Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dep-versions
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ enzyme=v0.0.203

# For a custom PL version, update the package version here and at
# 'doc/requirements.txt'
pennylane=0.44.0-dev48
pennylane=0.44.0-dev50

# For a custom LQ/LK version, update the package version here and at
# 'doc/requirements.txt'
Expand Down
4 changes: 4 additions & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@

<h3>Internal changes ⚙️</h3>

* Integration tests for `qml.specs` have been updated to match the new output format introduced
in PennyLane.
[(#2255)](https://github.com/PennyLaneAI/catalyst/pull/2255)

* Resource tracking now writes out at device destruction time instead of qubit deallocation
time. The written resources will be the total amount of resources collected throughout the
lifetime of the execution. For executions that split work between multiple functions,
Expand Down
2 changes: 1 addition & 1 deletion doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ lxml_html_clean
--extra-index-url https://test.pypi.org/simple/
pennylane-lightning-kokkos==0.44.0-dev16
pennylane-lightning==0.44.0-dev16
pennylane==0.44.0-dev48
pennylane==0.44.0-dev50
32 changes: 14 additions & 18 deletions frontend/test/pytest/test_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Test for qml.specs() Catalyst integration"""
"""Tests for qml.specs() Catalyst integration"""

import pennylane as qml
import pytest
from jax import numpy as jnp
Expand All @@ -21,22 +22,22 @@
# pylint:disable = protected-access,attribute-defined-outside-init


# TODO: Remove this method once feature parity has been reached, and instead use `==` directly
def check_specs_same(specs1, specs2):
"""Check that two specs dictionaries are the same."""
assert specs1["device_name"] == specs2["device_name"]
assert specs1["resources"].num_wires == specs2["resources"].num_wires
assert specs1["resources"].num_gates == specs2["resources"].num_gates
assert specs1["resources"].depth == specs2["resources"].depth
assert specs1["num_device_wires"] == specs2["num_device_wires"]
assert specs1["shots"] == specs2["shots"]

assert len(specs1["resources"].gate_types) == len(specs2["resources"].gate_types)
for gate, count in specs1["resources"].gate_types.items():
assert gate in specs2["resources"].gate_types
assert count == specs2["resources"].gate_types[gate]
assert specs1["resources"].gate_types == specs2["resources"].gate_types
assert specs1["resources"].gate_sizes == specs2["resources"].gate_sizes

assert len(specs1["resources"].gate_sizes) == len(specs2["resources"].gate_sizes)
for gate, count in specs1["resources"].gate_sizes.items():
assert gate in specs2["resources"].gate_sizes
assert count == specs2["resources"].gate_sizes[gate]
# Measurements are not yet supported in Catalyst device-level specs
# assert specs1["resources"].measurements == specs2["resources"].measurements

assert specs1["resources"].num_allocs == specs2["resources"].num_allocs
assert specs1["resources"].depth == specs2["resources"].depth
assert specs1["resources"].num_gates == specs2["resources"].num_gates


@pytest.mark.parametrize("level", ["device"])
Expand Down Expand Up @@ -85,14 +86,9 @@ def circuit():

assert cat_specs["device_name"] == "lightning.qubit"

# Catalyst level specs should report the number of controls for multi-controlled gates
assert "2C(S)" in cat_specs["resources"].gate_types
cat_specs["resources"].gate_types["C(S)"] += cat_specs["resources"].gate_types["2C(S)"]
del cat_specs["resources"].gate_types["2C(S)"]

# Catalyst will handle Adjoint(PauliY) == PauliY
assert "CY" in cat_specs["resources"].gate_types
cat_specs["resources"].gate_types["C(Adjoint(PauliY))"] += cat_specs["resources"].gate_types[
cat_specs["resources"].gate_types["C(Adjoint(PauliY))"] = cat_specs["resources"].gate_types[
"CY"
]
del cat_specs["resources"].gate_types["CY"]
Expand Down