-
Notifications
You must be signed in to change notification settings - Fork 55
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
Looping Behavior in Qibo SABRE #1396
Comments
Looping Behavior in Qibo SABREIntroductionWhen the SABRE router encounters a two-qubit gate that cannot be executed due to hardware constraints, it adds a sequence of SWAPs to make the two-qubit gate executable. SABRE generates candidate SWAPs and selects one based on a defined formula. This process is repeated until the two-qubit gate becomes executable. However, since SABRE is a heuristic algorithm, the process can sometimes get stuck in a loop. ProblemIn some cases, SABRE adds a repeated sequence of similar SWAPs. For example, a 10-qubit circuit with the following connectivity: qubit_array = [(7, 2), (6, 0), (5, 6), (4, 8), (3, 5), (9, 1)] is routed with 156 SWAPs using the Trivial placer and SABRE router. (After modification, the number of SWAPs is reduced to 17.) This example is illustrated in the notebook. SolutionTo solve this, the number of SWAPs is managed until every routing is made. Notebook ...
self.circuit.update(best_candidate) # SWAP is added
self._added_swaps += 1
...
...
if self._added_swaps > 1.5 * longest_path: # threshold is arbitrary
self.circuit = deepcopy(self._saved_circuit)
self._route_to_nearest_gate()
... If TestsWhen routing 30 random CZ circuits with the Random placer and original SABRE router, there are cases where more than 100 SWAPs are added. After modification, no such cases were found. Discussion
|
Thanks @csookim for this analysis and tests. Let me invite @Simone-Bordoni to have a look and confirm your findings, meanwhile please feel free to open a PR with the suggested fix in this repository. |
There is a bug in the SABRE algorithm, and I modified
router.py
to fix it. Is it okay to make a PR? My code is in a forked repo. Below is the explanation.The text was updated successfully, but these errors were encountered: