Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 Dec 28, 2025
34a9e7c
✅ Add tests for quaternion merging and simplify pattern matching
J4MMlE Jan 15, 2026
6749f3c
🐛 Fix u-gate combination and improve test infrastructure
J4MMlE Jan 22, 2026
f8aaa9d
♻️ Refine pass implementation, error handling, and documentation
J4MMlE Jan 22, 2026
44c3c62
🐛 Handle gimbal lock and add edge case tests
J4MMlE Jan 23, 2026
aa8caf4
♻️ Final improvements: type checks, parameter ordering, pipeline test
J4MMlE Feb 4, 2026
9f468aa
Merge branch 'main' into merge-main
MatthiasReumann Mar 10, 2026
f75edf8
Fix compiler pipeline test
MatthiasReumann Mar 10, 2026
cfe9eda
Add RotationGateMergingPass test
MatthiasReumann Mar 10, 2026
1a22b2b
Fix test
MatthiasReumann Mar 10, 2026
54e612b
🔀 Merge with main
burgholzer Mar 12, 2026
c11e856
📝 Split off merge-rotation-gates pass changelog entry
burgholzer Mar 12, 2026
05d5fdc
✅ refine compiler pipeline test
burgholzer Mar 12, 2026
22d17ad
🚨 fix clang-tidy warning
burgholzer Mar 12, 2026
1ee703b
🎨 remove most of the redundant `mlir::` namespace specifiers
burgholzer Mar 12, 2026
fb0d8cb
✏️ Fix typo in changelog entry
burgholzer Mar 12, 2026
abdacce
🚨 Use `OpType::create` methods
burgholzer Mar 12, 2026
b267779
♻️ Rename compiler flag and clean up docstrings
J4MMlE Mar 17, 2026
409f94d
♻️ Remove single-use constraint on rotation gate
J4MMlE Mar 17, 2026
e707dc5
♻️ Refactor operation replacement
J4MMlE Mar 18, 2026
e506cec
♻️ Consolidate constants into shared Constants struc
J4MMlE Mar 18, 2026
7e6299b
🔀 Merge with main
J4MMlE Mar 21, 2026
40b697d
✨ Add support for POp, ROp, U2Op
J4MMlE Mar 19, 2026
7198eb3
🐛 Normalize UOp alpha/gamma angles after quaternion-to-Euler conversion
J4MMlE Mar 19, 2026
e7b8da6
♻️ Refactor from pairwise to chain-based merging
J4MMlE Mar 21, 2026
e16f12d
🔀 Merge with main
J4MMlE Mar 21, 2026
b2a7d4b
🐛 fix collectChain UB, linter warnings, and inaccurate test and comment
J4MMlE Mar 21, 2026
f889a11
🔥 remove dead pairwise gate merge
J4MMlE Mar 22, 2026
114392b
🚨 fix linter warnings
J4MMlE Mar 22, 2026
3bf55ff
🩹 fix linter warnings and emit merged op at chain tail
J4MMlE Mar 22, 2026
212605a
📝 add note for discarding of global phase
J4MMlE Mar 22, 2026
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning], with the exception that minor rel

### Added

