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
20 changes: 5 additions & 15 deletions .github/workflows/build-wheel-linux-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -493,26 +496,13 @@ 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
# Run only on Thursday at the given time
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"


18 changes: 5 additions & 13 deletions .github/workflows/build-wheel-linux-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -512,24 +515,13 @@ 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
# Run only on Thursday at the given time
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"
18 changes: 5 additions & 13 deletions .github/workflows/build-wheel-macos-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -493,24 +496,13 @@ 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
# Run only on Thursday at the given time
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"
17 changes: 5 additions & 12 deletions .github/workflows/check-catalyst.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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")
Expand Down
35 changes: 1 addition & 34 deletions .github/workflows/check-pl-compat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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"
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"
Expand Down
8 changes: 5 additions & 3 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,12 @@

<h3>Bug fixes 🐛</h3>

<<<<<<< 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)
Expand Down Expand Up @@ -387,6 +385,9 @@

<h3>Internal changes ⚙️</h3>

* 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)

Expand Down Expand Up @@ -532,6 +533,7 @@ Joseph Lee,
Mehrdad Malekmohammadi,
River McCubbin,
Lee J. O'Riordan,
Mudit Pandey,
Andrija Paurevic,
Roberto Turrado,
Paul Haochen Wang,
Expand Down
72 changes: 30 additions & 42 deletions frontend/catalyst/python_interface/xdsl_universe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,19 @@
# 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
from xdsl.utils.exceptions import VerifyException

from catalyst.python_interface.dialects import Quantum, mbqc

pytestmark = pytest.mark.xdsl

all_ops = list(mbqc.MBQC.operations)
all_attrs = list(mbqc.MBQC.attributes)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading