-
-
Notifications
You must be signed in to change notification settings - Fork 48
✨Implement Unitized Routing Passes #1301
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
Merged
Merged
Changes from all commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
5a23021
Add RoutingDriver struct
MatthiasReumann eb4e104
Remove worklist from route function
MatthiasReumann 5750df5
Add working global scheduler and routing process
MatthiasReumann 50a66bc
Add mapper base and naive mapper files
MatthiasReumann d6c702f
Implement driver approach
MatthiasReumann 260036c
Fix scf funcs for AStarDriver
MatthiasReumann d59bfc1
Add statistics struct
MatthiasReumann 7f9a8ca
Improve a-star scheduler
MatthiasReumann f9106f6
Implement fix-and-repair approach
MatthiasReumann a4f43fe
Split naive and astar router into separate passes
MatthiasReumann 8531ed7
Add astar functionality to the respective pass
MatthiasReumann dc908e1
Update schedule function to handle scf.for and scf.if as well
MatthiasReumann 24aba99
Compute anchor when adding operations to layer
MatthiasReumann fdbbbb4
Implement branching logic
MatthiasReumann 27f23b1
Improve documentation of WireIterator
MatthiasReumann 40b005e
Fix linting
MatthiasReumann 8772335
Add missing header
MatthiasReumann 993163a
Improve documentation
MatthiasReumann 78d4d67
Remove closed map in A* for now
MatthiasReumann 7dcccac
Add skip-two-qubit-block function
MatthiasReumann beb0b81
Add A* fallback mechanism.
MatthiasReumann ab8b7a7
Remove layout from scheduling
MatthiasReumann 11bf8d7
Use TypeSwitch
MatthiasReumann 882909c
Clean up pull-request
MatthiasReumann c201372
Add Unit abstraction
MatthiasReumann 69a4734
Implement LayeredUnit
MatthiasReumann befa5f7
Implement SequentialUnit
MatthiasReumann 79b76f8
Fix linting
MatthiasReumann 346fe58
Add LLVM_DEBUG
MatthiasReumann a23d79c
Fix more linting issues
MatthiasReumann 10412da
Remove grid layouts
MatthiasReumann 6438f07
Fix heuristic bug
MatthiasReumann 9d1df84
Merge branch 'main' into enh/routing-driver
MatthiasReumann 1365ad1
Merge branch 'main' into enh/routing-driver
MatthiasReumann 48ff8f4
🎨 pre-commit fixes
pre-commit-ci[bot] 33448a1
Reduce code duplication
MatthiasReumann 4ade668
Merge branch 'enh/routing-driver' of https://github.com/munich-quantu…
MatthiasReumann 3404e7a
Remove stack from verification pass
MatthiasReumann c317604
Add std::queue header
MatthiasReumann fcfbff6
Remove header
MatthiasReumann dcc49fb
Add bunny suggestions
MatthiasReumann 6aa5927
Add QubitIndex.h
MatthiasReumann 8993868
Fix linting
MatthiasReumann 8d3419e
Remove SlidingWindow Iterator
MatthiasReumann 13f2900
Fix linting
MatthiasReumann fabda23
Apply bunny suggestions
MatthiasReumann 0746263
Apply bunny suggestions
MatthiasReumann 5ca6ec0
Remove history
MatthiasReumann cb4baa0
Merge branch 'main' into enh/routing-driver
MatthiasReumann f60eecb
Update CHANGELOG.md
MatthiasReumann 0fcf836
Fix "A Unit"
MatthiasReumann 06e1d7e
Make remap functions class methods
MatthiasReumann e4676c1
Use templated range for insertSWAPs function
MatthiasReumann 2fb08dd
Add swap check to unitary remap method
MatthiasReumann b4e658d
Remove casting header
MatthiasReumann 2122f50
Apply suggestions from code review
MatthiasReumann dca2e0a
🎨 pre-commit fixes
pre-commit-ci[bot] 1264ab3
Add 'shortestSWAPsBetween' to architecture class
MatthiasReumann 869fee6
Remove QubitIndex and add isExecutable to Architecture
MatthiasReumann b050bf5
Fix linting
MatthiasReumann 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
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
70 changes: 70 additions & 0 deletions
70
mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/LayeredUnit.h
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,70 @@ | ||
| /* | ||
| * 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 | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "mlir/Dialect/MQTOpt/Transforms/Transpilation/Common.h" | ||
| #include "mlir/Dialect/MQTOpt/Transforms/Transpilation/Layout.h" | ||
| #include "mlir/Dialect/MQTOpt/Transforms/Transpilation/Unit.h" | ||
|
|
||
| #include <cstddef> | ||
| #include <llvm/ADT/STLExtras.h> | ||
| #include <llvm/Support/Debug.h> | ||
| #include <mlir/Support/LLVM.h> | ||
|
|
||
| namespace mqt::ir::opt { | ||
|
|
||
| struct Layer { | ||
| /// @brief All (zero, one, two-qubit) ops contained inside this layer. | ||
| mlir::SmallVector<mlir::Operation*, 64> ops; | ||
| /// @brief The program index pairs of all two-qubit ops. | ||
| mlir::SmallVector<QubitIndexPair, 16> twoQubitProgs; | ||
| /// @brief The first op in ops in textual IR order. | ||
| mlir::Operation* anchor{}; | ||
|
|
||
| /// @brief Add op to ops and reset anchor if necessary. | ||
| void addOp(mlir::Operation* op) { | ||
| ops.emplace_back(op); | ||
| if (anchor == nullptr || op->isBeforeInBlock(anchor)) { | ||
| anchor = op; | ||
| } | ||
| } | ||
| /// @returns true iff. there are no ops in this layer. | ||
| [[nodiscard]] bool hasZeroOps() const { return ops.empty(); } | ||
| /// @returns true iff. there are no two-qubit ops in this layer. | ||
| [[nodiscard]] bool hasZero2QOps() const { return twoQubitProgs.empty(); } | ||
| }; | ||
|
|
||
| /// @brief A LayeredUnit traverses a program layer-by-layer. | ||
| class LayeredUnit : public Unit { | ||
| public: | ||
| using Layers = mlir::SmallVector<Layer, 0>; | ||
|
|
||
| [[nodiscard]] static LayeredUnit | ||
| fromEntryPointFunction(mlir::func::FuncOp func, std::size_t nqubits); | ||
|
|
||
| LayeredUnit(Layout layout, mlir::Region* region, bool restore = false); | ||
|
|
||
| [[nodiscard]] mlir::SmallVector<LayeredUnit, 3> next(); | ||
| [[nodiscard]] Layers::const_iterator begin() const { return layers_.begin(); } | ||
| [[nodiscard]] Layers::const_iterator end() const { return layers_.end(); } | ||
| [[nodiscard]] const Layer& operator[](std::size_t i) const { | ||
| return layers_[i]; | ||
| } | ||
| [[nodiscard]] std::size_t size() const { return layers_.size(); } | ||
|
|
||
| #ifndef NDEBUG | ||
| LLVM_DUMP_METHOD void dump(llvm::raw_ostream& os = llvm::dbgs()) const; | ||
| #endif | ||
|
|
||
| private: | ||
| Layers layers_; | ||
| }; | ||
| } // 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.