Skip to content

Commit af3e13b

Browse files
authored
Miscellaneous fixes to the unified compiler (#2274)
* Update MLIR graph tests so that they are skipped if at least one of the following conditions is not met: * The Python `graphviz` package is not installed * The system-level `graphviz` package is not installed * Update a test for the xDSL Quantum dialect that was causing the `--force-flaky` workflow to fail * Update version of PennyLane in `.dep-versions` * Move changelog entry for `qml.specs` integration with xDSL to the correct section
1 parent 3fa1455 commit af3e13b

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

.dep-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ enzyme=v0.0.203
1010

1111
# For a custom PL version, update the package version here and at
1212
# 'doc/requirements.txt'
13-
pennylane=0.44.0-dev44
13+
pennylane=0.44.0-dev48
1414

1515
# For a custom LQ/LK version, update the package version here and at
1616
# 'doc/requirements.txt'

doc/releases/changelog-dev.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
`catalyst.python_interface` namespace.
1111
[(#2199)](https://github.com/PennyLaneAI/catalyst/pull/2199)
1212

13+
* A new `catalyst.python_interface.inspection.mlir_specs` function has been added to facilitate
14+
PennyLane's new pass-by-pass specs feature. This function returns information gathered by parsing
15+
the xDSL generated by a given QJIT object, such as gate counts, measurements, or qubit allocations.
16+
[(#2238)](https://github.com/PennyLaneAI/catalyst/pull/2238)
17+
1318
This functionality was originally developed as part of the PennyLane package, and has been migrated here.
1419
For earlier development notes to the feature, please refer to the
1520
[PennyLane release notes](https://docs.pennylane.ai/en/stable/development/release_notes.html#release-0-43-0).
@@ -361,11 +366,6 @@
361366

362367
<h3>Internal changes ⚙️</h3>
363368

364-
* A new `catalyst.python_interface.inspection.mlir_specs` method has been added to facilitate
365-
PennyLane's new pass-by-pass specs feature. This function returns information gathered by parsing
366-
the xDSL generated by a given QJIT object, such as gate counts, measurements, or qubit allocations.
367-
[(#2238)](https://github.com/PennyLaneAI/catalyst/pull/2238)
368-
369369
* Resource tracking now writes out at device destruction time instead of qubit deallocation
370370
time. The written resources will be the total amount of resources collected throughout the
371371
lifetime of the execution. For executions that split work between multiple functions,

doc/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ lxml_html_clean
3333
--extra-index-url https://test.pypi.org/simple/
3434
pennylane-lightning-kokkos==0.44.0-dev16
3535
pennylane-lightning==0.44.0-dev16
36-
pennylane==0.44.0-dev44
36+
pennylane==0.44.0-dev48

frontend/test/pytest/python_interface/dialects/test_quantum_dialect.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414

1515
"""Unit tests for the xDSL Quantum dialect."""
16-
1716
import pytest
1817

1918
# pylint: disable=wrong-import-position
@@ -30,7 +29,7 @@
3029
i1,
3130
)
3231
from xdsl.dialects.test import TestOp
33-
from xdsl.ir import AttributeCovT, OpResult
32+
from xdsl.ir import AttributeCovT, Block, Operation, OpResult, Region
3433

3534
from catalyst.python_interface.dialects import Quantum
3635
from catalyst.python_interface.dialects.quantum import (
@@ -115,7 +114,10 @@ def create_ssa_value(t: AttributeCovT) -> OpResult[AttributeCovT]:
115114
state = create_ssa_value(TensorType(ComplexType(Float64Type()), shape=(16,)))
116115

117116
expected_ops_init_kwargs = {
118-
"AdjointOp": {"qreg": qreg, "region": (CustomOp(gate_name="CNOT", in_qubits=(q0, q1)),)},
117+
"AdjointOp": {
118+
"qreg": qreg,
119+
"region": Region(Block((CustomOp(gate_name="CNOT", in_qubits=(q0, q1)),))),
120+
},
119121
"AllocOp": {"nqubits": 3},
120122
"AllocQubitOp": {},
121123
"ComputationalBasisOp": {"operands": (q0, None), "result_types": (obs,)},
@@ -203,7 +205,10 @@ def test_only_existing_operations_are_expected():
203205
@pytest.mark.parametrize("op", all_ops)
204206
def test_operation_construction(op):
205207
"""Test the constructors of operations in the Quantum dialect."""
206-
kwargs = expected_ops_init_kwargs[op.__name__]
208+
kwargs = {
209+
k: v.clone() if isinstance(v, (Operation, Region)) else v
210+
for k, v in expected_ops_init_kwargs[op.__name__].items()
211+
}
207212
_ = op(**kwargs)
208213

209214

frontend/test/pytest/python_interface/inspection/test_mlir_graph.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"""Unit test module for the MLIR graph generation in the Unified Compiler visualization module."""
1515

1616
from pathlib import Path
17+
from subprocess import run
1718

1819
import pytest
1920

@@ -22,6 +23,10 @@
2223
xdsl = pytest.importorskip("xdsl")
2324
graphviz = pytest.importorskip("graphviz")
2425

26+
if run(["/usr/bin/which", "dot"], check=False).returncode != 0:
27+
pytest.skip(reason="Graphviz isn't installed.")
28+
29+
2530
import pennylane as qml
2631

2732
from catalyst.passes.xdsl_plugin import getXDSLPluginAbsolutePath

0 commit comments

Comments
 (0)