-
-
Notifications
You must be signed in to change notification settings - Fork 43
✨ Implement two-qubit gate decomposition pass #1206
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
Draft
taminob
wants to merge
100
commits into
main
Choose a base branch
from
taminob/mlir-two-qubit-gate-decomposition-pass
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.
Draft
Changes from all commits
Commits
Show all changes
100 commits
Select commit
Hold shift + click to select a range
bcf595b
snapshot
taminob a06cb1b
copied rust code
taminob 83a75c4
🎨 pre-commit fixes
pre-commit-ci[bot] 1dc459b
snapshot
taminob 95d7cae
snapshot
taminob 512fbe8
snapshot
taminob ea302dd
minor additions
taminob 91fd9c0
add pass to Passes.td
taminob 8cf929f
snapshot
taminob 2032436
compiling snapshot
taminob fe81855
tmp
taminob 3df1e5c
switch to long double
taminob f080bc6
testing a.cpp
taminob 792d082
add zgemm for testing, start euler decomposition implementation
taminob 5bd31b4
non-working but finished snapshot
taminob 5982c45
fix out-of-bounds issues
taminob 2e86550
test using Armadillo
taminob 6b110b8
minor fix
taminob 4a6c1bc
tmp
taminob 7ef7fde
work on gate application
taminob 0254818
use laughing-umbrella implementation for decompose_two_qubit_product_…
taminob e5f659e
add more eigen decomposition implementations
taminob ae3d08d
work on applySeries()
taminob d2f4456
Revert "use laughing-umbrella implementation for decompose_two_qubit_…
taminob 58c4ec3
fix transpose_conjugate
taminob 5aa5d87
add test
taminob 2359f28
actually kind of working snapshot?
taminob 4435948
fix test case
taminob 0b12cb3
minor fix
taminob e3dbdb3
fix test case
taminob 3974582
add new test, fix tests
taminob 458d187
iniital complexSeries test
taminob 4cb24a0
use Eigen for multiply() and determinant()
taminob 4cbc85e
fix gate matrix multiplication
taminob 374454b
add simple (too simple) series complexity
taminob 26b11a2
fix insertion when operations which are not part of the series are in…
taminob 2b648a9
add gate matrices
taminob f559334
sequence complexity()
taminob 85d204c
print debugging :)
taminob 1036007
longer complex test to pass sequence complexity check
taminob 1d654d1
use CXGate() definition for decomposer
taminob bba842c
add cnot test other direction
taminob bda98d0
tmp (to be deleted)
taminob 246879c
re-write using Eigen
taminob d50484d
delete pulse-optimizer code (KEEP for future; should be re-added at s…
taminob 9f7ac0e
use designated initializer lists
taminob c69618f
fix warnings, rename all variables
taminob f055925
test normalized magic basis, allow complex eigenvector decomposition
taminob be2feca
finally figured some stuff out
taminob d39d2ec
try out lauging-umbrella weyl-chamber
taminob 0013723
try to implement weylchamber.c1c2c3 algorithm
taminob d28ab9d
on_gates two-qubit product decompose
taminob d6c6a8b
minor additions
taminob d294635
try ordering all four eigenvectors
taminob 5c1d56b
undo ordering of all columns
taminob 388ca6b
implement algorithm based on quantumflow.canonical_decomposition
taminob fbd6647
sanity checks and stuff
taminob db09335
add original implementation again which seems to kind of work?
taminob afd19ee
generate openqasm code of generated sequence
taminob 79ced7b
some more small fixes, maybe breakthrough?
taminob 65057a0
rework getTwoQubitSeries logic
taminob 61e5678
generate openqasm code of found series
taminob 812fcd7
fix new getTwoQubitSeries logic
taminob 53f53c8
working except global phase?
taminob 1a0eebb
fix global phase issues
taminob cb85552
first working snapshot
taminob 09c9f2b
very minor cleanup
taminob fb0366d
add more sanity checks for unitary
taminob 0a41410
find and fix minor formula mistake
taminob 5bc93d9
test update
taminob 27b4cf8
make calculations exact without approximation
taminob 0a02763
respect gphase of circuit and fix series collection bug
taminob 786143e
change global phase to local phase
taminob a9bf676
revert to global phase, fix controlled gate qubit order
taminob 3a132ec
fix first couple of tests
taminob 3b61c08
start working on basis set and remove dead code
taminob dff3f30
decompose for all bases, choose best
taminob e3f67b9
add checks for most tests
taminob b89d602
TMP, needs to be removed; allow OpenQASM export with round-trip pass
taminob c531c56
add single-qubit backtracking
taminob 75d64a3
fix atol issues
taminob 13d9a0d
add more euler bases to pattern
taminob d14ac76
minor cleanup (renaming, comments, disable printing)
taminob 453565f
Revert "TMP, needs to be removed; allow OpenQASM export with round-tr…
taminob 29d01aa
remove armadillo in cmake
taminob b5f4b2d
more cleanup
taminob 0084081
fix (?) tests
taminob 50310f6
fix final test
taminob 500ccc6
another minor cleanup
taminob 9a4574e
clean sanity check prints up
taminob bf714ac
properly add Eigen lib to cmake
taminob 0a528b9
remove unnecessary correction
taminob 686ed5f
🎨 pre-commit fixes
pre-commit-ci[bot] 09d105c
fix eigen compilation issues
taminob 91fe42d
more cleanup
taminob 1705f83
clean up weyl decomposition creation
taminob 49d512f
remove openqasm code generation
taminob d8ab299
fix includes and use SmallVector instead of std::vector
taminob 4ea6f02
fix or silence linter
taminob 37b30e3
incorporate coderabbitai feedback
taminob 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
Some comments aren't visible on the classic Files Changed page.
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
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 |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * Copyright (c) 2023 - 2025 Chair for Design Automation, TUM | ||
| * Copyright (c) 2025 Munich Quantum Software Company GmbH | ||
| * All rights reserved. | ||
| * | ||
| * SPDX-License-Identifier: MIT | ||
| * | ||
| * Licensed under the MIT License | ||
| */ | ||
|
|
||
| #include "mlir/Dialect/MQTOpt/Transforms/Passes.h" | ||
|
|
||
| #include <mlir/IR/PatternMatch.h> | ||
| #include <mlir/Support/LLVM.h> | ||
| #include <mlir/Transforms/GreedyPatternRewriteDriver.h> | ||
| #include <utility> | ||
|
|
||
| namespace mqt::ir::opt { | ||
|
|
||
| #define GEN_PASS_DEF_GATEDECOMPOSITION | ||
| #include "mlir/Dialect/MQTOpt/Transforms/Passes.h.inc" | ||
|
|
||
| /** | ||
| * @brief This pass attempts to collect as many operations as possible into a | ||
| * 4x4 unitary matrix and then decompose it into 1q rotations and 2q | ||
| * basis gates. | ||
| */ | ||
| struct GateDecomposition final | ||
| : impl::GateDecompositionBase<GateDecomposition> { | ||
|
|
||
| void runOnOperation() override { | ||
| // Get the current operation being operated on. | ||
| auto op = getOperation(); | ||
| auto* ctx = &getContext(); | ||
|
|
||
| // Define the set of patterns to use. | ||
| mlir::RewritePatternSet patterns(ctx); | ||
| populateGateDecompositionPatterns(patterns); | ||
|
|
||
| // Configure greedy driver | ||
| mlir::GreedyRewriteConfig config; | ||
| config.setUseTopDownTraversal(true); | ||
|
|
||
| // Apply patterns in an iterative and greedy manner. | ||
| if (mlir::failed( | ||
| mlir::applyPatternsGreedily(op, std::move(patterns), config))) { | ||
| signalPassFailure(); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| } // namespace mqt::ir::opt |
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.