-
-
Notifications
You must be signed in to change notification settings - Fork 48
⚡️ Algorithmic Improvements of A*-search-based Routing #1271
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
Conversation
|
This is great to see! Would you mind adding the note about compiling llvm with statistics tracking to the Issue about providing pre-compiled MLIR binaries. I guess we should always make sure to compile with statistics on. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
1 similar comment
✅ Actions performedFull review triggered. |
|
@MatthiasReumann I think you have to take the PR out if its draft state and the rabbit will automatically perform a review |
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughReworks transpilation internals: replaces CouplingMap with CouplingSet and adds neighbour caching; redesigns A* router to a Node-based state and removes beta from HeuristicWeights; changes scheduler to a worklist/layered approach and updates related APIs, tests, and pass telemetry (removed beta option and msTime). Changes
Sequence Diagram(s)sequenceDiagram
participant Scheduler as ParallelOpScheduler
participant Worklist as Worklist/Queue
participant Adv as advanceToTwoQubitGate
participant Layer as LayerBuilder
Scheduler->>Worklist: init active qubits
loop per layer
Scheduler->>Worklist: pop active qubits
par find next two-qubit gate for each qubit
Scheduler->>Adv: advanceToTwoQubitGate(q, region, layout)
Adv-->>Scheduler: (Value, UnitaryInterface) or std::nullopt
end
alt gates found
Scheduler->>Layer: collect ready gates, remap qubits
Layer-->>Scheduler: built layer
Scheduler->>Scheduler: emit layer, advance heads, update layout
else none found
Scheduler->>Worklist: mark qubits inactive
end
end
sequenceDiagram
participant Caller as RoutingPass
participant Router as AStarHeuristicRouter
participant Arch as Architecture
participant Layout as ThinLayout
Caller->>Router: route(layers, layout, arch)
Router->>Layout: read layout (getHardwareIndex...)
Router->>Arch: neighbour queries (neighboursOf)
Router->>Router: expand Nodes, compute g/h, update ClosedMap
alt goal reached
Router-->>Caller: RouterResult (swaps)
else exhausted
Router-->>Caller: RouterResult (best effort / empty)
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~70 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
mlir/include/mlir/Dialect/MQTOpt/Transforms/Passes.td (1)
113-124: Complete documentation of breaking changes before merge.The code changes are correct and properly implemented—no remaining references to
betaormsTimeexist. However, this PR introduces breaking changes requiring documentation:
- Changelog: Must document removal of
--betaparameter andmsTimestatistic- Upgrade guide: Must guide users to use
-mlir-timinginstead of the removedmsTimemetric- Documentation: Any user-facing docs referencing
betaparameter need updatesThese are currently unchecked in the PR checklist and must be completed before merge.
mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Router.h (1)
55-63: Fix return-type mismatch in NaiveRouter::route.Line 55 declares
SmallVector<QubitIndexPair, 16> swaps;, but the function now returnsRouterResult(SmallVector<QubitIndexPair>). These template instantiations are distinct types, soreturn swaps;no longer compiles. Use the aliased type (and reserve inline capacity if needed) so the return statement matches the signature.Apply this diff:
- SmallVector<QubitIndexPair, 16> swaps; + RouterResult swaps; + swaps.reserve(16);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (11)
mlir/include/mlir/Dialect/MQTOpt/Transforms/Passes.td(1 hunks)mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Architecture.h(4 hunks)mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Common.h(2 hunks)mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Layout.h(3 hunks)mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Router.h(4 hunks)mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Scheduler.h(3 hunks)mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/Architecture.cpp(3 hunks)mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/Common.cpp(1 hunks)mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/PlacementPass.cpp(1 hunks)mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingPass.cpp(4 hunks)mlir/test/Dialect/MQTOpt/Transforms/Transpilation/astar-routing.mlir(1 hunks)
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: MatthiasReumann
PR: munich-quantum-toolkit/core#1237
File: mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Scheduler.h:72-140
Timestamp: 2025-10-09T04:30:29.071Z
Learning: In the CrawlScheduler (mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Scheduler.h), the persistent `layoutCopy` is updated across all lookahead layers via `remapQubitValue` calls. After each two-qubit gate is scheduled in a layer, its input qubits are remapped to output qubits, ensuring the next layer's crawl starts from those outputs. This progressive remapping through SSA values prevents the same operation from being scheduled in multiple lookahead layers.
Learnt from: MatthiasReumann
PR: munich-quantum-toolkit/core#1237
File: mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Planner.h:202-214
Timestamp: 2025-10-07T15:58:19.247Z
Learning: In the QMAP routing algorithm (mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Planner.h), the heuristic function h() intentionally uses a non-admissible heuristic that sums per-gate shortest-path distances. This is a deliberate design choice from the QMAP paper, where admissibility is dropped because locally optimal solutions can negatively affect the overall routing quality. This approach prioritizes global solution quality over guaranteed local optimality.
📚 Learning: 2025-10-09T13:20:11.483Z
Learnt from: DRovara
PR: munich-quantum-toolkit/core#1108
File: mlir/test/Dialect/MQTOpt/Transforms/lift-measurements.mlir:269-288
Timestamp: 2025-10-09T13:20:11.483Z
Learning: In the MQT MLIR dialect, the `rz` gate should not be included in the `DIAGONAL_GATES` set for the `ReplaceBasisStateControlsWithIfPattern` because its operator matrix does not have the required shape | 1 0 | / | 0 x | for the targets-as-controls optimization. It is only included in `LiftMeasurementsAboveGatesPatterns` where the matrix structure requirement differs.
Applied to files:
mlir/test/Dialect/MQTOpt/Transforms/Transpilation/astar-routing.mlirmlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/PlacementPass.cppmlir/lib/Dialect/MQTOpt/Transforms/Transpilation/Common.cpp
📚 Learning: 2025-10-09T04:30:29.071Z
Learnt from: MatthiasReumann
PR: munich-quantum-toolkit/core#1237
File: mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Scheduler.h:72-140
Timestamp: 2025-10-09T04:30:29.071Z
Learning: In the CrawlScheduler (mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Scheduler.h), the persistent `layoutCopy` is updated across all lookahead layers via `remapQubitValue` calls. After each two-qubit gate is scheduled in a layer, its input qubits are remapped to output qubits, ensuring the next layer's crawl starts from those outputs. This progressive remapping through SSA values prevents the same operation from being scheduled in multiple lookahead layers.
Applied to files:
mlir/test/Dialect/MQTOpt/Transforms/Transpilation/astar-routing.mlirmlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/PlacementPass.cppmlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Scheduler.hmlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Layout.hmlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingPass.cppmlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Router.h
📚 Learning: 2025-10-07T15:58:19.247Z
Learnt from: MatthiasReumann
PR: munich-quantum-toolkit/core#1237
File: mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Planner.h:202-214
Timestamp: 2025-10-07T15:58:19.247Z
Learning: In the QMAP routing algorithm (mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Planner.h), the heuristic function h() intentionally uses a non-admissible heuristic that sums per-gate shortest-path distances. This is a deliberate design choice from the QMAP paper, where admissibility is dropped because locally optimal solutions can negatively affect the overall routing quality. This approach prioritizes global solution quality over guaranteed local optimality.
Applied to files:
mlir/test/Dialect/MQTOpt/Transforms/Transpilation/astar-routing.mlirmlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Scheduler.hmlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingPass.cppmlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Router.h
📚 Learning: 2025-10-07T15:30:42.946Z
Learnt from: MatthiasReumann
PR: munich-quantum-toolkit/core#1237
File: mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Layout.h:219-231
Timestamp: 2025-10-07T15:30:42.946Z
Learning: In the Layout class for MLIR quantum routing (mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Layout.h), the swap method intentionally does NOT swap the hw fields in QubitInfo. This is correct because SSA values represent quantum states at fixed hardware locations, and only their program index associations change during a SWAP gate. The hw field indicates where an SSA value physically resides and remains constant.
Applied to files:
mlir/test/Dialect/MQTOpt/Transforms/Transpilation/astar-routing.mlirmlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/PlacementPass.cppmlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Scheduler.hmlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Layout.hmlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingPass.cppmlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Common.hmlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Router.h
📚 Learning: 2025-10-09T13:28:29.237Z
Learnt from: DRovara
PR: munich-quantum-toolkit/core#1108
File: mlir/lib/Dialect/MQTOpt/Transforms/DeadGateEliminationPattern.cpp:42-45
Timestamp: 2025-10-09T13:28:29.237Z
Learning: In the MQTOpt MLIR dialect, linear types enforce single-use semantics where each qubit value can only be consumed once, preventing duplicate deallocations and making RAUW operations safe when replacing output qubits with corresponding input qubits in transformation patterns.
Applied to files:
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/PlacementPass.cppmlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Scheduler.hmlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Layout.hmlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Common.h
📚 Learning: 2025-10-09T13:13:51.224Z
Learnt from: DRovara
PR: munich-quantum-toolkit/core#1108
File: mlir/lib/Dialect/MQTOpt/Transforms/ReplaceBasisStateControlsWithIfPattern.cpp:171-180
Timestamp: 2025-10-09T13:13:51.224Z
Learning: In MQT Core MLIR, UnitaryInterface operations guarantee 1-1 correspondence between input and output qubits in the same order. When cloning or modifying unitary operations (e.g., removing controls), this correspondence is maintained by construction, so yielding getAllInQubits() in else-branches matches the result types from the operation's outputs.
Applied to files:
mlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/PlacementPass.cppmlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Scheduler.hmlir/lib/Dialect/MQTOpt/Transforms/Transpilation/Common.cppmlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Architecture.hmlir/lib/Dialect/MQTOpt/Transforms/Transpilation/sc/RoutingPass.cppmlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Common.h
📚 Learning: 2025-10-09T13:25:36.887Z
Learnt from: DRovara
PR: munich-quantum-toolkit/core#1108
File: mlir/lib/Dialect/MQTOpt/Transforms/ReuseQubitsPattern.cpp:98-100
Timestamp: 2025-10-09T13:25:36.887Z
Learning: In MLIR code, when traversing parent operations to find a common block between two operations where one uses the result of another, explicit bounds checking is not necessary. MLIR's SSA properties and scope locality guarantees ensure that operations using results must be in compatible scopes and will always share a common ancestor in the operation hierarchy.
Applied to files:
mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Scheduler.h
🔇 Additional comments (1)
mlir/include/mlir/Dialect/MQTOpt/Transforms/Passes.td (1)
125-127: msTime removal is correct and complete across the codebase.Verification confirms:
- No
msTimereferences exist in any MQTOpt implementation filesnumSwapsstatistic is properly defined in RoutingPassSC and actively used in RoutingPass.cpp (constructor, increment at line 207, member at line 218)- PlacementPassSC defines no statistics (as expected)
- Code is consistent with the .td definitions
The change is sound. Consider updating the project changelog or upgrade guide to document that users should use MLIR's
-mlir-timingflag for pass timing measurements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
mlir/test/Dialect/MQTOpt/Transforms/Transpilation/basics.mlir(8 hunks)mlir/test/Dialect/MQTOpt/Transforms/Transpilation/grover_5.mlir(1 hunks)mlir/test/Dialect/MQTOpt/Transforms/Transpilation/naive-routing.mlir(0 hunks)mlir/test/Dialect/MQTOpt/Transforms/Transpilation/routing-placement.mlir(1 hunks)
💤 Files with no reviewable changes (1)
- mlir/test/Dialect/MQTOpt/Transforms/Transpilation/naive-routing.mlir
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: MatthiasReumann
PR: munich-quantum-toolkit/core#1237
File: mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Scheduler.h:72-140
Timestamp: 2025-10-09T04:30:29.071Z
Learning: In the CrawlScheduler (mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Scheduler.h), the persistent `layoutCopy` is updated across all lookahead layers via `remapQubitValue` calls. After each two-qubit gate is scheduled in a layer, its input qubits are remapped to output qubits, ensuring the next layer's crawl starts from those outputs. This progressive remapping through SSA values prevents the same operation from being scheduled in multiple lookahead layers.
Learnt from: MatthiasReumann
PR: munich-quantum-toolkit/core#1237
File: mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Layout.h:219-231
Timestamp: 2025-10-07T15:30:42.946Z
Learning: In the Layout class for MLIR quantum routing (mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Layout.h), the swap method intentionally does NOT swap the hw fields in QubitInfo. This is correct because SSA values represent quantum states at fixed hardware locations, and only their program index associations change during a SWAP gate. The hw field indicates where an SSA value physically resides and remains constant.
📚 Learning: 2025-10-09T13:20:11.483Z
Learnt from: DRovara
PR: munich-quantum-toolkit/core#1108
File: mlir/test/Dialect/MQTOpt/Transforms/lift-measurements.mlir:269-288
Timestamp: 2025-10-09T13:20:11.483Z
Learning: In the MQT MLIR dialect, the `rz` gate should not be included in the `DIAGONAL_GATES` set for the `ReplaceBasisStateControlsWithIfPattern` because its operator matrix does not have the required shape | 1 0 | / | 0 x | for the targets-as-controls optimization. It is only included in `LiftMeasurementsAboveGatesPatterns` where the matrix structure requirement differs.
Applied to files:
mlir/test/Dialect/MQTOpt/Transforms/Transpilation/grover_5.mlirmlir/test/Dialect/MQTOpt/Transforms/Transpilation/basics.mlirmlir/test/Dialect/MQTOpt/Transforms/Transpilation/routing-placement.mlir
📚 Learning: 2025-10-07T15:30:42.946Z
Learnt from: MatthiasReumann
PR: munich-quantum-toolkit/core#1237
File: mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Layout.h:219-231
Timestamp: 2025-10-07T15:30:42.946Z
Learning: In the Layout class for MLIR quantum routing (mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Layout.h), the swap method intentionally does NOT swap the hw fields in QubitInfo. This is correct because SSA values represent quantum states at fixed hardware locations, and only their program index associations change during a SWAP gate. The hw field indicates where an SSA value physically resides and remains constant.
Applied to files:
mlir/test/Dialect/MQTOpt/Transforms/Transpilation/grover_5.mlir
📚 Learning: 2025-10-09T13:28:29.237Z
Learnt from: DRovara
PR: munich-quantum-toolkit/core#1108
File: mlir/lib/Dialect/MQTOpt/Transforms/DeadGateEliminationPattern.cpp:42-45
Timestamp: 2025-10-09T13:28:29.237Z
Learning: In the MQTOpt MLIR dialect, linear types enforce single-use semantics where each qubit value can only be consumed once, preventing duplicate deallocations and making RAUW operations safe when replacing output qubits with corresponding input qubits in transformation patterns.
Applied to files:
mlir/test/Dialect/MQTOpt/Transforms/Transpilation/grover_5.mlir
📚 Learning: 2025-10-09T13:13:51.224Z
Learnt from: DRovara
PR: munich-quantum-toolkit/core#1108
File: mlir/lib/Dialect/MQTOpt/Transforms/ReplaceBasisStateControlsWithIfPattern.cpp:171-180
Timestamp: 2025-10-09T13:13:51.224Z
Learning: In MQT Core MLIR, UnitaryInterface operations guarantee 1-1 correspondence between input and output qubits in the same order. When cloning or modifying unitary operations (e.g., removing controls), this correspondence is maintained by construction, so yielding getAllInQubits() in else-branches matches the result types from the operation's outputs.
Applied to files:
mlir/test/Dialect/MQTOpt/Transforms/Transpilation/grover_5.mlir
📚 Learning: 2025-10-07T15:58:19.247Z
Learnt from: MatthiasReumann
PR: munich-quantum-toolkit/core#1237
File: mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Planner.h:202-214
Timestamp: 2025-10-07T15:58:19.247Z
Learning: In the QMAP routing algorithm (mlir/include/mlir/Dialect/MQTOpt/Transforms/Transpilation/Planner.h), the heuristic function h() intentionally uses a non-admissible heuristic that sums per-gate shortest-path distances. This is a deliberate design choice from the QMAP paper, where admissibility is dropped because locally optimal solutions can negatively affect the overall routing quality. This approach prioritizes global solution quality over guaranteed local optimality.
Applied to files:
mlir/test/Dialect/MQTOpt/Transforms/Transpilation/basics.mlir
🔇 Additional comments (6)
mlir/test/Dialect/MQTOpt/Transforms/Transpilation/routing-placement.mlir (1)
9-9: Verify whether placement-only validation catches qubit limit errors, or restore routing verification.The routing and routing verification passes have been removed from this test, reducing coverage. While other files (
basics.mlir,grover_5.mlir) contain comprehensive routing tests, they don't test error cases like qubit allocation limits.Concerns:
- Qubit limit errors are typically caught during routing, not placement. Placement maps logical qubits to physical ones; routing validates those mappings against architecture constraints. Removing
route-scandverify-routing-scmay prevent this error from being caught.- Filename mismatch: The file is named
routing-placement.mlirbut now tests only placement.Recommendations:
- Confirm that
placement-sc="strategy=identity"alone still catches the "requires one too many qubits" error on line 22. If not, restore the routing pass and verification.- If placement alone is sufficient, rename the file to
placement-errors.mliror similar to reflect the actual scope.mlir/test/Dialect/MQTOpt/Transforms/Transpilation/basics.mlir (3)
11-12: LGTM! Good test coverage for both routing methods.Adding separate RUN commands for both naive and astar routing methods ensures that the algorithmic improvements work correctly while maintaining backward compatibility with the naive approach.
356-356: Clarify the semantic changes and consistency withentryBranching.The changes alter the quantum circuit semantics in the
entryAllfunction's branching section:
- Line 356:
ctrl→nctrl(negatively-controlled gate)- Line 361: controlled-X →
swapwith result operand reorderingHowever, the
entryBranchingfunction (lines 217-227) still usesctrlin both branches. Given that the comment on line 241 statesentryAllcontains "All of the above quantum computations in a single entry point", this inconsistency is potentially confusing.Could you clarify:
- Is
entryAllmeant to exactly duplicateentryBranchinglogic, or is it adding coverage for different gate types (nctrlandswap)?- Do both naive and astar routing methods correctly handle these different gate semantics, given both use the same function labels (lines 235-236)?
If the intent is to add test coverage for
nctrlandswapgates specifically, consider adding a comment documenting this deviation from theentryBranchingpattern.Also applies to: 361-361
15-16: LGTM! Consistent label structure for dual-method testing.The addition of both NAIVE-LABEL and ASTAR-LABEL for all test functions correctly enables verification that both routing methods handle the same test cases successfully.
Also applies to: 76-77, 108-109, 145-146, 195-196, 235-236, 372-373
mlir/test/Dialect/MQTOpt/Transforms/Transpilation/grover_5.mlir (2)
666-682: LGTM: Barrier and measurement structure is correct.The barrier operation correctly groups all final qubits before measurement, and the measurement + storage sequence properly handles all 5 qubits with correct indexing.
11-11: The-verify-diagnosticsflag usage is consistent with established test patterns across all routing transpilation tests.Verification shows that grover_5.mlir contains no diagnostic check directives (expected-error, expected-warning, etc.), which aligns with your observation. However, this same pattern is uniformly used across all similar routing tests in the Transpilation directory (basics.mlir, routing-placement.mlir, routing-verification.mlir). The file's comment explicitly states "the routing verifier pass ensures the validity of this program," indicating this design is intentional. The flag appears to be part of the established test infrastructure conventions for routing validation tests rather than a misuse of the diagnostic verification feature.
burgholzer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me 👍🏻
You might want to add this PR number to the Changelog entry for the QMAP addition.
Afterwards, feel free to hit merge here 🎉
Description
This PR aims to improve the total runtime and memory footprint of the A*-based Routing Algorithm.
Changes
ndepthcalculation to reduce footprint ofNodestruct.QubitIndex: [QubitIndex]map) reduces runtime ofneighboursOffromO(n)toO(1)ClosedMap: Maps previously visited layouts to their lowest search depth. Essentially: Don't revisit layouts that were discovered with a lower depth.getAll{In,Out}QubitsingetIns(),getOuts(), andisTwoQubitGate()to avoid creating temporary vectors.ParallelOpScheduler.ParallelOpScheduler.msTimestatistics: MLIR provides a-mlir-timingCLI flag which measures how long each pass took.Benchmarks
Options:
place{strategy=identity}, route{nlookahead=15 lambda=0.5}Note
I've removed the QFT benchmarks for now because A* frequently runs into troubles here. There should probably be some fallback mechanism when A* gets stuck. But I will leave that for a future PR.
Checklist:
Summary by CodeRabbit
Chores
Refactors
Tests
Documentation