From 0a9294ff06f7fddb45f5ddfd5da629a1bee53757 Mon Sep 17 00:00:00 2001 From: Mudit Pandey Date: Mon, 8 Dec 2025 10:25:49 -0500 Subject: [PATCH 1/7] Skip MLIR graph tests if system graphviz isn't installed --- .../pytest/python_interface/inspection/test_mlir_graph.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/test/pytest/python_interface/inspection/test_mlir_graph.py b/frontend/test/pytest/python_interface/inspection/test_mlir_graph.py index 380fe6a9e5..fffb83328e 100644 --- a/frontend/test/pytest/python_interface/inspection/test_mlir_graph.py +++ b/frontend/test/pytest/python_interface/inspection/test_mlir_graph.py @@ -14,14 +14,18 @@ """Unit test module for the MLIR graph generation in the Unified Compiler visualization module.""" from pathlib import Path +from subprocess import run import pytest # pylint: disable=wrong-import-position pytestmark = pytest.mark.xdsl -xdsl = pytest.importorskip("xdsl") graphviz = pytest.importorskip("graphviz") +if run(["which", "dot"]).returncode != 0: + pytest.skip(reason="Graphviz isn't installed.") + + import pennylane as qml from catalyst.passes.xdsl_plugin import getXDSLPluginAbsolutePath From bfdcbe9763471166c512086b89e2852dd901d281 Mon Sep 17 00:00:00 2001 From: Mudit Pandey Date: Mon, 8 Dec 2025 10:41:44 -0500 Subject: [PATCH 2/7] Fix quantum dialect test --- .../dialects/test_quantum_dialect.py | 13 +++++++++---- .../python_interface/inspection/test_mlir_graph.py | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/test/pytest/python_interface/dialects/test_quantum_dialect.py b/frontend/test/pytest/python_interface/dialects/test_quantum_dialect.py index 50804ef462..ae08a07069 100644 --- a/frontend/test/pytest/python_interface/dialects/test_quantum_dialect.py +++ b/frontend/test/pytest/python_interface/dialects/test_quantum_dialect.py @@ -13,7 +13,6 @@ # limitations under the License. """Unit tests for the xDSL Quantum dialect.""" - import pytest # pylint: disable=wrong-import-position @@ -30,7 +29,7 @@ i1, ) from xdsl.dialects.test import TestOp -from xdsl.ir import AttributeCovT, OpResult +from xdsl.ir import AttributeCovT, Block, Operation, OpResult, Region from catalyst.python_interface.dialects import Quantum from catalyst.python_interface.dialects.quantum import ( @@ -115,7 +114,10 @@ def create_ssa_value(t: AttributeCovT) -> OpResult[AttributeCovT]: state = create_ssa_value(TensorType(ComplexType(Float64Type()), shape=(16,))) expected_ops_init_kwargs = { - "AdjointOp": {"qreg": qreg, "region": (CustomOp(gate_name="CNOT", in_qubits=(q0, q1)),)}, + "AdjointOp": { + "qreg": qreg, + "region": Region(Block((CustomOp(gate_name="CNOT", in_qubits=(q0, q1)),))), + }, "AllocOp": {"nqubits": 3}, "AllocQubitOp": {}, "ComputationalBasisOp": {"operands": (q0, None), "result_types": (obs,)}, @@ -203,7 +205,10 @@ def test_only_existing_operations_are_expected(): @pytest.mark.parametrize("op", all_ops) def test_operation_construction(op): """Test the constructors of operations in the Quantum dialect.""" - kwargs = expected_ops_init_kwargs[op.__name__] + kwargs = { + k: v.clone() if isinstance(v, (Operation, Region)) else v + for k, v in expected_ops_init_kwargs[op.__name__].items() + } _ = op(**kwargs) diff --git a/frontend/test/pytest/python_interface/inspection/test_mlir_graph.py b/frontend/test/pytest/python_interface/inspection/test_mlir_graph.py index fffb83328e..3dd2e62dc7 100644 --- a/frontend/test/pytest/python_interface/inspection/test_mlir_graph.py +++ b/frontend/test/pytest/python_interface/inspection/test_mlir_graph.py @@ -20,6 +20,7 @@ # pylint: disable=wrong-import-position pytestmark = pytest.mark.xdsl +xdsl = pytest.importorskip("xdsl") graphviz = pytest.importorskip("graphviz") if run(["which", "dot"]).returncode != 0: From 429fee5338ea687eca61d91ae961517d252bfb2b Mon Sep 17 00:00:00 2001 From: Mudit Pandey Date: Mon, 8 Dec 2025 10:51:21 -0500 Subject: [PATCH 3/7] Update dev pennylane dep --- .dep-versions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dep-versions b/.dep-versions index 27e8c1a3fc..5bf366b639 100644 --- a/.dep-versions +++ b/.dep-versions @@ -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-dev44 +pennylane=0.44.0-dev48 # For a custom LQ/LK version, update the package version here and at # 'doc/requirements.txt' From 25f02d458273cfa42476abc415cf5fdadbdbd5a5 Mon Sep 17 00:00:00 2001 From: Mudit Pandey Date: Mon, 8 Dec 2025 10:57:18 -0500 Subject: [PATCH 4/7] Add check arg explicitly to subprocess.run --- .../test/pytest/python_interface/inspection/test_mlir_graph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/test/pytest/python_interface/inspection/test_mlir_graph.py b/frontend/test/pytest/python_interface/inspection/test_mlir_graph.py index 3dd2e62dc7..b87f1db377 100644 --- a/frontend/test/pytest/python_interface/inspection/test_mlir_graph.py +++ b/frontend/test/pytest/python_interface/inspection/test_mlir_graph.py @@ -23,7 +23,7 @@ xdsl = pytest.importorskip("xdsl") graphviz = pytest.importorskip("graphviz") -if run(["which", "dot"]).returncode != 0: +if run(["which", "dot"], check=False).returncode != 0: pytest.skip(reason="Graphviz isn't installed.") From 81783ec8f1be36ad618cbccf5e106fdb97eb4ba7 Mon Sep 17 00:00:00 2001 From: Mudit Pandey Date: Mon, 8 Dec 2025 15:23:31 -0500 Subject: [PATCH 5/7] Trigger CI From da9aa0258522903cca2f4b21c65bf4454aa1752e Mon Sep 17 00:00:00 2001 From: Mudit Pandey Date: Mon, 8 Dec 2025 15:49:31 -0500 Subject: [PATCH 6/7] Move specs entry to correct section --- doc/releases/changelog-dev.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index b5bd6fcf44..afa5f07941 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -10,6 +10,11 @@ `catalyst.python_interface` namespace. [(#2199)](https://github.com/PennyLaneAI/catalyst/pull/2199) + * A new `catalyst.python_interface.inspection.mlir_specs` function has been added to facilitate + PennyLane's new pass-by-pass specs feature. This function returns information gathered by parsing + the xDSL generated by a given QJIT object, such as gate counts, measurements, or qubit allocations. + [(#2238)](https://github.com/PennyLaneAI/catalyst/pull/2238) + This functionality was originally developed as part of the PennyLane package, and has been migrated here. For earlier development notes to the feature, please refer to the [PennyLane release notes](https://docs.pennylane.ai/en/stable/development/release_notes.html#release-0-43-0). @@ -355,11 +360,6 @@

Internal changes ⚙️

-* A new `catalyst.python_interface.inspection.mlir_specs` method has been added to facilitate - PennyLane's new pass-by-pass specs feature. This function returns information gathered by parsing - the xDSL generated by a given QJIT object, such as gate counts, measurements, or qubit allocations. - [(#2238)](https://github.com/PennyLaneAI/catalyst/pull/2238) - * 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, From ad7b3251c1ac21fd22fcffc1b93126abf1863fcb Mon Sep 17 00:00:00 2001 From: Mudit Pandey Date: Mon, 8 Dec 2025 16:41:45 -0500 Subject: [PATCH 7/7] Address code review --- doc/requirements.txt | 2 +- .../test/pytest/python_interface/inspection/test_mlir_graph.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/requirements.txt b/doc/requirements.txt index 4937e0d28f..fe60e0a4ae 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -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-dev44 +pennylane==0.44.0-dev48 diff --git a/frontend/test/pytest/python_interface/inspection/test_mlir_graph.py b/frontend/test/pytest/python_interface/inspection/test_mlir_graph.py index b87f1db377..e404099d07 100644 --- a/frontend/test/pytest/python_interface/inspection/test_mlir_graph.py +++ b/frontend/test/pytest/python_interface/inspection/test_mlir_graph.py @@ -23,7 +23,7 @@ xdsl = pytest.importorskip("xdsl") graphviz = pytest.importorskip("graphviz") -if run(["which", "dot"], check=False).returncode != 0: +if run(["/usr/bin/which", "dot"], check=False).returncode != 0: pytest.skip(reason="Graphviz isn't installed.")