Skip to main content

An MLIR plugin for connecting MQT Core with Xanadu's Catalyst

Project description

PyPI OS License: MIT DOI CI CD Documentation codecov

[!NOTE] This project is intended primarily as a demonstration and learning resource. It is provided for educational purposes and may not be suitable for production use.

MQT Logo

MLIR-Based MQT Core / Catalyst Plugin

This package provides a Catalyst plugin based on MLIR. It allows you to use MQT Core's MLIR dialects and transformations within Xanadu's Catalyst framework.

If you have any questions, feel free to create a discussion or an issue on GitHub.

Contributors and Supporters

The Munich Quantum Toolkit (MQT) is developed by the Chair for Design Automation at the Technical University of Munich and supported by the Munich Quantum Software Company (MQSC). Among others, it is part of the Munich Quantum Software Stack (MQSS) ecosystem, which is being developed as part of the Munich Quantum Valley (MQV) initiative.

MQT Partner Logos

Thank you to all the contributors who have helped make the MLIR-based MQT Core / Catalyst plugin a reality!

Contributors to munich-quantum-toolkit/core-plugins-catalyst

The MQT will remain free, open-source, and permissively licensed—now and in the future. We are firmly committed to keeping it open and actively maintained for the quantum computing community.

To support this endeavor, please consider:

Sponsor the MQT

Getting Started

mqt-core-plugins-catalyst is available on PyPI.

Because pennylane-catalyst pins to a specific LLVM/MLIR revision, you must build that LLVM/MLIR locally and point CMake at it.

1) Build the exact LLVM/MLIR revision (locally)

If you want to use a fast pre-built MLIR installation locally (recommended), we provide installation scripts. The scripts require a specific LLVM hash (i.e., 113f01aa82d055410f22a9d03b3468fa68600589) and the desired installation directory to be passed. The scripts automatically download and use a platform-specific zstd binary for decompression, so only tar needs to be installed on the host system.

curl -LsSf https://github.com/munich-quantum-software/setup-mlir/releases/latest/download/setup-mlir.sh | bash -s -- -v 113f01aa82d055410f22a9d03b3468fa68600589 -p /path/to/installation

# Export this for your shell/session
export MLIR_DIR="/path/to/installation/lib/cmake/mlir"

Alternatively (but much more time-consuming); you can build MLIR from source as follows:

# Pick a workspace (optional)
mkdir -p ~/dev && cd ~/dev

# Clone the exact LLVM revision Catalyst expects
git clone https://github.com/llvm/llvm-project.git
cd llvm-project
git checkout 113f01aa82d055410f22a9d03b3468fa68600589

# Configure & build MLIR (Release is recommended)
cmake -S llvm -B build_llvm -G Ninja \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_CXX_VISIBILITY_PRESET=default \
  -DLLVM_ENABLE_PROJECTS=mlir \
  -DLLVM_BUILD_EXAMPLES=OFF \
  -DLLVM_BUILD_TESTS=OFF \
  -DLLVM_INCLUDE_TESTS=OFF \
  -DLLVM_INCLUDE_EXAMPLES=OFF \
  -DLLVM_ENABLE_ASSERTIONS=ON \
  -DLLVM_ENABLE_ZLIB=FORCE_ON \
  -DLLVM_ENABLE_ZSTD=OFF \
  -DLLVM_ENABLE_RTTI=ON \
  -DLLVM_ENABLE_EH=ON

cmake --build build_llvm --config Release

# Export this for your shell/session
export MLIR_DIR="$PWD/build_llvm/lib/cmake/mlir"

2) Install the plugin

Install the MQT Core Catalyst Plugin using uv:

uv pip install mqt-core-plugins-catalyst

Alternatively, you can build and install the plugin from source:

# Clone the repository
git clone https://github.com/munich-quantum-toolkit/core-plugins-catalyst.git
cd core-plugins-catalyst

# Build and install the plugin
# This automatically creates a venv, downloads Python if necessary, and installs the project
MLIR_DIR="$MLIR_DIR" uv sync

# Or, if the environment variables are already set from step 1:
uv sync

3) Use the MQT plugin and explore intermediate MLIR representations