- ✨ Add a `mlir-merge-single-qubit-rotation-gates` pass for merging consecutive rotation gates using quaternions ([#1407]) ([**@J4MMlE**])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- ✨ Add a `mlir-merge-single-qubit-rotation-gates` pass for merging consecutive rotation gates using quaternions ([#1407]) ([**@J4MMlE**])
- ✨ Add a `merge-single-qubit-rotation-gates` pass for merging consecutive rotation gates using quaternions ([#1407]) ([**@J4MMlE**])

Just noticed this here when being contrasted to the place-and-route pass below; do we want to drop the mlir- prefix for the pass name?
Or, to open up another box, would it make sense to define our own prefix that identifies passes being run as part of mqt-cc? (e.g., by using the mqt-cc- prefix)
@munich-quantum-toolkit/mqt-cc any opinions on that?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would personally drop the mlir (make mlir an identifier for options/concepts taken directly from MLIR). I don't have a super strong opinion on the mqt-cc- prefix, except that it's a bit weird to call the program using

./mqt-cc test.mlir --mqt-cc-option1 --mqt-cc-option2...

One could say "well of course it's an mqt-cc option, I literally use it on mqt-cc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. Should be safe to just drop then and use no prefix.

- ✨ Add Sampler and Estimator Primitives to the QDMI-Qiskit Interface ([#1507]) ([**@marcelwa**])
- ✨ Add conversions between Jeff and QCO ([#1479], [#1548], [#1565]) ([**@denialhaag**])
- ✨ Add a `place-and-route` pass for mapping circuits to architectures with restricted topologies ([#1537], [#1547], [#1568]) ([**@MatthiasReumann**])
Expand Down Expand Up @@ -377,6 +378,7 @@ _📚 Refer to the [GitHub Release Notes](https://github.com/munich-quantum-tool
[#1413]: https://github.com/munich-quantum-toolkit/core/pull/1413
[#1412]: https://github.com/munich-quantum-toolkit/core/pull/1412
[#1411]: https://github.com/munich-quantum-toolkit/core/pull/1411
[#1407]: https://github.com/munich-quantum-toolkit/core/pull/1407
[#1406]: https://github.com/munich-quantum-toolkit/core/pull/1406
[#1403]: https://github.com/munich-quantum-toolkit/core/pull/1403
[#1402]: https://github.com/munich-quantum-toolkit/core/pull/1402
Expand Down Expand Up @@ -533,6 +535,7 @@ _📚 Refer to the [GitHub Release Notes](https://github.com/munich-quantum-tool
[**@lirem101**]: https://github.com/lirem101
[**@Ectras**]: https://github.com/Ectras
[**@simon1hofmann**]: https://github.com/simon1hofmann
[**@J4MMlE**]: https://github.com/J4MMlE

<!-- General links -->

Expand Down
3 changes: 3 additions & 0 deletions mlir/include/mlir/Compiler/CompilerPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ struct QuantumCompilerConfig {

/// Print IR after each stage
bool printIRAfterAllStages = false;

/// Enable quaternion-based rotation gate merging
bool mergeSingleQubitRotationGates = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like this should default to true. There is no real downside of running this, right? We just need to make sure to be careful when this pass is run in relation to gate synthesis in general.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may need a refresher, but doesn't this pass also do stuff like merging RX; RZ? In that case, I'm not sure if we always want that. Sometimes, one wants to specifically work with special types of rotations (e.g., because the hardware only accepts those).

One could argue that this IR should be device agnostic, so it shouldn't matter. I'm just not sure if we maybe would then lose some information or potential for reductions when going back from U to RX; RZ.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It all depends on where this pass is being run in the pipeline. For the hardware-agnostic stage, I would argue it should be on by default. We do not have a hardware-dependent level; but this pass should not be run after translating to the native gate-set.

};

/**
Expand Down
5 changes: 0 additions & 5 deletions mlir/include/mlir/Dialect/QCO/Transforms/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ namespace mlir::qco {
#define GEN_PASS_DECL
#include "mlir/Dialect/QCO/Transforms/Passes.h.inc" // IWYU pragma: export

//===----------------------------------------------------------------------===//
// Registration
//===----------------------------------------------------------------------===//

/// Generate the code for registering passes.
#define GEN_PASS_REGISTRATION
#include "mlir/Dialect/QCO/Transforms/Passes.h.inc" // IWYU pragma: export

Expand Down
11 changes: 11 additions & 0 deletions mlir/include/mlir/Dialect/QCO/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@

include "mlir/Pass/PassBase.td"

def MergeRotationGates : Pass<"merge-rotation-gates", "mlir::ModuleOp"> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changelog talks about a mlir-merge-single-qubit-rotation-gates pass, but this renaming is not reflected here, in the docs below, or the implementation files. Please update the code base so that the documentation is consistent.

let dependentDialects = ["mlir::qco::QCODialect",
"::mlir::arith::ArithDialect",
"::mlir::math::MathDialect"];
let summary = "Merge rotation gates using quaternion-based fusion";
let description = [{
Merges consecutive rotation gates of different types (rx, ry, rz, p, r, u2, u)
using quaternion representation and the Hamilton product.
}];
Comment on lines +19 to +22
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is the documentation that also shows up in the API docs, this should be a bit more extensive and give more details on what is actually going on internally, including references. You can take the place-and-route pass docs as an example

}

//===----------------------------------------------------------------------===//
// Transpilation Passes
//===----------------------------------------------------------------------===//
Expand Down
1 change: 1 addition & 0 deletions mlir/lib/Compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ add_mlir_library(
MLIRQCToQCO
MLIRQCOToQC
MLIRQCToQIR
MLIRQCOTransforms
MQT::MLIRSupport
DISABLE_INSTALL)

Expand Down
8 changes: 6 additions & 2 deletions mlir/lib/Compiler/CompilerPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "mlir/Conversion/QCOToQC/QCOToQC.h"
#include "mlir/Conversion/QCToQCO/QCToQCO.h"
#include "mlir/Conversion/QCToQIR/QCToQIR.h"
#include "mlir/Dialect/QCO/Transforms/Passes.h"
#include "mlir/Support/PrettyPrinting.h"

#include <llvm/ADT/StringRef.h>
Expand Down Expand Up @@ -140,8 +141,11 @@ QuantumCompilerPipeline::runPipeline(ModuleOp module,
}
}
// Stage 5: Optimization passes
// TODO: Add optimization passes
if (failed(runStage([&](PassManager& pm) { addCleanupPasses(pm); }))) {
if (failed(runStage([&](PassManager& pm) {
if (config_.mergeSingleQubitRotationGates) {
pm.addPass(mlir::qco::createMergeRotationGates());
}
}))) {
return failure();
}
if (record != nullptr && config_.recordIntermediates) {
Expand Down
3 changes: 2 additions & 1 deletion mlir/lib/Dialect/QCO/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ add_mlir_library(
PRIVATE
MLIRQCODialect
MLIRQCOUtils
${dialect_libs}
MLIRArithDialect
MLIRMathDialect
DEPENDS
MLIRQCOTransformsIncGen)

Expand Down
Loading
Loading