Add BFS initial placement to SABRE qubit-mapping pass#4292
Open
taalexander wants to merge 1 commit intoNVIDIA:mainfrom
Open
Add BFS initial placement to SABRE qubit-mapping pass#4292taalexander wants to merge 1 commit intoNVIDIA:mainfrom
taalexander wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
Replace identity placement with BFS-from-highest-degree-node as the default initial placement strategy. This places circuit qubits on the most centrally-connected device positions, improving routing quality on irregular topologies (heavy-hex, star). Add a 'placement' pass option (identity|bfs, default bfs) so users can select the strategy. Existing FileCheck tests updated to use placement=identity for backward compatibility. Addresses NVIDIA#4289. Signed-off-by: Thomas Alexander <talexander@nvidia.com>
68eb846 to
0378a34
Compare
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
atgeller
reviewed
Apr 10, 2026
| visited[bestNode] = true; | ||
| while (!queue.empty()) { | ||
| SmallVector<unsigned> nextQueue; | ||
| for (unsigned node : queue) { |
Collaborator
There was a problem hiding this comment.
This BFS implementation looks a little wonky to me. I would expect it to go one node at a time on the queue, adding neighbors. That way we don't need a separate queue to avoid writes to the first queue through loop iterations. Maybe it's more optimal, but it looks a little funny and overly complex to me.
atgeller
reviewed
Apr 10, 2026
| return | ||
| } | ||
|
|
||
| // Verify star(5,0) BFS produces valid mapped output. |
Collaborator
There was a problem hiding this comment.
Doesn't look like we have any tests to make sure that the BFS strategy actually performs better than identity?
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Note: This is an experiment of having an agent prepare a fix for #4289 with no intervention (ie. we passed it the issue and then hit enter for all stages of speckit) following the spec-kit workflow I have been using. This was done as a part of a live tutorial. We agreed to use the output of this PR as an oppurtunity to review the PR comparing human led review with review agents.
Summary
❯ - Add topology-aware BFS placement as the default initial placement strategy for the SABRE
qubit-mapping pass, replacing identity placement
placementpass option (identity|bfs, defaultbfs) to allow users to select thestrategy
qubit routing
Context
Addresses #4289. Investigation found that the routing engine already supports full-device
routing through unmapped (auxiliary) qubits. The root cause of poor routing quality on irregular
topologies is identity placement (
v_i -> p_i), which ignores device topology structure.On heavy-hex and star topologies, identity placement puts circuit qubits on low-degree
peripheral nodes. BFS placement starts from the highest-degree node and assigns circuit qubits
to the most centrally-connected positions, giving the SABRE router a better starting point.
Changes
lib/Optimizer/Transforms/Mapping.cpp: AddedbfsPlacement()function (BFS fromhighest-degree node, O(V+E)), placement option wiring with validation for unknown values
include/cudaq/Optimizer/Transforms/Passes.td: Addedplacementoption toMappingFuncpasstest/Transforms/mapping_bfs_placement.qke: New test for BFS on star(5,0), path(5), grid(3,3)test/Transforms/mapping_aux_routing.qke: New test confirming auxiliary qubit routing works(star, path, single-qubit edge case)
placement=identityto preserve expected outputTest plan
mapping_unitaries.qkepasses with BFS default on path(10) via CircuitCheck (functionalcorrectness)
mapping_bfs_placement.qkeverifies BFS produces valid mapped output on star, path, andgrid topologies
mapping_aux_routing.qkeverifies auxiliary qubit allocation and N=M regression