diff --git a/.github/workflows/build-wheel-linux-arm64.yaml b/.github/workflows/build-wheel-linux-arm64.yaml
index da2bc5eb7e..162f44eccb 100644
--- a/.github/workflows/build-wheel-linux-arm64.yaml
+++ b/.github/workflows/build-wheel-linux-arm64.yaml
@@ -467,6 +467,9 @@ jobs:
- name: Install Python dependencies
run: |
python${{ matrix.python_version }} -m pip install pytest pytest-xdist pytest-mock
+ # Install graphviz for testing the mlir-op-graph integration
+ sudo apt-get install -y graphviz
+ python${{ matrix.python_version }} -m pip install graphviz
- name: Install PennyLane Plugins
run: |
@@ -493,9 +496,9 @@ jobs:
- name: Run Python Pytest Tests
run: |
python${{ matrix.python_version }} -m pytest frontend/test/pytest -n auto
- python${{ matrix.python_version }} -m pytest frontend/test/pytest --backend="lightning.kokkos" -n auto
+ python${{ matrix.python_version }} -m pytest frontend/test/pytest --backend="lightning.kokkos" -n auto -m "not xdsl"
python${{ matrix.python_version }} -m pytest frontend/test/async_tests
- python${{ matrix.python_version }} -m pytest frontend/test/pytest --runbraket=LOCAL -n auto || true
+ python${{ matrix.python_version }} -m pytest frontend/test/pytest --runbraket=LOCAL -n auto -m "not xdsl" || true
python${{ matrix.python_version }} -m pytest frontend/test/test_oqc/oqc -n auto
- name: Run Standalone Plugin Tests
@@ -503,16 +506,3 @@ jobs:
if: env.BUILD_STANDALONE_PLUGIN == 'true'
run: |
python${{ matrix.python_version }} -m pytest standalone_plugin_wheel/standalone_plugin/test -n auto
-
- - name: Install Unified Compiler Dependencies
- run: |
- python${{ matrix.python_version }} -m pip install xdsl~=0.55.0 xdsl-jax==0.1.1
- # Install graphviz for testing the mlir-op-graph integration
- sudo apt-get install -y graphviz
- python${{ matrix.python_version }} -m pip install graphviz
-
- - name: Run Unified Compiler Tests
- run: |
- python${{ matrix.python_version }} -m pytest frontend/test/pytest -n auto -m "xdsl"
-
-
diff --git a/.github/workflows/build-wheel-linux-x86_64.yaml b/.github/workflows/build-wheel-linux-x86_64.yaml
index d54de0f541..2f88dce2bf 100644
--- a/.github/workflows/build-wheel-linux-x86_64.yaml
+++ b/.github/workflows/build-wheel-linux-x86_64.yaml
@@ -486,6 +486,9 @@ jobs:
- name: Install Python dependencies
run: |
python${{ matrix.python_version }} -m pip install pytest pytest-xdist pytest-mock
+ # Install graphviz for testing the mlir-op-graph integration
+ sudo apt-get install -y graphviz
+ python${{ matrix.python_version }} -m pip install graphviz
- name: Install PennyLane Plugins
run: |
@@ -512,9 +515,9 @@ jobs:
- name: Run Python Pytest Tests
run: |
python${{ matrix.python_version }} -m pytest frontend/test/pytest -n auto
- python${{ matrix.python_version }} -m pytest frontend/test/pytest --backend="lightning.kokkos" -n auto
+ python${{ matrix.python_version }} -m pytest frontend/test/pytest --backend="lightning.kokkos" -n auto -m "not xdsl"
python${{ matrix.python_version }} -m pytest frontend/test/async_tests
- python${{ matrix.python_version }} -m pytest frontend/test/pytest --runbraket=LOCAL -n auto || true
+ python${{ matrix.python_version }} -m pytest frontend/test/pytest --runbraket=LOCAL -n auto -m "not xdsl" || true
python${{ matrix.python_version }} -m pytest frontend/test/test_oqc/oqc -n auto
- name: Run Standalone Plugin Tests
@@ -522,14 +525,3 @@ jobs:
if: env.BUILD_STANDALONE_PLUGIN == 'true'
run: |
python${{ matrix.python_version }} -m pytest standalone_plugin_wheel/standalone_plugin/test -n auto
-
- - name: Install Unified Compiler Dependencies
- run: |
- python${{ matrix.python_version }} -m pip install xdsl~=0.55.0 xdsl-jax==0.1.1
- # Install graphviz for testing the mlir-op-graph integration
- sudo apt-get install -y graphviz
- python${{ matrix.python_version }} -m pip install graphviz
-
- - name: Run Unified Compiler Tests
- run: |
- python${{ matrix.python_version }} -m pytest frontend/test/pytest -n auto -m "xdsl"
diff --git a/.github/workflows/build-wheel-macos-arm64.yaml b/.github/workflows/build-wheel-macos-arm64.yaml
index a5d53d18a7..cc5cf5d342 100644
--- a/.github/workflows/build-wheel-macos-arm64.yaml
+++ b/.github/workflows/build-wheel-macos-arm64.yaml
@@ -467,6 +467,9 @@ jobs:
- name: Install Python dependencies
run: |
python${{ matrix.python_version }} -m pip install pytest pytest-xdist pytest-mock
+ # Install graphviz for testing the mlir-op-graph integration
+ brew install graphviz
+ python${{ matrix.python_version }} -m pip install graphviz
- name: Install PennyLane Plugins
run: |
@@ -493,9 +496,9 @@ jobs:
- name: Run Python Pytest Tests
run: |
python${{ matrix.python_version }} -m pytest frontend/test/pytest -n auto
- python${{ matrix.python_version }} -m pytest frontend/test/pytest --backend="lightning.kokkos" -n auto
+ python${{ matrix.python_version }} -m pytest frontend/test/pytest --backend="lightning.kokkos" -n auto -m "not xdsl"
python${{ matrix.python_version }} -m pytest frontend/test/async_tests
- python${{ matrix.python_version }} -m pytest frontend/test/pytest --runbraket=LOCAL -n auto || true
+ python${{ matrix.python_version }} -m pytest frontend/test/pytest --runbraket=LOCAL -n auto -m "not xdsl" || true
python${{ matrix.python_version }} -m pytest frontend/test/test_oqc/oqc -n auto
- name: Run Standalone Plugin Tests
@@ -503,14 +506,3 @@ jobs:
if: env.BUILD_STANDALONE_PLUGIN == 'true'
run: |
python${{ matrix.python_version }} -m pytest standalone_plugin_wheel/standalone_plugin/test -n auto
-
- - name: Install Unified Compiler Dependencies
- run: |
- python${{ matrix.python_version }} -m pip install xdsl~=0.55.0 xdsl-jax==0.1.1
- # Install graphviz for testing the mlir-op-graph integration
- brew install graphviz
- python${{ matrix.python_version }} -m pip install graphviz
-
- - name: Run Unified Compiler Tests
- run: |
- python${{ matrix.python_version }} -m pytest frontend/test/pytest -n auto -m "xdsl"
diff --git a/.github/workflows/check-catalyst.yaml b/.github/workflows/check-catalyst.yaml
index 89ca023563..54d0d399e9 100644
--- a/.github/workflows/check-catalyst.yaml
+++ b/.github/workflows/check-catalyst.yaml
@@ -473,6 +473,9 @@ jobs:
# macOS requirements.txt
python3 -m pip install cuda-quantum==0.6.0
python3 -m pip install oqc-qcaas-client
+ # Install graphviz for testing the mlir-op-graph integration
+ sudo apt-get install -y graphviz
+ python3 -m pip install graphviz
make frontend
- name: Get Cached LLVM Build
@@ -533,17 +536,6 @@ jobs:
MDD_BENCHMARK_PRECISION=1 \
python3 -m pytest demos -k "tutorial_qft_arithmetics.ipynb" --nbmake
- - name: Install Unified Compiler Dependencies
- run: |
- python3 -m pip install xdsl~=0.55.0 xdsl-jax==0.1.1
- # Install graphviz for testing the mlir-op-graph integration
- sudo apt-get install -y graphviz
- python3 -m pip install graphviz
-
- - name: Run Unified Compiler Tests
- run: |
- python3 -m pytest frontend/test/pytest -n auto -m "xdsl"
-
frontend-tests-lightning-kokkos:
name: Frontend Tests (backend="lightning.kokkos")
needs: [constants, llvm, runtime, quantum, determine_runner]
@@ -599,7 +591,8 @@ jobs:
- name: Run Python Pytest Tests (backend=lightning.kokkos)
run: |
- make pytest TEST_BACKEND="lightning.kokkos"
+ # Don't run xDSL tests
+ make pytest TEST_BACKEND="lightning.kokkos" XDSL_TESTS=OFF
frontend-tests-openqasm-device:
name: Frontend Tests (backend="openqasm3")
diff --git a/.github/workflows/check-pl-compat.yaml b/.github/workflows/check-pl-compat.yaml
index 3832845086..2264cc0f4d 100644
--- a/.github/workflows/check-pl-compat.yaml
+++ b/.github/workflows/check-pl-compat.yaml
@@ -195,7 +195,7 @@ jobs:
- name: Run Frontend Tests (Kokkos)
run: |
- make pytest TEST_BACKEND="lightning.kokkos"
+ make pytest TEST_BACKEND="lightning.kokkos" XDSL_TESTS=OFF
- name: Run Frontend Tests (Braket)
run: |
@@ -207,36 +207,3 @@ jobs:
# We skip them for now. These demos should be properly moved to the qml repo.
MDD_BENCHMARK_PRECISION=1 \
python3 -m pytest demos -k "tutorial_qft_arithmetics.ipynb" --nbmake
-
- - name: Check If Unified Compiler Tests Should Execute
- id: check_unified_compiler
- run: |
- # Check if installed pennylane has python_compiler module
- EXIT_CODE=0
- python3 -c "from pennylane.compiler import python_compiler" || EXIT_CODE=$?
-
- # For Unified Compiler tests to execute, PennyLane must NOT have the 'compiler.python_compiler'
- # submodule, and Catalyst MUST have the 'python_interface' submodule
- if [[ -d "$GITHUB_WORKSPACE/frontend/catalyst/python_interface" && EXIT_CODE -ne 0 ]]; then
- echo "unified_compiler_available='true'" >> $GITHUB_OUTPUT
- else
- echo "unified_compiler_available='false'" >> $GITHUB_OUTPUT
- fi
-
- - name: Install Unified Compiler Dependencies
- if: steps.check_unified_compiler.outputs.unified_compiler_available == 'true'
- run: |
- python3 -m pip install xdsl~=0.55.0 xdsl-jax==0.1.1
- # Install graphviz for testing the mlir-op-graph integration
- sudo apt-get install -y graphviz
- python3 -m pip install graphviz
-
- - name: Run Unified Compiler Tests
- if: steps.check_unified_compiler.outputs.unified_compiler_available == 'true'
- run: |
- python3 -m pytest frontend/test/pytest -n auto -m "xdsl"
-
- - name: Run Unified Compiler Tests (Kokkos)
- if: steps.check_unified_compiler.outputs.unified_compiler_available == 'true'
- run: |
- python3 -m pytest frontend/test/pytest --backend="lightning.kokkos" -n auto -m "xdsl"
diff --git a/Makefile b/Makefile
index 3133696093..c6addfa5a4 100644
--- a/Makefile
+++ b/Makefile
@@ -22,6 +22,7 @@ TEST_BRAKET ?= NONE
ENABLE_ASAN ?= OFF
TOML_SPECS ?= $(shell find ./runtime ./frontend -name '*.toml' -not -name 'pyproject.toml')
ENABLE_FLAKY ?= OFF
+XDSL_TESTS ?= ON
PLATFORM := $(shell uname -s)
ifeq ($(PLATFORM),Linux)
@@ -59,7 +60,11 @@ FLAKY :=
ifeq ($(ENABLE_FLAKY),ON)
FLAKY := --force-flaky --max-runs=5 --min-passes=5
endif
-PYTEST_FLAGS := $(PARALLELIZE) $(TEST_EXCLUDES) $(FLAKY)
+XDSL_MARKER :=
+ifeq ($(XDSL_TESTS),OFF)
+XDSL_MARKER := -m "not xdsl"
+endif
+PYTEST_FLAGS := $(PARALLELIZE) $(TEST_EXCLUDES) $(FLAKY) $(XDSL_MARKER)
# TODO: Find out why we have container overflow on macOS.
ASAN_OPTIONS := ASAN_OPTIONS="detect_leaks=0,detect_container_overflow=0"
diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md
index 92d8569d33..5d88f6f96c 100644
--- a/doc/releases/changelog-dev.md
+++ b/doc/releases/changelog-dev.md
@@ -294,14 +294,12 @@
Bug fixes 🐛
-<<<<<<< mlxd/fix_cond_measure_test
* Updated tests and PennyLane dependency pin to follow changes introduced by [PennyLaneAI/pennylane#8290](https://github.com/PennyLaneAI/pennylane/pull/8290).
[(#2286)](https://github.com/PennyLaneAI/catalyst/pull/2286)
-=======
+
* Update `catalyst.python_interface.inspection.xdsl_conversion.get_mlir_module` to
no longer explicitly use the xDSL pass plugin.
[(#2303)](https://github.com/PennyLaneAI/catalyst/pull/2303)
->>>>>>> main
* Added missing `detensorize-function-boundary` and `symbol-dce` passes to `Pipelines.cpp`.
[(#2266)](https://github.com/PennyLaneAI/catalyst/pull/2266)
@@ -387,6 +385,9 @@
Internal changes ⚙️
+* xDSL and xDSL-JAX are now dependencies of Catalyst.
+ [(#2282)](https://github.com/PennyLaneAI/catalyst/pull/2282)
+
* Python 3.14 is now officially supported. Added the forward capability with Python 3.14.
[(#2271)](https://github.com/PennyLaneAI/catalyst/pull/2271)
@@ -532,6 +533,7 @@ Joseph Lee,
Mehrdad Malekmohammadi,
River McCubbin,
Lee J. O'Riordan,
+Mudit Pandey,
Andrija Paurevic,
Roberto Turrado,
Paul Haochen Wang,
diff --git a/frontend/catalyst/python_interface/xdsl_universe.py b/frontend/catalyst/python_interface/xdsl_universe.py
index fec6306945..8b3dfa1e19 100644
--- a/frontend/catalyst/python_interface/xdsl_universe.py
+++ b/frontend/catalyst/python_interface/xdsl_universe.py
@@ -13,45 +13,33 @@
# limitations under the License.
"""xDSL universe for containing all dialects and passes."""
-xdsl_available = True
-
-try:
- from xdsl.passes import ModulePass
- from xdsl.universe import Universe
-except (ImportError, ModuleNotFoundError):
- xdsl_available = False # pragma: no cover
-
-# We must check that xDSL is installed because we're adding an entry point to
-# PennyLane that references this file, and we must ensure that PennyLane can
-# be installed in environments where xDSL is not installed.
-XDSL_UNIVERSE = None
-
-if xdsl_available:
- # pylint: disable=import-outside-toplevel
- from . import dialects, transforms
-
- shared_dialects = ("stablehlo", "transform")
-
- # Create a map from dialect names to dialect classes. Dialects that are already
- # provided by xDSL cannot be loaded into the multiverse, so we don't add them to
- # our universe.
- names_to_dialects = {
- d.name: d
- for name in dialects.__all__
- if (d := getattr(dialects, name)).name not in shared_dialects
- }
-
- # Create a map from pass names to their respective ModulePass. The transforms module
- # contains PassDispatcher instances as well as ModulePasses. We only want to collect
- # the ModulePasses. We cannot use issubclass with instances, which is why we first
- # check if isinstance(transform, type).
- names_to_passes = {
- t.name: t
- for name in transforms.__all__
- if isinstance((t := getattr(transforms, name)), type) and issubclass(t, ModulePass)
- }
-
- # The Universe is used to expose custom dialects and transforms to xDSL. It is
- # specified as an entry point in PennyLane's pyproject.toml file, which makes
- # it available to look up by xDSL for tools such as xdsl-opt, xdsl-gui, etc.
- XDSL_UNIVERSE = Universe(all_dialects=names_to_dialects, all_passes=names_to_passes)
+from xdsl.passes import ModulePass
+from xdsl.universe import Universe
+
+from . import dialects, transforms
+
+shared_dialects = ("stablehlo",)
+
+# Create a map from dialect names to dialect classes. Dialects that are already
+# provided by xDSL cannot be loaded into the multiverse, so we don't add them to
+# our universe.
+names_to_dialects = {
+ d.name: d
+ for name in dialects.__all__
+ if (d := getattr(dialects, name)).name not in shared_dialects
+}
+
+# Create a map from pass names to their respective ModulePass. The transforms module
+# contains PassDispatcher instances as well as ModulePasses. We only want to collect
+# the ModulePasses. We cannot use issubclass with instances, which is why we first
+# check if isinstance(transform, type).
+names_to_passes = {
+ t.name: t
+ for name in transforms.__all__
+ if isinstance((t := getattr(transforms, name)), type) and issubclass(t, ModulePass)
+}
+
+# The Universe is used to expose custom dialects and transforms to xDSL. It is
+# specified as an entry point in PennyLane's pyproject.toml file, which makes
+# it available to look up by xDSL for tools such as xdsl-opt, xdsl-gui, etc.
+XDSL_UNIVERSE = Universe(all_dialects=names_to_dialects, all_passes=names_to_passes)
diff --git a/frontend/test/pytest/python_interface/dialects/test_catalyst_dialect.py b/frontend/test/pytest/python_interface/dialects/test_catalyst_dialect.py
index 41c1a0f1d6..908577970b 100644
--- a/frontend/test/pytest/python_interface/dialects/test_catalyst_dialect.py
+++ b/frontend/test/pytest/python_interface/dialects/test_catalyst_dialect.py
@@ -11,17 +11,13 @@
# 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.
-
"""Unit test module for the xDSL Catalyst dialect."""
import pytest
-# pylint: disable=wrong-import-position
+from catalyst.python_interface.dialects import Catalyst
pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
-
-from catalyst.python_interface.dialects import Catalyst
all_ops = list(Catalyst.operations)
all_attrs = list(Catalyst.attributes)
diff --git a/frontend/test/pytest/python_interface/dialects/test_mbqc_dialect.py b/frontend/test/pytest/python_interface/dialects/test_mbqc_dialect.py
index c19256aa73..36084116ba 100644
--- a/frontend/test/pytest/python_interface/dialects/test_mbqc_dialect.py
+++ b/frontend/test/pytest/python_interface/dialects/test_mbqc_dialect.py
@@ -11,16 +11,10 @@
# 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.
-
"""Unit tests for the xDSL MBQC dialect."""
-
+# pylint: disable=line-too-long
import pytest
-
-# pylint: disable=wrong-import-position,line-too-long
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
-
from xdsl.context import Context
from xdsl.dialects import arith, builtin, test
from xdsl.parser import Parser
@@ -28,6 +22,8 @@
from catalyst.python_interface.dialects import Quantum, mbqc
+pytestmark = pytest.mark.xdsl
+
all_ops = list(mbqc.MBQC.operations)
all_attrs = list(mbqc.MBQC.attributes)
diff --git a/frontend/test/pytest/python_interface/dialects/test_qec_dialect.py b/frontend/test/pytest/python_interface/dialects/test_qec_dialect.py
index b42713d0c7..5347e51e35 100644
--- a/frontend/test/pytest/python_interface/dialects/test_qec_dialect.py
+++ b/frontend/test/pytest/python_interface/dialects/test_qec_dialect.py
@@ -11,17 +11,14 @@
# 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.
-
"""Unit tests for the xDSL QEC dialect."""
import pytest
-# pylint: disable=wrong-import-position
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
-
from catalyst.python_interface.dialects import QEC
+pytestmark = pytest.mark.xdsl
+
all_ops = list(QEC.operations)
all_attrs = list(QEC.attributes)
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 ae08a07069..2f925e128c 100644
--- a/frontend/test/pytest/python_interface/dialects/test_quantum_dialect.py
+++ b/frontend/test/pytest/python_interface/dialects/test_quantum_dialect.py
@@ -11,14 +11,9 @@
# 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.
-
"""Unit tests for the xDSL Quantum dialect."""
-import pytest
-
-# pylint: disable=wrong-import-position
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
+import pytest
from xdsl.dialects.builtin import (
I32,
ComplexType,
@@ -40,6 +35,8 @@
QuregType,
)
+pytestmark = pytest.mark.xdsl
+
all_ops = list(Quantum.operations)
all_attrs = list(Quantum.attributes)
diff --git a/frontend/test/pytest/python_interface/dialects/test_stablehlo_dialect.py b/frontend/test/pytest/python_interface/dialects/test_stablehlo_dialect.py
index 40e96a51b6..64655dd770 100644
--- a/frontend/test/pytest/python_interface/dialects/test_stablehlo_dialect.py
+++ b/frontend/test/pytest/python_interface/dialects/test_stablehlo_dialect.py
@@ -11,13 +11,12 @@
# 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.
-
"""Unit test module for catalyst/python_interface/dialects/stablehlo.py."""
# pylint: disable=line-too-long
+
import pytest
pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
def test_all_unary_operations(run_filecheck):
diff --git a/frontend/test/pytest/python_interface/dialects/test_transform_dialect.py b/frontend/test/pytest/python_interface/dialects/test_transform_dialect.py
index 19f4c0907e..a8f78ad700 100644
--- a/frontend/test/pytest/python_interface/dialects/test_transform_dialect.py
+++ b/frontend/test/pytest/python_interface/dialects/test_transform_dialect.py
@@ -11,17 +11,12 @@
# 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.
-
"""Unit tests for the xDSL Transform dialect."""
+# pylint: disable=line-too-long
from dataclasses import dataclass
import pytest
-
-# pylint: disable=wrong-import-position,line-too-long
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
-
from xdsl import passes
from xdsl.context import Context
from xdsl.dialects import builtin, transform
@@ -37,6 +32,8 @@
compiler_transform,
)
+pytestmark = pytest.mark.xdsl
+
def test_dict_options():
"""Test ApplyRegisteredPassOp constructor with DictionaryAttr options."""
diff --git a/frontend/test/pytest/python_interface/inspection/test_draw_unified_compiler.py b/frontend/test/pytest/python_interface/inspection/test_draw_unified_compiler.py
index e7280dd6c0..6bd44c8896 100644
--- a/frontend/test/pytest/python_interface/inspection/test_draw_unified_compiler.py
+++ b/frontend/test/pytest/python_interface/inspection/test_draw_unified_compiler.py
@@ -12,16 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Unit test module for the draw function in the unified compiler inspection module."""
+# pylint: disable=unnecessary-lambda
-
-import pytest
-
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
-
-# pylint: disable=wrong-import-position,unnecessary-lambda
import jax
import pennylane as qml
+import pytest
from catalyst.python_interface.inspection import draw
from catalyst.python_interface.transforms import (
@@ -29,6 +24,8 @@
merge_rotations_pass,
)
+pytestmark = pytest.mark.xdsl
+
@pytest.mark.usefixtures("use_capture")
class Testdraw:
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 66b77d2a2a..ecf847a75d 100644
--- a/frontend/test/pytest/python_interface/inspection/test_mlir_graph.py
+++ b/frontend/test/pytest/python_interface/inspection/test_mlir_graph.py
@@ -14,20 +14,10 @@
"""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(["/usr/bin/which", "dot"], check=False).returncode != 0:
- pytest.skip(reason="Graphviz isn't installed.")
-
+from shutil import which
import pennylane as qml
+import pytest
from catalyst.python_interface.inspection import generate_mlir_graph
from catalyst.python_interface.transforms import (
@@ -35,6 +25,12 @@
merge_rotations_pass,
)
+pytestmark = pytest.mark.xdsl
+graphviz = pytest.importorskip("graphviz")
+
+if which("dot") is None:
+ pytest.skip(reason="Graphviz isn't installed.", allow_module_level=True)
+
@pytest.fixture(autouse=True)
def _chdir_tmp(monkeypatch, tmp_path: Path):
diff --git a/frontend/test/pytest/python_interface/inspection/test_mlir_specs.py b/frontend/test/pytest/python_interface/inspection/test_mlir_specs.py
index eb5cc5cbdc..84ae1fc7a6 100644
--- a/frontend/test/pytest/python_interface/inspection/test_mlir_specs.py
+++ b/frontend/test/pytest/python_interface/inspection/test_mlir_specs.py
@@ -13,20 +13,17 @@
# limitations under the License.
"""Unit test module for the mlir_specs function in the Python Compiler inspection module."""
-import pytest
-
-# pylint: disable=wrong-import-position
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
-
from functools import partial
import jax.numpy as jnp
import pennylane as qml
+import pytest
import catalyst
from catalyst.python_interface.inspection import ResourcesResult, mlir_specs
+pytestmark = pytest.mark.xdsl
+
def resources_equal(
actual: ResourcesResult, expected: ResourcesResult, return_only: bool = False
diff --git a/frontend/test/pytest/python_interface/test_unified_compiler.py b/frontend/test/pytest/python_interface/test_unified_compiler.py
index 12d19a71be..e98f218da6 100644
--- a/frontend/test/pytest/python_interface/test_unified_compiler.py
+++ b/frontend/test/pytest/python_interface/test_unified_compiler.py
@@ -11,19 +11,14 @@
# 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.
-
"""Unit tests for the unified compiler's entry point."""
+# pylint: disable=line-too-long
from dataclasses import dataclass
-# pylint: disable=wrong-import-position,line-too-long
-import pytest
-
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
-
import jax
import pennylane as qml
+import pytest
from jaxlib.mlir.ir import Module as jModule
from pennylane.capture import enabled as capture_enabled
from xdsl import passes
@@ -54,6 +49,8 @@
merge_rotations_pass,
)
+pytestmark = pytest.mark.xdsl
+
@dataclass(frozen=True)
class HelloWorldPass(passes.ModulePass):
diff --git a/frontend/test/pytest/python_interface/test_xdsl_universe.py b/frontend/test/pytest/python_interface/test_xdsl_universe.py
index f748164b1e..141e1e8c4f 100644
--- a/frontend/test/pytest/python_interface/test_xdsl_universe.py
+++ b/frontend/test/pytest/python_interface/test_xdsl_universe.py
@@ -14,17 +14,14 @@
"""Unit tests for the xDSL universe."""
import pytest
-
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
-
-# pylint: disable=wrong-import-position
from xdsl.passes import ModulePass
from xdsl.universe import Universe as xUniverse
from catalyst.python_interface import dialects, transforms
from catalyst.python_interface.xdsl_universe import XDSL_UNIVERSE, shared_dialects
+pytestmark = pytest.mark.xdsl
+
all_dialects = tuple(getattr(dialects, name) for name in dialects.__all__)
all_transforms = tuple(
transform
diff --git a/frontend/test/pytest/python_interface/test_xdsl_utils.py b/frontend/test/pytest/python_interface/test_xdsl_utils.py
index a88a8cfbcc..6de162ee4f 100644
--- a/frontend/test/pytest/python_interface/test_xdsl_utils.py
+++ b/frontend/test/pytest/python_interface/test_xdsl_utils.py
@@ -11,20 +11,17 @@
# 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.
-
"""Unit tests for xDSL utilities."""
+# pylint: disable=line-too-long
import pytest
-
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
-
-# pylint: disable=wrong-import-position,line-too-long
from xdsl.dialects import arith, builtin, tensor, test
from catalyst.python_interface.dialects.stablehlo import ConstantOp as hloConstantOp
from catalyst.python_interface.utils import get_constant_from_ssa
+pytestmark = pytest.mark.xdsl
+
class TestGetConstantFromSSA:
"""Unit tests for ``get_constant_from_ssa``."""
diff --git a/frontend/test/pytest/python_interface/transforms/mbqc/test_graph_state_utils.py b/frontend/test/pytest/python_interface/transforms/mbqc/test_graph_state_utils.py
index 6e4d18b971..626926c6e5 100644
--- a/frontend/test/pytest/python_interface/transforms/mbqc/test_graph_state_utils.py
+++ b/frontend/test/pytest/python_interface/transforms/mbqc/test_graph_state_utils.py
@@ -13,13 +13,7 @@
# limitations under the License.
"""Unit test module for the graph state utils"""
-# pylint: disable=wrong-import-position
-
import pytest
-
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
-
from pennylane.exceptions import CompileError
from catalyst.python_interface.transforms.mbqc.graph_state_utils import (
@@ -30,6 +24,8 @@
n_vertices_from_packed_adj_matrix,
)
+pytestmark = pytest.mark.xdsl
+
@pytest.fixture(scope="module", name="mbqc_single_qubit_graph")
def fixture_mbqc_single_qubit_graph():
diff --git a/frontend/test/pytest/python_interface/transforms/mbqc/test_xdsl_convert_to_mbqc_formalism.py b/frontend/test/pytest/python_interface/transforms/mbqc/test_xdsl_convert_to_mbqc_formalism.py
index 4cea7667c6..dff259b60e 100644
--- a/frontend/test/pytest/python_interface/transforms/mbqc/test_xdsl_convert_to_mbqc_formalism.py
+++ b/frontend/test/pytest/python_interface/transforms/mbqc/test_xdsl_convert_to_mbqc_formalism.py
@@ -12,13 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Unit test module for the convert to MBQC formalism transform"""
-import pytest
-
-# pylint: disable=wrong-import-position,line-too-long
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
+# pylint: disable=line-too-long
import pennylane as qml
+import pytest
from pennylane.ftqc import RotXZX
from catalyst.ftqc import mbqc_pipeline
@@ -29,6 +26,8 @@
measurements_from_samples_pass,
)
+pytestmark = pytest.mark.xdsl
+
class TestConvertToMBQCFormalismPass:
"""Unit tests for ConvertToMBQCFormalismPass."""
diff --git a/frontend/test/pytest/python_interface/transforms/mbqc/test_xdsl_decompose_graph_state.py b/frontend/test/pytest/python_interface/transforms/mbqc/test_xdsl_decompose_graph_state.py
index b2c851396e..dfb6af3900 100644
--- a/frontend/test/pytest/python_interface/transforms/mbqc/test_xdsl_decompose_graph_state.py
+++ b/frontend/test/pytest/python_interface/transforms/mbqc/test_xdsl_decompose_graph_state.py
@@ -11,7 +11,6 @@
# 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.
-
"""Unit and integration tests for the unified compiler `decompose-graph-state` transform.
FileCheck notation hint:
@@ -20,19 +19,17 @@
number indicates the wire index of that qubit, and the second letter increments by one after
each use.
"""
-
-# pylint: disable=wrong-import-position,line-too-long
+# pylint: disable=line-too-long
import pytest
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
-
from catalyst.python_interface.transforms import (
DecomposeGraphStatePass,
NullDecomposeGraphStatePass,
)
+pytestmark = pytest.mark.xdsl
+
class TestDecomposeGraphStatePass:
"""Unit tests for the decompose-graph-state pass."""
diff --git a/frontend/test/pytest/python_interface/transforms/mbqc/test_xdsl_outline_state_evolution.py b/frontend/test/pytest/python_interface/transforms/mbqc/test_xdsl_outline_state_evolution.py
index 8300f663e2..b82bac6ece 100644
--- a/frontend/test/pytest/python_interface/transforms/mbqc/test_xdsl_outline_state_evolution.py
+++ b/frontend/test/pytest/python_interface/transforms/mbqc/test_xdsl_outline_state_evolution.py
@@ -12,13 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Unit test module for the outline state evolution transform"""
-import pytest
-
-# pylint: disable=wrong-import-position
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
import pennylane as qml
+import pytest
from pennylane.ftqc import RotXZX
from catalyst.ftqc import mbqc_pipeline
@@ -31,6 +27,8 @@
outline_state_evolution_pass,
)
+pytestmark = pytest.mark.xdsl
+
@qml.while_loop(lambda i: i < 1000)
def _while_for(i):
diff --git a/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_cancel_inverses.py b/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_cancel_inverses.py
index 8281a775e6..65171f0237 100644
--- a/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_cancel_inverses.py
+++ b/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_cancel_inverses.py
@@ -13,19 +13,16 @@
# limitations under the License.
"""Unit test module for the iterative cancel inverses transform"""
-import pytest
-
-# pylint: disable=wrong-import-position
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
-
import pennylane as qml
+import pytest
from catalyst.python_interface.transforms import (
IterativeCancelInversesPass,
iterative_cancel_inverses_pass,
)
+pytestmark = pytest.mark.xdsl
+
class TestIterativeCancelInversesPass:
"""Unit tests for IterativeCancelInversesPass."""
diff --git a/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_combine_global_phases.py b/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_combine_global_phases.py
index b393cbf279..acb7fcc15d 100644
--- a/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_combine_global_phases.py
+++ b/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_combine_global_phases.py
@@ -12,19 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Unit test module for the combine global phases transform"""
-import pytest
-
-# pylint: disable=wrong-import-position
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
import pennylane as qml
+import pytest
from catalyst.python_interface.transforms import (
CombineGlobalPhasesPass,
combine_global_phases_pass,
)
+pytestmark = pytest.mark.xdsl
+
class TestCombineGlobalPhasesPass:
"""Unit tests for CombineGlobalPhasesPass."""
diff --git a/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_diagonalize_measurements.py b/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_diagonalize_measurements.py
index 16f9b6ca18..48bf7e3ee2 100644
--- a/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_diagonalize_measurements.py
+++ b/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_diagonalize_measurements.py
@@ -13,22 +13,17 @@
# limitations under the License.
"""Unit test module for the xDSL implementation of the diagonalize_final_measurements pass"""
-
-# pylint: disable=wrong-import-position
-
import numpy as np
-import pytest
-
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
-
import pennylane as qml
+import pytest
from catalyst.python_interface.transforms import (
DiagonalizeFinalMeasurementsPass,
diagonalize_final_measurements_pass,
)
+pytestmark = pytest.mark.xdsl
+
class TestDiagonalizeFinalMeasurementsPass:
"""Unit tests for the diagonalize-final-measurements pass."""
diff --git a/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_measurements_from_samples.py b/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_measurements_from_samples.py
index bce8b4ad02..3e4ef183d9 100644
--- a/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_measurements_from_samples.py
+++ b/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_measurements_from_samples.py
@@ -11,26 +11,22 @@
# 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.
-
"""Unit and integration tests for the unified compiler `measurements_from_samples` transform."""
-
-# pylint: disable=wrong-import-position,line-too-long
+# pylint: disable=line-too-long
from functools import partial
import numpy as np
-import pytest
-
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
-
import pennylane as qml
+import pytest
from catalyst.python_interface.transforms import (
MeasurementsFromSamplesPass,
measurements_from_samples_pass,
)
+pytestmark = pytest.mark.xdsl
+
class TestMeasurementsFromSamplesPass:
"""Unit tests for the measurements-from-samples pass."""
diff --git a/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_merge_rotations.py b/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_merge_rotations.py
index 7445ad9c0f..14ff09ffe8 100644
--- a/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_merge_rotations.py
+++ b/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_merge_rotations.py
@@ -12,16 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Unit test module for the merge rotations transform"""
-import pytest
-
-# pylint: disable=wrong-import-position,line-too-long
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
+# pylint: disable=line-too-long
import pennylane as qml
+import pytest
from catalyst.python_interface.transforms import MergeRotationsPass, merge_rotations_pass
+pytestmark = pytest.mark.xdsl
+
class TestMergeRotationsPass:
"""Unit tests for MergeRotationsPass."""
diff --git a/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_split_non_commuting.py b/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_split_non_commuting.py
index 59b365f136..e9f47f19c2 100644
--- a/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_split_non_commuting.py
+++ b/frontend/test/pytest/python_interface/transforms/quantum/test_xdsl_split_non_commuting.py
@@ -12,19 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Unit test module for the split non-commuting transform"""
-import pytest
-
-# pylint: disable=wrong-import-position
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
import pennylane as qml
+import pytest
from catalyst.python_interface.transforms import (
SplitNonCommutingPass,
split_non_commuting_pass,
)
+pytestmark = pytest.mark.xdsl
+
class TestSplitNonCommutingPass:
"""Unit tests for SplitNonCommutingPass."""
diff --git a/frontend/test/pytest/python_interface/xdsl_extras/test_constraints.py b/frontend/test/pytest/python_interface/xdsl_extras/test_constraints.py
index 7dc7cd6ea6..b10e815f72 100644
--- a/frontend/test/pytest/python_interface/xdsl_extras/test_constraints.py
+++ b/frontend/test/pytest/python_interface/xdsl_extras/test_constraints.py
@@ -11,15 +11,9 @@
# 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 the constraints defined within the xdsl_extras module."""
import pytest
-
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
-
-# pylint: disable=wrong-import-position
from xdsl.context import Context
from xdsl.dialects import builtin, test
from xdsl.dialects.builtin import MemRefType, TensorType, TupleType, i1, i32
@@ -42,6 +36,8 @@
TensorConstraint,
)
+pytestmark = pytest.mark.xdsl
+
@pytest.fixture(scope="module", name="my_dialect")
def my_dialect_fixture():
diff --git a/frontend/test/pytest/python_interface/xdsl_extras/test_traits.py b/frontend/test/pytest/python_interface/xdsl_extras/test_traits.py
index bcc579d972..a27aec6a8d 100644
--- a/frontend/test/pytest/python_interface/xdsl_extras/test_traits.py
+++ b/frontend/test/pytest/python_interface/xdsl_extras/test_traits.py
@@ -17,15 +17,8 @@
from typing import TypeAlias
import pytest
-
-# pylint: disable=wrong-import-position
-pytestmark = pytest.mark.xdsl
-xdsl = pytest.importorskip("xdsl")
-
from xdsl.dialects.builtin import AnyAttr, TensorType, f32, i32, i64
from xdsl.ir import Attribute
-
-# xdsl imports
from xdsl.irdl import (
IRDLOperation,
attr_def,
@@ -47,6 +40,7 @@
SameOperandsElementType,
)
+pytestmark = pytest.mark.xdsl
AnyTensorType: TypeAlias = TensorType[Attribute]
diff --git a/frontend/test/pytest/test_xdsl_passes.py b/frontend/test/pytest/test_xdsl_passes.py
index c7d66959e9..50f9ad5576 100644
--- a/frontend/test/pytest/test_xdsl_passes.py
+++ b/frontend/test/pytest/test_xdsl_passes.py
@@ -11,10 +11,10 @@
# 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.
-
"""
Unit tests for xDSL pass-related functionality in the Compiler class.
"""
+# pylint: disable=protected-access
import os
import pathlib
@@ -29,8 +29,6 @@
from catalyst.pipelines import KeepIntermediateLevel
from catalyst.utils.filesystem import Directory
-# pylint: disable=protected-access
-
@pytest.mark.xdsl
class TestHasXDSLPassesInTransformModules:
diff --git a/setup.py b/setup.py
index 13890344e2..68d1043234 100644
--- a/setup.py
+++ b/setup.py
@@ -130,6 +130,8 @@ def parse_dep_versions():
"numpy!=2.0.0",
"scipy-openblas32>=0.3.26", # symbol and library name
"diastatic-malt>=2.15.2",
+ "xdsl==0.55.4",
+ "xdsl-jax==0.1.1",
]
entry_points = {