From 46010b9c065c0fcfe7b6759785a4d4674f81bd0a Mon Sep 17 00:00:00 2001 From: Jake Zaia Date: Mon, 1 Dec 2025 20:23:39 +0000 Subject: [PATCH 1/2] Update tests to match new specs output types --- frontend/test/pytest/test_specs.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/frontend/test/pytest/test_specs.py b/frontend/test/pytest/test_specs.py index 61abdcf3da..eb811cba38 100644 --- a/frontend/test/pytest/test_specs.py +++ b/frontend/test/pytest/test_specs.py @@ -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 @@ -21,22 +22,22 @@ # pylint:disable = protected-access,attribute-defined-outside-init +# TODO: Remove this method once feature pairty 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"]) @@ -92,7 +93,7 @@ def circuit(): # 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"] From a8bfd06e9d969db2e7661e6b7394923632c89fcd Mon Sep 17 00:00:00 2001 From: Jake Zaia Date: Wed, 3 Dec 2025 21:20:27 +0000 Subject: [PATCH 2/2] Slight change to accomodate new control qubit counting --- frontend/test/pytest/test_specs.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/frontend/test/pytest/test_specs.py b/frontend/test/pytest/test_specs.py index eb811cba38..5b81b2084b 100644 --- a/frontend/test/pytest/test_specs.py +++ b/frontend/test/pytest/test_specs.py @@ -86,11 +86,6 @@ 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[