Skip to content
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

Track Sabre decay heuristic on physical qubits #10756

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions crates/accelerate/src/sabre_swap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ fn swap_map_trial(
qubits_decay.fill(1.);
num_search_steps = 0;
} else {
qubits_decay[best_swap[0].index()] += DECAY_RATE;
qubits_decay[best_swap[1].index()] += DECAY_RATE;
qubits_decay[best_swap[0].to_phys(&layout).index()] += DECAY_RATE;
qubits_decay[best_swap[1].to_phys(&layout).index()] += DECAY_RATE;
}
}
// If we exceeded the number of allowed attempts without successfully routing a node, we
Expand Down Expand Up @@ -717,7 +717,8 @@ fn choose_best_swap(
+ EXTENDED_SET_WEIGHT * extended_set.score(swap, layout, dist)
}
Heuristic::Decay => {
qubits_decay[swap[0].index()].max(qubits_decay[swap[1].index()])
qubits_decay[swap[0].to_phys(layout).index()]
.max(qubits_decay[swap[1].to_phys(layout).index()])
* (absolute_score
+ layer.score(swap, layout, dist)
+ EXTENDED_SET_WEIGHT * extended_set.score(swap, layout, dist))
Expand Down
6 changes: 6 additions & 0 deletions releasenotes/notes/sabre-decay-physical-ad2f470cd45d69f3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
The ``"decay"`` heuristic of :class:`.SabreSwap` and :class:`.SabreLayout` now tracks the depth
correctly on physical qubits rather than mistakenly tracking the "depth" of swaps on virtual
qubits.
2 changes: 1 addition & 1 deletion test/python/transpiler/test_sabre_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_5q_circuit_20q_coupling(self):
pass_.run(dag)

layout = pass_.property_set["layout"]
self.assertEqual([layout[q] for q in circuit.qubits], [11, 10, 16, 5, 17])
self.assertEqual([layout[q] for q in circuit.qubits], [16, 7, 11, 12, 13])

def test_6q_circuit_20q_coupling(self):
"""Test finds layout for 6q circuit on 20q device."""
Expand Down