Skip to content
Open
Show file tree
Hide file tree
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 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
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ This project adheres to [Semantic Versioning], with the exception that minor rel
### Added

- ✨ Add initial infrastructure for new QC and QCO MLIR dialects
([#1264], [#1330], [#1402], [#1428], [#1430], [#1436], [#1443], [#1446], [#1464], [#1465], [#1470], [#1471], [#1472], [#1474], [#1475])
([**@burgholzer**], [**@denialhaag**], [**@taminob**], [**@DRovara**], [**@li-mingbao**], [**@Ectras**])
([#1264], [#1330], [#1402], [#1407], [#1428], [#1430], [#1436], [#1443], [#1446], [#1464], [#1465], [#1470], [#1471], [#1472], [#1474], [#1475])
([**@burgholzer**], [**@denialhaag**], [**@taminob**], [**@DRovara**], [**@li-mingbao**], [**@Ectras**], [**@J4MMlE**])

### Changed

Expand Down Expand Up @@ -351,6 +351,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 @@ -506,6 +507,7 @@ _📚 Refer to the [GitHub Release Notes](https://github.com/munich-quantum-tool
[**@marcelwa**]: https://github.com/marcelwa
[**@lirem101**]: https://github.com/lirem101
[**@Ectras**]: https://github.com/Ectras
[**@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 @@ -39,6 +39,9 @@ struct QuantumCompilerConfig {

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

/// Enable quaternion-based rotation gate merging
bool mergeRotationGates = false;
};

/**
Expand Down
1 change: 1 addition & 0 deletions mlir/include/mlir/Dialect/QCO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
# Licensed under the MIT License

add_subdirectory(IR)
add_subdirectory(Transforms)
12 changes: 12 additions & 0 deletions mlir/include/mlir/Dialect/QCO/Transforms/CMakeLists.txt
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)
21 changes: 21 additions & 0 deletions mlir/include/mlir/Dialect/QCO/Transforms/Passes.h
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
20 changes: 20 additions & 0 deletions mlir/include/mlir/Dialect/QCO/Transforms/Passes.td
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)
using quaternion representation and the Hamilton product.
}];

let dependentDialects = ["::mlir::arith::ArithDialect", "::mlir::math::MathDialect"];
}
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(
QCToQCO
QCOToQC
QCToQIR
MLIRQCOTransforms
MQT::MLIRSupport
MQT::ProjectOptions
DISABLE_INSTALL)
Expand Down
11 changes: 9 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 @@ -162,9 +163,15 @@ QuantumCompilerPipeline::runPipeline(ModuleOp module,
// Stage 5: Optimization passes
// TODO: Add optimization passes
addCleanupPasses(pm);
if (failed(pm.run(module))) {
return failure();

// quaternion gate merging pass
if (config_.mergeRotationGates) {
pm.addPass(mlir::qco::createMergeRotationGates());
if (failed(pm.run(module))) {
return failure();
}
}

if (record != nullptr && config_.recordIntermediates) {
record->afterOptimization = captureIR(module);
if (config_.printIRAfterAllStages) {
Expand Down
1 change: 1 addition & 0 deletions mlir/lib/Dialect/QCO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@

add_subdirectory(Builder)
add_subdirectory(IR)
add_subdirectory(Transforms)
38 changes: 38 additions & 0 deletions mlir/lib/Dialect/QCO/Transforms/CMakeLists.txt
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)
add_compile_options(-fexceptions)

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})
Loading
Loading