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

LookaheadSwap mapper hangs in some cases #2171

Closed
kdk opened this issue Apr 22, 2019 · 1 comment · Fixed by #4112
Closed

LookaheadSwap mapper hangs in some cases #2171

kdk opened this issue Apr 22, 2019 · 1 comment · Fixed by #4112
Labels
bug Something isn't working
Milestone

Comments

@kdk
Copy link
Member

kdk commented Apr 22, 2019

The LookaheadSwap mapper will, for some input circuits and coupling maps, loop infinitely while attempting to build a mapping.

The lookahead algorithm can end up in an effective local minimum where 1) no depth-1 swaps lead to an improvement in score over the current layout, and 2) the swaps required to advance the circuit fall outside of the search width pruning (maybe depending on the order returned by coupling.get_edges()).

The LookaheadSwap has no priority queue or backtracking mechanism beyond the size of search depth, so it will continue to examine the first set of swaps indefinitely. An iteration limit would be an easy way to likely detect and alert users to these cases. Alternately, the algorithm could choose to not prune in cases where there is no clear ranking of swaps, or randomly select a subset to consider further.

e.g.

>>> import qiskit as qk
>>> from qiskit.test.mock import FakeMelbourne
>>> from qiskit.transpiler import CouplingMap
>>> qr = qk.QuantumRegister(14, 'q')
>>> qc = qk.QuantumCircuit(qr)
>>> qc.cx(qr[0], qr[13])
>>> qc.cx(qr[1], qr[13])
>>> qc.cx(qr[1], qr[0])
>>> qc.cx(qr[13], qr[1])
>>> qc.cx(qr[6], qr[7])
>>> qc.cx(qr[8], qr[7])
>>> qc.cx(qr[8], qr[6])
>>> qc.cx(qr[7], qr[8])
>>> qc.cx(qr[0], qr[13])
>>> qc.cx(qr[1], qr[0])
>>> qc.cx(qr[13], qr[1])
>>> qc.cx(qr[0], qr[1])
>>> dag = qk.converters.circuit_to_dag(qc)
>>> cm = CouplingMap(FakeMelbourne().configuration().coupling_map)
>>> qk.transpiler.passes.LookaheadSwap(cm).run(dag)
...
KeyboardInterrupt
>>> qk.transpiler.passes.BasicSwap(cm).run(dag)
<qiskit.dagcircuit.dagcircuit.DAGCircuit object at 0x1220bc668>
>>> qk.transpiler.passes.LegacySwap(cm).run(dag)
<qiskit.dagcircuit.dagcircuit.DAGCircuit object at 0x1220cd2b0>
>>> qk.transpiler.passes.StochasticSwap(cm).run(dag)
<qiskit.dagcircuit.dagcircuit.DAGCircuit object at 0x1220c0ba8>
@kdk kdk added the bug Something isn't working label Apr 22, 2019
@kdk kdk added this to the 0.8 milestone Apr 22, 2019
@ajavadia ajavadia modified the milestones: 0.8, 0.9 May 2, 2019
@ajavadia ajavadia modified the milestones: 0.9, 0.10 Jul 22, 2019
@mtreinish mtreinish modified the milestones: 0.10, 0.11 Nov 7, 2019
@1ucian0
Copy link
Member

1ucian0 commented Nov 13, 2019

priority: medium because LookaheadSwap is not in any of the preset passmanagers...

@mtreinish mtreinish modified the milestones: 0.11, 0.12 Dec 5, 2019
@kdk kdk removed this from the 0.12 milestone Dec 10, 2019
mtreinish pushed a commit to Qiskit/qiskit-metapackage that referenced this issue Mar 13, 2020
The lookahead swap mapping passes timeout consistently and have generated no data (likely due to Qiskit/qiskit#2171 ) but cost roughly an hour of benchmarking runtime per terra commit.

This commit disables these benchmarks while the problems are investigated.
@kdk kdk added this to the 0.13 milestone Apr 7, 2020
@mergify mergify bot closed this as completed in #4112 Apr 9, 2020
jakelishman pushed a commit to jakelishman/qiskit-terra that referenced this issue Aug 1, 2023
…it-metapackage#845)

The lookahead swap mapping passes timeout consistently and have generated no data (likely due to Qiskit#2171 ) but cost roughly an hour of benchmarking runtime per terra commit.

This commit disables these benchmarks while the problems are investigated.
jakelishman pushed a commit to jakelishman/qiskit-terra that referenced this issue Aug 11, 2023
…it-metapackage#845)

The lookahead swap mapping passes timeout consistently and have generated no data (likely due to Qiskit#2171 ) but cost roughly an hour of benchmarking runtime per terra commit.

This commit disables these benchmarks while the problems are investigated.
SamD-1998 pushed a commit to SamD-1998/qiskit-terra that referenced this issue Sep 7, 2023
…it-metapackage#845)

The lookahead swap mapping passes timeout consistently and have generated no data (likely due to Qiskit#2171 ) but cost roughly an hour of benchmarking runtime per terra commit.

This commit disables these benchmarks while the problems are investigated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants