-
-
Notifications
You must be signed in to change notification settings - Fork 54
✨ Add Rotation Gate Merging using Quaternions #1407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
J4MMlE
wants to merge
31
commits into
munich-quantum-toolkit:main
Choose a base branch
from
J4MMlE:quaternion-rotation-merging
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,643
−11
Open
Changes from 6 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
b566c21
✨ Add quaternion rotation merging pass with core algorithm
J4MMlE 34a9e7c
✅ Add tests for quaternion merging and simplify pattern matching
J4MMlE 6749f3c
🐛 Fix u-gate combination and improve test infrastructure
J4MMlE f8aaa9d
♻️ Refine pass implementation, error handling, and documentation
J4MMlE 44c3c62
🐛 Handle gimbal lock and add edge case tests
J4MMlE aa8caf4
♻️ Final improvements: type checks, parameter ordering, pipeline test
J4MMlE 9f468aa
Merge branch 'main' into merge-main
MatthiasReumann f75edf8
Fix compiler pipeline test
MatthiasReumann cfe9eda
Add RotationGateMergingPass test
MatthiasReumann 1a22b2b
Fix test
MatthiasReumann 54e612b
🔀 Merge with main
burgholzer c11e856
📝 Split off merge-rotation-gates pass changelog entry
burgholzer 05d5fdc
✅ refine compiler pipeline test
burgholzer 22d17ad
🚨 fix clang-tidy warning
burgholzer 1ee703b
🎨 remove most of the redundant `mlir::` namespace specifiers
burgholzer fb0d8cb
✏️ Fix typo in changelog entry
burgholzer abdacce
🚨 Use `OpType::create` methods
burgholzer b267779
♻️ Rename compiler flag and clean up docstrings
J4MMlE 409f94d
♻️ Remove single-use constraint on rotation gate
J4MMlE e707dc5
♻️ Refactor operation replacement
J4MMlE e506cec
♻️ Consolidate constants into shared Constants struc
J4MMlE 7e6299b
🔀 Merge with main
J4MMlE 40b697d
✨ Add support for POp, ROp, U2Op
J4MMlE 7198eb3
🐛 Normalize UOp alpha/gamma angles after quaternion-to-Euler conversion
J4MMlE e7b8da6
♻️ Refactor from pairwise to chain-based merging
J4MMlE e16f12d
🔀 Merge with main
J4MMlE b2a7d4b
🐛 fix collectChain UB, linter warnings, and inaccurate test and comment
J4MMlE f889a11
🔥 remove dead pairwise gate merge
J4MMlE 114392b
🚨 fix linter warnings
J4MMlE 3bf55ff
🩹 fix linter warnings and emit merged op at chain tail
J4MMlE 212605a
📝 add note for discarding of global phase
J4MMlE File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,3 +7,4 @@ | |
| # Licensed under the MIT License | ||
|
|
||
| add_subdirectory(IR) | ||
| add_subdirectory(Transforms) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Copyright (c) 2023 - 2026 Chair for Design Automation, TUM | ||
| # Copyright (c) 2025 - 2026 Munich Quantum Software Company GmbH | ||
| # All rights reserved. | ||
| # | ||
| # SPDX-License-Identifier: MIT | ||
| # | ||
| # Licensed under the MIT License | ||
|
|
||
| set(LLVM_TARGET_DEFINITIONS Passes.td) | ||
| mlir_tablegen(Passes.h.inc -gen-pass-decls -name QCO) | ||
| add_public_tablegen_target(MLIRQCOTransformsIncGen) | ||
| add_mlir_doc(Passes QCOPasses Passes/ -gen-pass-doc) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /* | ||
| * Copyright (c) 2023 - 2026 Chair for Design Automation, TUM | ||
| * Copyright (c) 2025 - 2026 Munich Quantum Software Company GmbH | ||
| * All rights reserved. | ||
| * | ||
| * SPDX-License-Identifier: MIT | ||
| * | ||
| * Licensed under the MIT License | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <mlir/Pass/Pass.h> // from @llvm-project | ||
|
|
||
| namespace mlir::qco { | ||
| #define GEN_PASS_DECL | ||
| #include "mlir/Dialect/QCO/Transforms/Passes.h.inc" // IWYU pragma: export | ||
|
|
||
| #define GEN_PASS_REGISTRATION | ||
| #include "mlir/Dialect/QCO/Transforms/Passes.h.inc" // IWYU pragma: export | ||
| } // namespace mlir::qco |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // Copyright (c) 2023 - 2026 Chair for Design Automation, TUM | ||
| // Copyright (c) 2025 - 2026 Munich Quantum Software Company GmbH | ||
| // All rights reserved. | ||
| // | ||
| // SPDX-License-Identifier: MIT | ||
| // | ||
| // Licensed under the MIT License | ||
|
|
||
| include "mlir/Pass/PassBase.td" | ||
|
|
||
| def MergeRotationGates : Pass<"merge-rotation-gates", | ||
| "mlir::ModuleOp"> { | ||
| let summary = "Merge rotation gates using quaternion-based fusion"; | ||
| let description = [{ | ||
| Merges consecutive rotation gates of different types (rx, ry, rz, u) | ||
J4MMlE marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| using quaternion representation and the Hamilton product. | ||
| }]; | ||
|
|
||
| let dependentDialects = ["::mlir::arith::ArithDialect", "::mlir::math::MathDialect"]; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,4 @@ | |
|
|
||
| add_subdirectory(Builder) | ||
| add_subdirectory(IR) | ||
| add_subdirectory(Transforms) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # Copyright (c) 2023 - 2026 Chair for Design Automation, TUM | ||
| # Copyright (c) 2025 - 2026 Munich Quantum Software Company GmbH | ||
| # All rights reserved. | ||
| # | ||
| # SPDX-License-Identifier: MIT | ||
| # | ||
| # Licensed under the MIT License | ||
|
|
||
| get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS) | ||
| set(LIBRARIES ${dialect_libs} MQT::CoreIR) | ||
J4MMlE marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| add_compile_options(-fexceptions) | ||
burgholzer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
burgholzer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| file(GLOB_RECURSE TRANSFORMS_SOURCES *.cpp) | ||
|
|
||
| add_mlir_library(MLIRQCOTransforms ${TRANSFORMS_SOURCES} LINK_LIBS ${LIBRARIES} DEPENDS | ||
| MLIRQCOTransformsIncGen) | ||
|
|
||
| # collect header files | ||
| file(GLOB_RECURSE TRANSFORMS_HEADERS_SOURCE | ||
| ${MQT_MLIR_SOURCE_INCLUDE_DIR}/mlir/Dialect/QCO/Transforms/*.h) | ||
| file(GLOB_RECURSE TRANSFORMS_HEADERS_BUILD | ||
| ${MQT_MLIR_BUILD_INCLUDE_DIR}/mlir/Dialect/QCO/Transforms/*.inc) | ||
|
|
||
| # add public headers using file sets | ||
| target_sources( | ||
| MLIRQCOTransforms | ||
| PUBLIC FILE_SET | ||
| HEADERS | ||
| BASE_DIRS | ||
| ${MQT_MLIR_SOURCE_INCLUDE_DIR} | ||
| FILES | ||
| ${TRANSFORMS_HEADERS_SOURCE} | ||
| FILE_SET | ||
| HEADERS | ||
| BASE_DIRS | ||
| ${MQT_MLIR_BUILD_INCLUDE_DIR} | ||
| FILES | ||
| ${TRANSFORMS_HEADERS_BUILD}) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.