Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
306 commits
Select commit Hold shift + click to select a range
09ea22c
⬆️ Update catalyst dep
ystade May 22, 2025
74231a1
♻️ Clean-up CMakeLists
ystade May 22, 2025
2c15f70
Merge branch 'main' into mlir-plugin
burgholzer May 22, 2025
76cb1dc
🎨 remove stray changes
burgholzer May 22, 2025
cbc5cba
🔥 remove duplicate file
burgholzer May 22, 2025
8a8f01d
🔥 remove further stray change
burgholzer May 22, 2025
9f17863
🎨 add entry point for mqt.passes in pyproject.toml
flowerthrower May 23, 2025
76535cb
add python guard
flowerthrower May 25, 2025
e69b0e1
Apply suggestions from code review
flowerthrower May 25, 2025
3626013
🎨 pre-commit fixes
pre-commit-ci[bot] May 25, 2025
5861960
Merge branch 'mlir-plugin' of https://github.com/cda-tum/mqt-core int…
flowerthrower May 25, 2025
01b139c
🎨 update CMakeLists.txt to improve RPATH handling and installation di…
flowerthrower May 26, 2025
816ac83
🎨 update CI configuration to enable BUILD_MQT_CORE_CATALYST_PLUGIN fo…
flowerthrower May 26, 2025
217305d
🎨 update pyproject.toml to set version and clean up dependencies
flowerthrower May 26, 2025
160c62e
🎨 pre-commit fixes
pre-commit-ci[bot] May 27, 2025
2b01fde
add environment markers
flowerthrower May 27, 2025
9d5f2eb
add ci for macos plugin test
flowerthrower Jun 2, 2025
d9d3028
fix ci
flowerthrower Jun 2, 2025
91304bf
fix ci
flowerthrower Jun 2, 2025
e23edb5
fix ci
flowerthrower Jun 2, 2025
c5242e3
fix ci
flowerthrower Jun 2, 2025
8db1931
fix ci
flowerthrower Jun 2, 2025
4cc18b0
fix ci
flowerthrower Jun 2, 2025
8c69fbd
fix ci
flowerthrower Jun 2, 2025
2a04dd5
dynamic path finding
flowerthrower Jun 2, 2025
65f34e7
calm down ruff
flowerthrower Jun 2, 2025
c2e0cda
remove version file
flowerthrower Jun 2, 2025
203049f
🚚 rename test file
flowerthrower Jun 4, 2025
270fd6d
🚧 use rpath
flowerthrower Jun 10, 2025
74a7ce9
🚧 use matchAndRewrite
flowerthrower Jun 11, 2025
cec21b4
add path in ci to find dylib
flowerthrower Jun 11, 2025
ffedad9
Merge commit '08e61d14291da0e7e39af3f5e6c46a6641635eb7' into mlir-plugin
flowerthrower Jun 11, 2025
95b7951
debug ci
flowerthrower Jun 11, 2025
8167e6f
🎨 pre-commit fixes
pre-commit-ci[bot] Jun 11, 2025
35c01bf
debug ci
flowerthrower Jun 11, 2025
c230d99
✅ add test for plugin execution
flowerthrower Jun 13, 2025
705ac5d
🎨 pre-commit fixes
pre-commit-ci[bot] Jun 13, 2025
116bb7f
➕ install pytest in ci
flowerthrower Jun 13, 2025
d5471b9
💚 fix urllib3 to stable version
flowerthrower Jun 13, 2025
4bd1af9
⚡️ improve ci
flowerthrower Jun 13, 2025
8c42d30
💚 improve ci
flowerthrower Jun 13, 2025
2680a1e
🐛 fix dialect roundtrip tests
flowerthrower Jun 20, 2025
ec8bedd
enable full round-trip-test
flowerthrower Jun 23, 2025
43f2bc2
add platform markers
flowerthrower Jun 23, 2025
294272f
Merge branch 'main' into mlir-plugin
burgholzer Jun 30, 2025
9ab3ef4
⏪ revert a couple of unrelated changes
burgholzer Jun 30, 2025
c43b7cc
♻️ restructure plugin package
burgholzer Jun 30, 2025
c0ee59f
🚧 work in progress that does not work yet
burgholzer Jun 30, 2025
388acf3
🩹 fix sdist for mqt-core
burgholzer Jul 9, 2025
54d4dec
➕ update dependencies
burgholzer Jul 9, 2025
ea57507
🚚 rename to `mqt-core-catalyst-plugin`
burgholzer Jul 9, 2025
7015cf3
🔧 do not explicitly register plugins
burgholzer Jul 9, 2025
745b26a
🔧 add target specific CMake settings
burgholzer Jul 9, 2025
7dda34a
♻️ turn into standalone plugin package
burgholzer Jul 9, 2025
624b5fa
🩹 do not register passes in dialect plugin
burgholzer Jul 9, 2025
4b69fa2
🎨 miscellaneous fixes in pyproject.toml configuration
burgholzer Jul 9, 2025
cbc97e9
🚨 run pre-commit
burgholzer Jul 9, 2025
7a97880
Merge remote-tracking branch 'refs/remotes/munich-quantum-toolkit/mai…
burgholzer Jul 9, 2025
fa3e096
⬆️ update mqt-core plugin dependency
burgholzer Jul 9, 2025
9900215
🔧 do not run cpp-linter on catalyst plugin for now.
burgholzer Jul 9, 2025
77266d3
👷 set up dedicated plugin CI
burgholzer Jul 9, 2025
4d76e3b
🩹 activate virtual environment in CI
burgholzer Jul 9, 2025
3d082df
🩹 enable PIC for MQT Core in plugin
burgholzer Jul 9, 2025
cd575bf
🔧 decouple plugin from main CMake build to avoid endless loop
burgholzer Jul 9, 2025
e3fe319
✏️ disambiguate workflow names
burgholzer Jul 9, 2025
ad33833
🔧 tweak workflow triggers
burgholzer Jul 9, 2025
8124ce3
Merge branch 'main' into mlir-plugin
flowerthrower Jul 10, 2025
70afd91
⏪ revert non plugin specific changes
flowerthrower Jul 10, 2025
173e971
⏪ revert non-plugin specific changes
flowerthrower Jul 10, 2025
3feaa26
⏪ revert non-plugin specific changes
flowerthrower Jul 10, 2025
aaa2188
🩹 properly run pytest
burgholzer Jul 10, 2025
d7d1783
🔧 only build catalyst MLIR component
burgholzer Jul 10, 2025
f1b333f
🩹 use active environment
burgholzer Jul 10, 2025
4b0d47e
⚗️ try building with clang-19 on Ubuntu
burgholzer Jul 10, 2025
e385ea5
Merge branch 'main' into mlir-plugin
burgholzer Jul 11, 2025
a314f38
⚗️ try Catalyst MLIR commit
burgholzer Jul 11, 2025
90dcb7b
🩹 set build type
burgholzer Jul 11, 2025
e80f154
⚗️ tweak LLVM installation
burgholzer Jul 12, 2025
29b121d
🩹 fix the mqt-core version
burgholzer Jul 12, 2025
8f804a2
🙈 simplify gitignore
burgholzer Jul 12, 2025
962802b
⏪ revert unnecessary config
burgholzer Jul 12, 2025
e9a3b56
⏪ don't explicitly install clang version that will not be used
burgholzer Jul 12, 2025
098c174
Merge branch 'main' into mlir-plugin
burgholzer Jul 12, 2025
43333de
⚗️ disable mold as a linker for catalyst build
burgholzer Jul 12, 2025
9179a40
♻️ one more `match` and `rewrite` replacement
burgholzer Jul 12, 2025
d9957f0
🔧 use mqt-core from the source tree
burgholzer Jul 14, 2025
989adfd
⬆️ update catalyst dependency
burgholzer Jul 14, 2025
14e5732
♻️ streamline Python plugin code
burgholzer Jul 14, 2025
106fa7d
🚨 address some clang-tidy warnings
burgholzer Jul 14, 2025
68142d6
🔧 tweak Catalyst installation on Linux
burgholzer Jul 14, 2025
9255e49
🔊 print more test output
burgholzer Jul 14, 2025
f7dce4c
⚗️ try with LLVM 21
burgholzer Jul 14, 2025
04a43f3
📦 only build the targets necessary for the plugin
burgholzer Jul 14, 2025
063b184
⚗️ experiment with the RPATH settings
burgholzer Jul 14, 2025
e7aed92
🔧 exclude macos and llvm@21
burgholzer Jul 14, 2025
610a8d9
⚗️ try compiling with gcc on Linux
burgholzer Jul 15, 2025
039cffc
🩹 disable LLD for catalyst build
burgholzer Jul 15, 2025
337ed02
🔧 only build the check-mlir target
burgholzer Jul 15, 2025
78e6291
⚗️ try an explicit repair wheel step
burgholzer Jul 15, 2025
7d874be
🔧 modify LLVM install configuration to maybe fix the Linux build
burgholzer Jul 15, 2025
e178ed8
🩹 fix CI configuration
burgholzer Jul 15, 2025
bec9939
⬆️ update to release version of Catalyst
burgholzer Jul 15, 2025
e045f05
🩹 also install the catalyst dependency group
burgholzer Jul 15, 2025
dd8cfb3
➕ add catalyst as a runtime dependency
burgholzer Jul 15, 2025
1afa51a
⏪ remove the wheel repair step again for now
burgholzer Jul 15, 2025
3b2c9dd
🔧 run without mold as a linker
burgholzer Jul 16, 2025
04f134d
🔊 print shared library information logs
burgholzer Jul 16, 2025
7668673
:refactor: added missing conversions from the separate PR #880
BertiFlorea Jul 16, 2025
60f7c22
:memo: update pass description with the remaining op conversions
BertiFlorea Jul 16, 2025
e2fde36
:bug: fix missing patterns of existing conversions
BertiFlorea Jul 16, 2025
3de0827
:recycle: add missing PeresOp conversion
BertiFlorea Jul 17, 2025
8686445
:memo: update MQTOptToCatalystQuantum pass description
BertiFlorea Jul 17, 2025
8fa8c0d
:green_heart: update include paths to prevent c lint error
BertiFlorea Jul 17, 2025
dfa1d9d
🎨 pre-commit fixes
pre-commit-ci[bot] Jul 17, 2025
f80355e
:rewind: :green_heart: revert include paths and update cmake file in …
BertiFlorea Jul 17, 2025
a682d93
:construction: try to explicitly point clang to see the includes
BertiFlorea Jul 17, 2025
d641451
🎨 pre-commit fixes
pre-commit-ci[bot] Jul 17, 2025
81b0e36
:recycle: revert catalyst/lib/CMakeLists.txt and catalyst/CMakeLists.txt
BertiFlorea Jul 17, 2025
ea46083
🐛 add arith includes and fix arith div logic
flowerthrower Jul 22, 2025
810ad4b
🐛 fix adjoint parameter handling in quantum gate conversions
flowerthrower Jul 22, 2025
48802d4
Merge remote-tracking branch 'munich-quantum-toolkit/main' into mlir-…
burgholzer Jul 30, 2025
5532a39
🔧 streamline CI configuration
burgholzer Jul 30, 2025
6358288
📦 make uv resolution more precise and update lockfile
burgholzer Jul 30, 2025
5953de0
🔧 match Catalyst macOS deployment target
burgholzer Jul 30, 2025
a83ecf6
⬆️ update C++ standard to C++20
burgholzer Jul 30, 2025
163d7d1
⬆️ update mqt-core version
burgholzer Jul 30, 2025
0b0b6d8
🔧 move prerelease config to comments
burgholzer Jul 30, 2025
fbfcf8c
🔥 remove unused CMake file
burgholzer Jul 30, 2025
41ad6a7
🔥 remove unused variable
burgholzer Jul 30, 2025
1667c4a
🚸 enable optional coverage collection
burgholzer Jul 30, 2025
5b1f072
🔧 optimize CMake configuration with header file sets
burgholzer Jul 30, 2025
32c4fdf
🎨 add format and linting config to plugin
burgholzer Jul 30, 2025
48ea811
♻️ first round of plugin code cleanup
burgholzer Jul 30, 2025
6a6c59f
🔥 remove LLVM 21 from the testing matrix
burgholzer Jul 30, 2025
ee084fd
👷 add Linux ARM to test matrix for plugin
burgholzer Jul 30, 2025
f9b32a2
♻️ simplify conversion patterns
burgholzer Jul 30, 2025
db60591
🐛 fix control and target ordering in MQTOpt to Catalyst translation
burgholzer Jul 30, 2025
6e829f2
🐛 fix pattern for `XXminusYY`
burgholzer Jul 30, 2025
54859f9
🔥 Comment out CI runs not using exact LLVM commit
burgholzer Jul 30, 2025
d2c7fec
✨ enable support for `CSWAP` from catalyst
burgholzer Jul 30, 2025
ee20add
✨ enable support for `S` and `T` from catalyst
burgholzer Jul 30, 2025
aa6bce6
✨ enable support for `ISWAP` from catalyst
burgholzer Jul 30, 2025
9daf5d3
✨ enable support for `Identity` from catalyst
burgholzer Jul 30, 2025
87ab895
✨ enable support for `SX` from catalyst
burgholzer Jul 30, 2025
ed9a3f3
✨ enable support for `ECR` from catalyst
burgholzer Jul 30, 2025
2374378
🎨 directly use string comparisons
burgholzer Jul 30, 2025
fec7946
🎨 reduce boilerplate code
burgholzer Jul 30, 2025
d80d1e4
⏪ restore boilerplate code for unresolved materialization
burgholzer Jul 30, 2025
12c47bf
♻️ streamline conversion to catalyst
burgholzer Jul 30, 2025
9a52a78
♻️ assume `SX` and `ECR` to be legal and supported
burgholzer Jul 30, 2025
857b368
✨ add support for CSWAP in conversion to catalyst
burgholzer Jul 30, 2025
4a7bf6e
♻️ simplify `V` and `Vdg` gate sequence
burgholzer Jul 30, 2025
778ae8f
🐛 fix DCX implementation
burgholzer Jul 30, 2025
b053818
🚨 fix missing header
burgholzer Jul 31, 2025
dbb2bb0
Merge branch 'main' into mlir-plugin
flowerthrower Aug 13, 2025
45ee5e1
add getting started example
flowerthrower Aug 13, 2025
11c308e
🎨 pre-commit fixes
pre-commit-ci[bot] Aug 13, 2025
f4580a3
💚 add ci for plugin lit tests
flowerthrower Aug 15, 2025
f84706e
🐛 fix tests
flowerthrower Aug 15, 2025
df10af6
🐛 fix control order in conversion test
flowerthrower Aug 15, 2025
f8215ca
🎨 pre-commit fixes
pre-commit-ci[bot] Aug 15, 2025
541c7ca
🚧 debug failing conversion
flowerthrower Aug 15, 2025
52023c1
🐛 fix test
flowerthrower Aug 18, 2025
5e46c40
🐛 fix operation names
flowerthrower Aug 18, 2025
5d3df91
✅ add conversion and test for xxplusyy gate
flowerthrower Aug 18, 2025
be0ba8e
🐛 fix lit setup
flowerthrower Aug 18, 2025
3f11c3c
🎨 remove debugging lines
flowerthrower Aug 19, 2025
1250676
✅ fix and test rzx gate conversion
flowerthrower Aug 19, 2025
b10f91b
🐛 fix include directories for Catalyst installation from PyPI
flowerthrower Aug 20, 2025
fca7d10
🎨 pre-commit fixes
pre-commit-ci[bot] Aug 20, 2025
a876914
🎨 clean up CI configuration by removing commented-out jobs and updati…
flowerthrower Aug 20, 2025
108bb60
🐛 update Python executable references to Python3 in CMake files
flowerthrower Aug 20, 2025
0fbdcfc
🐛 fix constant values in MQTOptToCatalystQuantum conversion for corre…
flowerthrower Aug 20, 2025
d48decf
📝 update README.md with installation instructions and system requirem…
flowerthrower Aug 20, 2025
8142c08
🎨 pre-commit fixes
pre-commit-ci[bot] Aug 20, 2025
906ca09
Merge commit '8bb58888948246ab3486c678a595ca670c2eddc7' into mlir-plugin
flowerthrower Aug 21, 2025
e7d8109
🚧 fix conversion patterns
flowerthrower Aug 21, 2025
ac126cd
🎨 imporve tests
flowerthrower Aug 21, 2025
b31f55e
✨ Update clang-tidy configurations and add clang-tidy to ci for the C…
flowerthrower Aug 25, 2025
00b2661
🎨 pre-commit fixes
pre-commit-ci[bot] Aug 25, 2025
5e642d7
🎨 pre-commit
flowerthrower Aug 25, 2025
3bcc78a
🎨 improve lit test coverage
flowerthrower Aug 25, 2025
bca11f7
🎨 reduce code duplication
flowerthrower Aug 25, 2025
7a4c649
Merge branch 'mlir-plugin' of https://github.com/cda-tum/mqt-core int…
flowerthrower Aug 26, 2025
a92555a
🎨 update parameter handling in ConvertMQTOptSimpleGate for VOp
flowerthrower Aug 26, 2025
3110870
Merge branch 'main' into mlir-plugin
flowerthrower Aug 29, 2025
e1193f5
Merge branch 'mlir-plugin' of https://github.com/cda-tum/mqt-core int…
flowerthrower Aug 29, 2025
0acca05
fix checks
flowerthrower Aug 29, 2025
23c1fd7
add pauli gates conversion lit test
flowerthrower Sep 2, 2025
559648d
add clifford gates conversion lit test
flowerthrower Sep 2, 2025
708f2c8
add swap gates conversion lit test
flowerthrower Sep 2, 2025
59bcd6e
add ising gates conversion lit test
flowerthrower Sep 2, 2025
fcf3f5d
add parameterized gates conversion lit test
flowerthrower Sep 2, 2025
81ee0af
remove xxminusyy conversion
flowerthrower Sep 2, 2025
1496eb8
remove duplicate tests
flowerthrower Sep 2, 2025
c9e0c9f
add quantum conversion tests
flowerthrower Sep 4, 2025
bad986e
🎨 make style consistent with other tests
flowerthrower Sep 4, 2025
ef302a7
Merge remote-tracking branch 'origin/main' into mlir-plugin
flowerthrower Sep 19, 2025
2e7dc88
update tests
flowerthrower Sep 26, 2025
cd7916c
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 26, 2025
ac029e8
fix tests
flowerthrower Sep 26, 2025
2ea817b
Merge commit 'cd7916c2e194a709ae71c19aadd1ab3f99250e82' into mlir-plugin
flowerthrower Sep 26, 2025
dd33fbf
Merge branch 'main' into mlir-plugin
flowerthrower Sep 26, 2025
cec133f
first adaptions to work with new mref
flowerthrower Sep 26, 2025
2830e66
🎨 pre-commit fixes
pre-commit-ci[bot] Sep 26, 2025
1a49e72
make work with older llvm
flowerthrower Sep 29, 2025
f273fa4
Merge commit '2830e66c823f742f46bc19a356ddfaba6e73c422' into mlir-plugin
flowerthrower Sep 29, 2025
08a5565
update ising
flowerthrower Sep 29, 2025
0d79329
update entangling tests
flowerthrower Sep 29, 2025
0755907
finish update all mqtopt tests
flowerthrower Sep 29, 2025
fd2c784
fix quantum pauli test
flowerthrower Sep 29, 2025
e3ef2e9
update quantum to mqt conversion to account for mref
flowerthrower Sep 30, 2025
3fe4e05
use mlir isa
flowerthrower Sep 30, 2025
70be761
standardize tests
flowerthrower Oct 1, 2025
54c1dd7
calm down warnings
flowerthrower Oct 1, 2025
abc676d
Merge remote-tracking branch 'origin/main' into mlir-plugin
flowerthrower Oct 1, 2025
1906761
fix fialing tests
flowerthrower Oct 1, 2025
fe20c95
🚧 wip
flowerthrower Oct 1, 2025
54a4ec1
all lit tests succeed
flowerthrower Oct 1, 2025
b50d557
fix conversion dynamic index from operand
flowerthrower Oct 13, 2025
7443c3a
Merge commit '1e22f589e0531e4693a22beb6ae8eb5a53a85eb5' into mlir-plugin
flowerthrower Oct 13, 2025
c8af436
fix: update greedy driver configuration for MLIR version compatibility
flowerthrower Oct 14, 2025
c789e97
fix: streamline top-down traversal configuration for MLIR compatibility
flowerthrower Oct 14, 2025
443ea2f
fix: add conversion pattern for GlobalPhaseOp in Catalyst to MQTOpt
flowerthrower Oct 14, 2025
349e952
fix: remove unnecessary comments in ConvertQuantumGlobalPhase struct
flowerthrower Oct 14, 2025
e1e300c
fix: enhance gate conversion logic for RX, RY, RZ, CRX, CRY, CRZ, and…
flowerthrower Oct 15, 2025
8eec5c7
fix: implement conversion pattern for XXplusYYOp with parameter handl…
flowerthrower Oct 15, 2025
3721891
fix: update Ising gate conversion test to correctly handle new RZ par…
flowerthrower Oct 15, 2025
fd43fba
fix: add device configuration utilities to prevent gate decomposition…
flowerthrower Oct 15, 2025
36a5d50
fix: add python test cases for MQT plugin to ensure correct roundtrip…
flowerthrower Oct 15, 2025
886e71d
🎨 pre-commit fixes
pre-commit-ci[bot] Oct 15, 2025
2032b9e
fix: update Ising gate tests to use correct angle parameter and add P…
flowerthrower Oct 15, 2025
b071000
fix: update C++ linter configuration to use input from caller and ign…
flowerthrower Oct 16, 2025
3d44546
fix: add type hint for kwargs in get_device function and update docst…
flowerthrower Oct 16, 2025
f518011
Merge branch 'main' into mlir-plugin
flowerthrower Oct 16, 2025
71065ab
fix: update cpp-linter workflow commit
flowerthrower Oct 16, 2025
d6fec59
fix: reorder includes and improve type conversion comments in Catalys…
flowerthrower Oct 17, 2025
36b52da
Merge branch 'mlir-plugin' of https://github.com/cda-tum/mqt-core int…
flowerthrower Oct 23, 2025
f7f806b
fix: update MLIR and Catalyst dependencies and adjust Python version …
flowerthrower Oct 23, 2025
38c779c
Merge branch 'main' into mlir-plugin
flowerthrower Oct 23, 2025
d40fa29
fix: clean up README.md by removing TODO comments and improving wording
flowerthrower Oct 23, 2025
f79d5a9
Merge branch 'mlir-plugin' of https://github.com/cda-tum/mqt-core int…
flowerthrower Oct 23, 2025
465242a
fix: add explicit constructor to QubitInfo for gcc-14 compatibility
flowerthrower Oct 23, 2025
70c4596
fix: enhance ising gates roundtrip test with custom MLIR pipelines an…
flowerthrower Oct 23, 2025
cc88071
Refactor code structure for improved readability
flowerthrower Oct 24, 2025
7b95c7b
Apply suggestions from code review
flowerthrower Oct 24, 2025
90c25d1
fix: correct variable usage in ExternalDependencies.cmake and improve…
flowerthrower Oct 24, 2025
3fe4813
🎨 pre-commit fixes
pre-commit-ci[bot] Oct 24, 2025
2239690
feat: implement XXminusYY gate conversion and update test cases for I…
flowerthrower Oct 24, 2025
153b6e6
Merge branch 'mlir-plugin' of https://github.com/cda-tum/mqt-core int…
flowerthrower Oct 24, 2025
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
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.PHONY: plugin

