Skip to content

Commit

Permalink
Daily rc sync to main (#1087)
Browse files Browse the repository at this point in the history
Automatic sync from the release candidate to main during a feature
freeze.

---------

Co-authored-by: Raul Torres <138264735+rauletorresc@users.noreply.github.com>
Co-authored-by: paul0403 <79805239+paul0403@users.noreply.github.com>
Co-authored-by: Mehrdad Malek <39844030+mehrdad2m@users.noreply.github.com>
Co-authored-by: Ahmed Darwish <exclass9.24@gmail.com>
Co-authored-by: erick-xanadu <110487834+erick-xanadu@users.noreply.github.com>
Co-authored-by: ringo-but-quantum <github-ringo-but-quantum@xanadu.ai>
Co-authored-by: David Ittah <dime10@users.noreply.github.com>
Co-authored-by: Romain Moyard <rmoyard@gmail.com>
Co-authored-by: GitHub Actions Bot <>
  • Loading branch information
9 people authored Aug 30, 2024
1 parent e4485e3 commit 1b2648e
Show file tree
Hide file tree
Showing 32 changed files with 718 additions and 158 deletions.
4 changes: 2 additions & 2 deletions .dep-versions
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ enzyme=v0.0.130

# For a custom PL version, update the package version here and at
# 'doc/requirements.txt
pennylane=0.38.0.dev11
pennylane=0.38.0.dev24

# For a custom LQ/LK version, update the package version here and at
# 'doc/requirements.txt'. Also, update the 'LIGHTNING_GIT_TAG' at
# 'runtime/Makefile' and at all GitHub workflows, using the exact
# commit hash corresponding to the merged PR that implements the
# desired feature.
lightning=0.38.0-dev34
lightning=0.38.0rc4
2 changes: 1 addition & 1 deletion .github/workflows/build-wheel-linux-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ jobs:
-DPYTHON_EXECUTABLE=$(which python${{ matrix.python_version }}) \
-Dpybind11_DIR=$(python${{ matrix.python_version }} -c "import pybind11; print(pybind11.get_cmake_dir())") \
-DENABLE_LAPACK=OFF \
-DLIGHTNING_GIT_TAG=c6b86a5 \
-DLIGHTNING_GIT_TAG=1536d88 \
-DENABLE_WARNINGS=OFF \
-DENABLE_OPENQASM=ON \
-DENABLE_OPENMP=OFF \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-wheel-macos-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ jobs:
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$GITHUB_WORKSPACE/runtime-build/lib \
-DPYTHON_EXECUTABLE=$(which python${{ matrix.python_version }}) \
-Dpybind11_DIR=$(python${{ matrix.python_version }} -c "import pybind11; print(pybind11.get_cmake_dir())") \
-DLIGHTNING_GIT_TAG=c6b86a5 \
-DLIGHTNING_GIT_TAG=1536d88 \
-DENABLE_LAPACK=OFF \
-DENABLE_WARNINGS=OFF \
-DENABLE_OPENQASM=ON \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-wheel-macos-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ jobs:
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$GITHUB_WORKSPACE/runtime-build/lib \
-DPYTHON_EXECUTABLE=$(which python${{ matrix.python_version }}) \
-Dpybind11_DIR=$(python${{ matrix.python_version }} -c "import pybind11; print(pybind11.get_cmake_dir())") \
-DLIGHTNING_GIT_TAG=c6b86a5 \
-DLIGHTNING_GIT_TAG=1536d88 \
-DENABLE_LAPACK=OFF \
-DENABLE_WARNINGS=OFF \
-DENABLE_OPENQASM=ON \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ cmake -S runtime -B runtime-build -G Ninja \
-DPYTHON_INCLUDE_DIR=/opt/_internal/cpython-${PYTHON_VERSION}.${PYTHON_SUBVERSION}/include/python${PYTHON_VERSION} \
-DPYTHON_LIBRARY=/opt/_internal/cpython-${PYTHON_VERSION}.${PYTHON_SUBVERSION}/lib \
-Dpybind11_DIR=/opt/_internal/cpython-${PYTHON_VERSION}.${PYTHON_SUBVERSION}/lib/python${PYTHON_VERSION}/site-packages/pybind11/share/cmake/pybind11 \
-DLIGHTNING_GIT_TAG=c6b86a5 \
-DLIGHTNING_GIT_TAG=1536d88 \
-DENABLE_LAPACK=OFF \
-DENABLE_WARNINGS=OFF \
-DENABLE_OPENQASM=ON \
Expand Down
26 changes: 23 additions & 3 deletions doc/releases/changelog-0.8.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@
* On devices that support it, initial state preparation routines `qml.StatePrep` and `qml.BasisState`
are no longer decomposed when using Catalyst, improving compilation and runtime performance.
[(#955)](https://github.com/PennyLaneAI/catalyst/pull/955)
[(#1047)](https://github.com/PennyLaneAI/catalyst/pull/1047)
[(#1062)](https://github.com/PennyLaneAI/catalyst/pull/1062)
[(#1073)](https://github.com/PennyLaneAI/catalyst/pull/1073)

* Improved type validation and error messaging has been added to both the `catalyst.jvp`
and `catalyst.vjp` functions to ensure that the (co)tangent and parameter types are compatible.
Expand Down Expand Up @@ -455,6 +458,20 @@

<h3>Bug fixes</h3>

* Catalyst no longer silently converts complex parameters to floats where floats are expected,
instead an error is raised.
[(#1008)](https://github.com/PennyLaneAI/catalyst/pull/1008)

* Fixes a bug where dynamic one-shot did not work when no mid-circuit measurements are present
and when the return type is an iterable.
[(#1060)](https://github.com/PennyLaneAI/catalyst/pull/1060)

* Fixes a bug finding the quantum function jaxpr when using quantum primitives with dynamic one-shot
[(#1041)](https://github.com/PennyLaneAI/catalyst/pull/1041)

* Fix a bug where LegacyDevice number of shots is not correctly extracted when using the legacyDeviceFacade.
[(#1035)](https://github.com/PennyLaneAI/catalyst/pull/1035)

* Catalyst no longer generates a `QubitUnitary` operation during decomposition if a device doesn't
support it. Instead, the operation that would lead to a `QubitUnitary` is either decomposed or
raises an error.
Expand Down Expand Up @@ -545,10 +562,10 @@
@catalyst.pure_callback
def callback_fn(x) -> jax.ShapeDtypeStruct((2,), jnp.float32):
return np.array([np.sin(x), np.cos(x)])

callback_fn.fwd(lambda x: (callback_fn(x), x))
callback_fn.bwd(lambda x, dy: (jnp.array([jnp.cos(x), -jnp.sin(x)]) @ dy,))

@qjit
@catalyst.grad
def f(x):
Expand Down Expand Up @@ -603,6 +620,9 @@
function inputs.
[(#1003)](https://github.com/PennyLaneAI/catalyst/pull/1003)

* Bug fixed when parameter annotations return strings.
[(#1078)](https://github.com/PennyLaneAI/catalyst/pull/1078)

<h3>Documentation</h3>

* A page has been added to the documentation, listing devices that are
Expand Down Expand Up @@ -676,4 +696,4 @@ Mudit Pandey,
Nate Stemen,
Raul Torres,
Tzung-Han Juang,
Paul Haochen Wang,
Paul Haochen Wang,
6 changes: 3 additions & 3 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ lxml_html_clean

# Pre-install PL development wheels
--extra-index-url https://test.pypi.org/simple/
pennylane-lightning-kokkos==0.38.0-dev34
pennylane-lightning==0.38.0-dev34
pennylane==0.38.0.dev11
pennylane-lightning-kokkos==0.38.0rc4
pennylane-lightning==0.38.0rc4
pennylane==0.38.0.dev24
2 changes: 0 additions & 2 deletions frontend/catalyst/api_extensions/differentiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,6 @@ def _make_jaxpr_check_differentiable(
with mark_gradient_tracing(method):
jaxpr, shape = jax.make_jaxpr(f, return_shape=True)(*args, **kwargs)
_, out_tree = tree_flatten(shape)
assert len(jaxpr.eqns) == 1, "Expected jaxpr consisting of a single function call."
assert jaxpr.eqns[0].primitive == func_p, "Expected jaxpr consisting of a single function call."

for pos, arg in enumerate(jaxpr.in_avals):
if arg.dtype.kind != "f" and pos in grad_params.expanded_argnums:
Expand Down
17 changes: 10 additions & 7 deletions frontend/catalyst/device/qjit_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
verify_operations,
)
from catalyst.logging import debug_logger, debug_logger_init
from catalyst.third_party.cuda import SoftwareQQPP
from catalyst.utils.exceptions import CompileError
from catalyst.utils.patching import Patcher
from catalyst.utils.runtime_environment import get_lib_path
Expand Down Expand Up @@ -133,7 +134,7 @@

def get_device_shots(dev):
"""Helper function to get device shots."""
return dev.shots if isinstance(dev, qml.devices.LegacyDevice) else dev.shots.total_shots
return dev.shots.total_shots if isinstance(dev, qml.devices.Device) else dev.shots


@dataclass
Expand All @@ -153,8 +154,8 @@ def extract_backend_info(device: qml.QubitDevice, capabilities: DeviceCapabiliti
to a valid TOML config file."""

dname = device.name
if isinstance(device, qml.devices.LegacyDevice):
dname = device.short_name
if isinstance(device, qml.devices.LegacyDeviceFacade):
dname = device.target_device.short_name

device_name = ""
device_lpath = ""
Expand Down Expand Up @@ -189,18 +190,18 @@ def extract_backend_info(device: qml.QubitDevice, capabilities: DeviceCapabiliti
device_kwargs["device_type"] = dname
device_kwargs["backend"] = (
# pylint: disable=protected-access
device._device._delegate.DEVICE_ID
device.target_device._device._delegate.DEVICE_ID
)
elif dname == "braket.aws.qubit": # pragma: no cover
device_kwargs["device_type"] = dname
device_kwargs["device_arn"] = device._device._arn # pylint: disable=protected-access
if device._s3_folder: # pylint: disable=protected-access
if device.target_device._s3_folder: # pylint: disable=protected-access
device_kwargs["s3_destination_folder"] = str(
device._s3_folder # pylint: disable=protected-access
device.target_device._s3_folder # pylint: disable=protected-access
)

for k, v in capabilities.options.items():
if hasattr(device, v):
if hasattr(device, v) and not k in device_kwargs:
device_kwargs[k] = getattr(device, v)

return BackendInfo(dname, device_name, device_lpath, device_kwargs)
Expand Down Expand Up @@ -506,6 +507,8 @@ def preprocess(
def _measurement_transform_program(self):

measurement_program = TransformProgram()
if isinstance(self.original_device, SoftwareQQPP):
return measurement_program

supports_sum_observables = any(
obs in self.qjit_capabilities.native_obs for obs in ("Sum", "Hamiltonian")
Expand Down
8 changes: 5 additions & 3 deletions frontend/catalyst/device/verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,16 @@ def _verify_nested(

ctx = EvaluationContext.get_main_tracing_context()
for op in tape.operations:
state = op_checker_fn(op, state)
inner_state = op_checker_fn(op, state)
if has_nested_tapes(op):
for region in nested_quantum_regions(op):
if region.trace is not None:
with EvaluationContext.frame_tracing_context(ctx, region.trace):
state = _verify_nested(region.quantum_tape, state, op_checker_fn)
inner_state = _verify_nested(
region.quantum_tape, inner_state, op_checker_fn
)
else:
state = _verify_nested(region.quantum_tape, state, op_checker_fn)
inner_state = _verify_nested(region.quantum_tape, inner_state, op_checker_fn)
return state


Expand Down
Loading

0 comments on commit 1b2648e

Please sign in to comment.