The MQT plugin provides device configuration utilities to prevent Catalyst from decomposing gates into unitary matrices, enabling lossless roundtrip conversions.

You can inspect the intermediate MLIR representations during the roundtrip between CatalystQuantum and MQTOpt dialects.

Example: Create a test script

Create a file test_example.py:

from __future__ import annotations
from pathlib import Path
from typing import Any

import pennylane as qml
from catalyst.passes import apply_pass
from mqt.core.plugins.catalyst import get_device

# Use get_device() to configure the device for MQT plugin compatibility
device = get_device("lightning.qubit", wires=2)


# Define your quantum circuit
@apply_pass("mqt.mqtopt-to-catalystquantum")
@apply_pass("mqt.catalystquantum-to-mqtopt")
@qml.qnode(device)
def circuit() -> None:
    qml.Hadamard(wires=0)
    qml.CNOT(wires=[0, 1])


# Custom pipeline to capture intermediate MLIR
custom_pipeline = [
    ("Init", ["builtin.module(canonicalize)"]),  # Initial Catalyst MLIR
    ("ToMQTOpt", ["builtin.module(catalystquantum-to-mqtopt)"]),
    ("ToCatalystQuantum", ["builtin.module(mqtopt-to-catalystquantum)"]),
]


# JIT compilation with intermediate MLIR files saved
@qml.qjit(target="mlir", autograph=True, keep_intermediate=2, pipelines=custom_pipeline)
def module() -> Any:
    return circuit()


# Trigger compilation and optimized MLIR generation
module.mlir_opt

# Catalyst writes intermediate MLIR files to the current working directory
mlir_dir = Path.cwd()
mlir_init = mlir_dir / "1_AfterInit.mlir"
mlir_to_mqtopt = mlir_dir / "2_AfterToMQTOpt.mlir"
mlir_to_catalyst = mlir_dir / "3_AfterToCatalystQuantum.mlir"

# Read MLIR files
print("=== Initial Catalyst MLIR ===")
if mlir_init.exists():
    print(mlir_init.read_text())

print("\n=== After CatalystQuantum → MQTOpt conversion ===")
if mlir_to_mqtopt.exists():
    print(mlir_to_mqtopt.read_text())

print("\n=== After MQTOpt → CatalystQuantum roundtrip ===")
if mlir_to_catalyst.exists():
    print(mlir_to_catalyst.read_text())

Alternative: You can also configure an existing device:

from mqt.core.plugins.catalyst import configure_device_for_mqt

device = qml.device("lightning.qubit", wires=2)
device = configure_device_for_mqt(device)

Run the example

uv run test_example.py

You should see three MLIR representations showing the transformation through the MQT dialects and back.

Verify the installation

You can run the test suite to verify everything is working:

# Run pytest using uv
uv run pytest test -v
# Alternatively run the tests using nox (handles all dependencies automatically)
uvx nox -s tests

System Requirements

Building the MQT Core Catalyst Plugin requires a C++ compiler with support for C++20 and CMake 3.24 or newer. Building (and running) is continuously tested under Linux and macOS using the latest available system versions for GitHub Actions. The MQT Core Catalyst Plugin is compatible with Python version 3.11 and newer.

The MQT Core Catalyst Plugin relies on some external dependencies:

  • llvm/llvm-project: A toolkit for the construction of highly optimized compilers, optimizers, and run-time environments (specific revision: 113f01aa82d055410f22a9d03b3468fa68600589).
  • PennyLaneAI/catalyst: A package that enables just-in-time (JIT) compilation of hybrid quantum-classical programs implemented with PennyLane (version == 0.14.0).
  • MQT Core: Provides the MQTOpt MLIR dialect and supporting infrastructure.

Note, both LLVM/MLIR and Catalyst are currently restricted to specific versions. You must build LLVM/MLIR locally from the exact revision specified above and configure CMake to use it (see installation instructions).

Cite This

If you want to cite MQT Core Catalyst Plugin, please use the following BibTeX entry:

@inproceedings{Hopf_Integrating_Quantum_Software_2026,
author = {Hopf, Patrick and Ochoa Lopez, Erick and Stade, Yannick and Rovara, Damian and Quetschlich, Nils and Florea, Ioan Albert and Izaac, Josh and Wille, Robert and Burgholzer, Lukas},
booktitle = {SCA/HPCAsia 2026: Supercomputing Asia and International Conference on High Performance Computing in Asia Pacific Region},
doi = {10.1145/3773656.3773658},
month = jan,
publisher = {Association for Computing Machinery},
series = {SCA/HPCAsia 2026},
title = {{Integrating Quantum Software Tools with(in) MLIR}},
year = {2026}
}

Acknowledgements

The Munich Quantum Toolkit has been supported by the European Research Council (ERC) under the European Union's Horizon 2020 research and innovation program (grant agreement No. 101001318), the Bavarian State Ministry for Science and Arts through the Distinguished Professorship Program, as well as the Munich Quantum Valley, which is supported by the Bavarian state government with funds from the Hightech Agenda Bayern Plus.

MQT Funding Footer

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mqt_core_plugins_catalyst-1.0.0.tar.gz (135.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mqt_core_plugins_catalyst-1.0.0-cp311-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

mqt_core_plugins_catalyst-1.0.0-cp311-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (2.9 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

mqt_core_plugins_catalyst-1.0.0-cp311-abi3-macosx_13_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.11+macOS 13.0+ ARM64

File details

Details for the file mqt_core_plugins_catalyst-1.0.0.tar.gz.

File metadata

File hashes

Hashes for mqt_core_plugins_catalyst-1.0.0.tar.gz
Algorithm Hash digest
SHA256 29c3b57678c6479f7ac8cf22ebc7e28d0430c3e76ebd20c3d99c54e0a38f583b
MD5 cd3b2f2eb442374b7d5334d736041273
BLAKE2b-256 d2925cb9613727ebc78ce6965020aaa31c07120701d45f7706901a5e5e51ac64

See more details on using hashes here.

Provenance

The following attestation bundles were made for mqt_core_plugins_catalyst-1.0.0.tar.gz:

Publisher: cd.yml on munich-quantum-toolkit/core-plugins-catalyst

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mqt_core_plugins_catalyst-1.0.0-cp311-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mqt_core_plugins_catalyst-1.0.0-cp311-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b92a56dea1111567419f80f3f5d55c03cc820980fdc3f054ae24a8f53f7c8a1f
MD5 b45929ea7d9d5a3974aa7a3792bbdbb2
BLAKE2b-256 c4503ac51edde14b254ab5d49fc22720ccf8081b9cdf6f3ae50e9f02f28ea737

See more details on using hashes here.

Provenance

The following attestation bundles were made for mqt_core_plugins_catalyst-1.0.0-cp311-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: cd.yml on munich-quantum-toolkit/core-plugins-catalyst

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mqt_core_plugins_catalyst-1.0.0-cp311-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mqt_core_plugins_catalyst-1.0.0-cp311-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7a5ced520d9da1f4c4009587d42a7f1b0cc0078851fffa94f7210cd51e27908d
MD5 1c031af546835c0e8c7ba8f8281cdde8
BLAKE2b-256 7f1fb7137ab55989f27ee27c5e5a62983dedc0385d58ef65388dda896413f1a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for mqt_core_plugins_catalyst-1.0.0-cp311-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl:

Publisher: cd.yml on munich-quantum-toolkit/core-plugins-catalyst

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mqt_core_plugins_catalyst-1.0.0-cp311-abi3-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for mqt_core_plugins_catalyst-1.0.0-cp311-abi3-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 19c9697bf2109fa7fe5d52670102ede99e377a200c08e7e285c6385e8d4582a6
MD5 57a52382de063fb2584f1ea6eecf9681
BLAKE2b-256 4b63effad28aba06e8b07f22bc52c360e13f83272bb0bcca75d725e8422f8630

See more details on using hashes here.

Provenance

The following attestation bundles were made for mqt_core_plugins_catalyst-1.0.0-cp311-abi3-macosx_13_0_arm64.whl:

Publisher: cd.yml on munich-quantum-toolkit/core-plugins-catalyst

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page