CATALYST_BASE_DIR := /Users/patrickhopf/Code/catalyst/mlir
CATALYST_BUILD_DIR := $(CATALYST_BASE_DIR)/build
LLVM_BUILD_DIR := $(CATALYST_BASE_DIR)/llvm-project/build
LLVM_EXTERNAL_LIT := $(LLVM_BUILD_DIR)/bin/llvm-lit
CATALYST_TOOLS_DIR := $(LLVM_BUILD_DIR)/bin

plugin:
cmake -B build -G Ninja \
-DCatalyst_DIR=$(CATALYST_BUILD_DIR)/lib/cmake/catalyst \
-DMLIR_DIR=$(LLVM_BUILD_DIR)/lib/cmake/mlir \
-DBUILD_MQT_CORE_MLIR=ON \

cmake --build build
cmake --build build --target quantum-opt
3 changes: 3 additions & 0 deletions mlir/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#
# Licensed under the MIT License

# HACK
cmake_policy(SET CMP0057 NEW)

# set the include directory for the build tree
set(MQT_MLIR_INCLUDE_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")

Expand Down
4 changes: 2 additions & 2 deletions mlir/include/mlir/Dialect/MQTOpt/IR/MQTOptTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ template <size_t N> class TargetArity {
public:
template <typename ConcreteOp>
class Impl : public mlir::OpTrait::TraitBase<ConcreteOp, Impl> {
static llvm::LogicalResult verifyTrait(mlir::Operation* op) {
static mlir::LogicalResult verifyTrait(mlir::Operation* op) {
auto unitaryOp = mlir::cast<ConcreteOp>(op);
if (const auto size = unitaryOp.getInQubits().size(); size != N) {
return op->emitError()
Expand All @@ -32,7 +32,7 @@ template <size_t N> class ParameterArity {
public:
template <typename ConcreteOp>
class Impl : public mlir::OpTrait::TraitBase<ConcreteOp, Impl> {
static llvm::LogicalResult verifyTrait(mlir::Operation* op) {
static mlir::LogicalResult verifyTrait(mlir::Operation* op) {
auto paramOp = mlir::cast<ConcreteOp>(op);
const auto& params = paramOp.getParams();
const auto& staticParams = paramOp.getStaticParams();
Expand Down
1 change: 1 addition & 0 deletions mlir/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
# Licensed under the MIT License

add_subdirectory(quantum-opt)
add_subdirectory(mqt-plugin)
28 changes: 28 additions & 0 deletions mlir/tools/mqt-plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (c) 2025 Chair for Design Automation, TUM
# All rights reserved.
#
# SPDX-License-Identifier: MIT
#
# Licensed under the MIT License

set(PLUGIN_OUTPUT_DIR "${CMAKE_SOURCE_DIR}/mqt_plugin_wheel/mqt_plugin")
add_compile_options(-fexceptions)

add_llvm_library(
MQTPlugin
MODULE
BUILDTREE_ONLY
mqt-plugin.cpp
DEPENDS
MLIRMQTOpt
MLIRMQTOptTransforms
PLUGIN_TOOL
catalyst-cli
LINK_LIBS
MLIRMQTOpt
MLIRMQTOptTransforms
${MLIRQuantum_LIB} # Link directly to the static library
)

# Set output directory for the plugin to be shipped with the wheel
set_target_properties(MQTPlugin PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${PLUGIN_OUTPUT_DIR}")
45 changes: 45 additions & 0 deletions mlir/tools/mqt-plugin/mqt-plugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2025 Chair for Design Automation, TUM
* All rights reserved.
*
* SPDX-License-Identifier: MIT
*
* Licensed under the MIT License
*/

//===- mqt-plugin.cpp ------------------------------------*- C++ -*-===//
//
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "mlir/Dialect/MQTOpt/IR/MQTOptDialect.h"
#include "mlir/Dialect/MQTOpt/Transforms/Passes.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/Tools/Plugins/DialectPlugin.h"
#include "mlir/Tools/Plugins/PassPlugin.h"

#include "llvm/Config/llvm-config.h"
#include "llvm/Support/Compiler.h"

using namespace mlir;

/// Dialect plugin registration mechanism.
/// Observe that it also allows to register passes.
/// Necessary symbol to register the dialect plugin.
extern "C" LLVM_ATTRIBUTE_WEAK DialectPluginLibraryInfo
mlirGetDialectPluginInfo() {
return {MLIR_PLUGIN_API_VERSION, "MQTOpt", LLVM_VERSION_STRING,
[](DialectRegistry* registry) {
registry->insert<::mqt::ir::opt::MQTOptDialect>();
}};
}

/// Pass plugin registration mechanism.
/// Necessary symbol to register the pass plugin.
extern "C" LLVM_ATTRIBUTE_WEAK PassPluginLibraryInfo mlirGetPassPluginInfo() {
return {MLIR_PLUGIN_API_VERSION, "MQTOptPasses", LLVM_VERSION_STRING,
[]() { mqt::ir::opt::registerMQTOptPasses(); }};
}
9 changes: 9 additions & 0 deletions mqt_plugin_wheel/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2025 Chair for Design Automation, TUM
# All rights reserved.
#
# SPDX-License-Identifier: MIT
#
# Licensed under the MIT License

include mqt_plugin/lib/*
include mqt_plugin/test/*.py
Binary file added mqt_plugin_wheel/mqt_plugin/MQTPlugin.dylib
Binary file not shown.
84 changes: 84 additions & 0 deletions mqt_plugin_wheel/mqt_plugin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Copyright (c) 2025 Chair for Design Automation, TUM
# All rights reserved.
#
# SPDX-License-Identifier: MIT
#
# Licensed under the MIT License

# Copyright 2024 Xanadu Quantum Technologies Inc.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.

"""MQT Plugin interface."""

from __future__ import annotations

from pathlib import Path

import pennylane as qml
from catalyst.passes import PassPlugin


def getMQTPluginAbsolutePath():
"""Returns the absolute path to the MQT plugin."""
ext = "dylib" # TODO: we should provide "so" as well
# ext = "so" if platform.system() == "Linux" else "dylib"
return Path(Path(__file__).parent.absolute(), f"MQTPlugin.{ext}")


def name2pass(_name):
"""Example entry point for MQT plugin."""
return getMQTPluginAbsolutePath(), "mqt-core-round-trip"


def MQTCoreRoundTrip(*flags, **valued_options):
"""Applies the "mqt-core-round-trip" pass."""

def add_pass_to_pipeline(**kwargs):
pass_pipeline = kwargs.get("pass_pipeline", [])
pass_pipeline.append(
PassPlugin(
getMQTPluginAbsolutePath(),
"mqt-core-round-trip",
*flags,
**valued_options,
)
)
return pass_pipeline

def decorator(qnode):
if not isinstance(qnode, qml.QNode):
# Technically, this apply pass is general enough that it can apply to
# classical functions too. However, since we lack the current infrastructure
# to denote a function, let's limit it to qnodes
msg = f"A QNode is expected, got the classical function {qnode}"
raise TypeError(msg)

def qnode_call(*args, **kwargs):
kwargs["pass_pipeline"] = add_pass_to_pipeline(**kwargs)
return qnode(*args, **kwargs)

return qnode_call

# When the decorator is used without ()
if len(flags) == 1 and isinstance(flags[0], qml.QNode):
qnode = flags[0]

def qnode_call(*args, **kwargs):
kwargs["pass_pipeline"] = add_pass_to_pipeline(**kwargs)
return qnode(*args, **kwargs)

return qnode_call

# When the decorator is used with ()
return decorator
6 changes: 6 additions & 0 deletions mqt_plugin_wheel/mqt_plugin/test/dev_config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# PennyLane dvice configuration file

["main"]
shots = 1024
wires = 2
cmap = [[0, 1], [1, 0]]
168 changes: 168 additions & 0 deletions mqt_plugin_wheel/mqt_plugin/test/test_mlir_plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# Copyright (c) 2025 Chair for Design Automation, TUM
# All rights reserved.
#
# SPDX-License-Identifier: MIT
#
# Licensed under the MIT License

# Copyright 2024 Xanadu Quantum Technologies Inc.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.

"""This file performs the frontend lit tests that the peephole transformations are correctly lowered.

We check the transform jax primitives for each pass is correctly injected
during tracing, and these transform primitives are correctly lowered to the mlir before
running -apply-transform-sequence.
"""

# RUN: %PYTHON %s | FileCheck %s

# pylint: disable=line-too-long
from __future__ import annotations

from pathlib import Path

import pennylane as qml
from catalyst import CompileError, pipeline
from pennylane.configuration import Configuration
from utils import print_jaxpr, print_mlir
from utils import qjit_for_tests as qjit


def flush_peephole_opted_mlir_to_iostream(QJIT) -> None:
"""The QJIT compiler does not offer a direct interface to access an intermediate mlir in the pipeline.
The `QJIT.mlir` is the mlir before any passes are run, i.e. the "0_<qnode_name>.mlir".
Since the QUANTUM_COMPILATION_PASS is located in the middle of the pipeline, we need
to retrieve it with keep_intermediate=True and manually access the "2_QuantumCompilationPass.mlir".
Then we delete the kept intermediates to avoid pollution of the workspace.
"""


#
# pipeline
#


def test_pipeline_lowering() -> None:
"""Basic pipeline lowering on one qnode."""
my_pipeline = {
"cancel_inverses": {},
"merge_rotations": {},
}

@qjit(keep_intermediate=True, verbose=True)
@pipeline(my_pipeline)
@qml.qnode(qml.device("lightning.qubit", wires=2))
def test_pipeline_lowering_workflow(x):
qml.RX(x, wires=[0])
qml.Hadamard(wires=[1])
qml.Hadamard(wires=[1])
return qml.expval(qml.PauliY(wires=0))

# CHECK: pipeline=(remove-chained-self-inverse, merge-rotations)
print_jaxpr(test_pipeline_lowering_workflow, 1.2)

# CHECK: transform.named_sequence @__transform_main
# CHECK-NEXT: {{%.+}} = transform.apply_registered_pass "remove-chained-self-inverse" to {{%.+}}
# CHECK-NEXT: {{%.+}} = transform.apply_registered_pass "merge-rotations" to {{%.+}}
# CHECK-NEXT: transform.yield
print_mlir(test_pipeline_lowering_workflow, 1.2)

# CHECK: {{%.+}} = call @test_pipeline_lowering_workflow_transformed_0(
# CHECK: func.func public @test_pipeline_lowering_workflow_transformed_0(
# CHECK: {{%.+}} = quantum.custom "RX"({{%.+}}) {{%.+}} : !quantum.bit
# CHECK-NOT: {{%.+}} = quantum.custom "Hadamard"() {{%.+}} : !quantum.bit
# CHECK-NOT: {{%.+}} = quantum.custom "Hadamard"() {{%.+}} : !quantum.bit
test_pipeline_lowering_workflow(42.42)
flush_peephole_opted_mlir_to_iostream(test_pipeline_lowering_workflow)


def test_MQT_plugin() -> bool | None:
"""Generate MLIR for the MQT plugin via entry-point.

HACK required to make this test work!

1. in catalyst/pipelines.py, add the following line:

def get_enforce_runtime_invariants_stage(_options: CompileOptions) -> List[str]:
...
enforce_runtime_invariants = [
...
"builtin.module(mqt-core-round-trip)", # HACK
"builtin.module(apply-transform-sequence)",
...
]

2. in catalyst/compiler.py, add the following line:

def run_from_ir(self, ir: str, module_name: str, workspace: Directory):
...
cmd = self.get_cli_command(tmp_infile_name, output_ir_name, module_name, workspace)
cmd += ["--debug"] # HACK
try:
...

"""
my_pipeline = {
"mqt.mqt-core-round-trip": {"cmap": [[0, 1], [1, 0]]},
# "mqt.mqt-core-round-trip": {},
}

config_path = Path(__file__).parent / "dev_config.toml"
Configuration(config_path)
dev = qml.device(
name="lightning.qubit", wires=2
) # config=conf)#"lightning.qubit", {'wires': 2, 'cmap': [[0, 1], [1, 0]]})

try:

@qjit(keep_intermediate=True, verbose=True)
@pipeline(my_pipeline)
@qml.qnode(dev)
def test_pipeline_mqtplugin_workflow() -> None:
qml.Hadamard(wires=[0])

test_pipeline_mqtplugin_workflow()
flush_peephole_opted_mlir_to_iostream(test_pipeline_mqtplugin_workflow)

except CompileError as error: # Expecting failure, because MQT plugin does not cover full roundtrip (yet)
error_msg = str(error) # Recover the output after application of the MQT conversion pass
try:
mlir_str = error_msg.split("module @module_test_pipeline_mqtplugin_workflow_transformed {")[1]
mlir_str = error_msg.split("}\n}")[0]
except:
return False

transformed = [
r"%c = stablehlo.constant dense<0> : tensor<i64>",
r"%extracted = tensor.extract %c[] : tensor<i64>",
r"quantum.device shots(%extracted) ", # ... there is more in this line
r"%c_0 = stablehlo.constant dense<1> : tensor<i64>",
r'%0 = "mqtopt.allocQubitRegister"() <{size_attr = 1 : i64}> : () -> !mqtopt.QubitRegister',
r"%c_1 = stablehlo.constant dense<0> : tensor<i64>",
r"%extracted_2 = tensor.extract %c_1[] : tensor<i64>",
r'%out_qureg, %out_qubit = "mqtopt.extractQubit"(%0, %extracted_2) : (!mqtopt.QubitRegister, i64) -> (!mqtopt.QubitRegister, !mqtopt.Qubit)',
r"%1 = mqtopt.H() %out_qubit : !mqtopt.Qubit",
r"%c_3 = stablehlo.constant dense<0> : tensor<i64>",
r"%extracted_4 = tensor.extract %c_3[] : tensor<i64>",
r'%2 = "mqtopt.insertQubit"(%out_qureg, %1, %extracted_4) : (!mqtopt.QubitRegister, !mqtopt.Qubit, i64) -> !mqtopt.QubitRegister',
r'"mqtopt.deallocQubitRegister"(%2) : (!mqtopt.QubitRegister) -> ()',
r"quantum.device_release",
r"return",
]

return all(t in mlir_str for t in transformed)


test_MQT_plugin()
Loading
Loading