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

Transpiler is crashed when transpiling 2q gates on non-connected qubit pairs #5473

Closed
nkanazawa1989 opened this issue Dec 7, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@nkanazawa1989
Copy link
Contributor

Information

  • Qiskit Terra version: master
  • Python version: 3.7
  • Operating system: 18.04.3 LTS

What is the current behavior?

Transpiler cannot handle coupling map correctly.

Steps to reproduce the problem

from qiskit import transpile, QuantumCircuit
from qiskit.test.mock import FakeMontreal
from qiskit import quantum_info as qi

backend = FakeMontreal()

qc = QuantumCircuit(4)
qc.append(qi.random_unitary(4).to_instruction(), [0,1])
transpile(qc, backend) # this is ok

qc = QuantumCircuit(4)
qc.append(qi.random_unitary(4).to_instruction(), [0,3])
transpile(qc, backend) # see error code
...
~/qiskit/qiskit-terra/qiskit/transpiler/passes/routing/stochastic_swap.py in _layer_permutation(self, layer_partition, layout, qubit_subset, coupling, trials)
    195                                                                      int_gates, cdist2,
    196                                                                      cdist, edges, scale,
--> 197                                                                      self.rng)
    198 
    199             logger.debug("layer_permutation: final distance for this trial = %s", dist)

~/qiskit/qiskit-terra/qiskit/transpiler/passes/routing/cython/stochastic_swap/swap_trial.pyx in qiskit.transpiler.passes.routing.cython.stochastic_swap.swap_trial.swap_trial()

~/qiskit/qiskit-terra/qiskit/transpiler/passes/routing/cython/stochastic_swap/swap_trial.cpython-37m-x86_64-linux-gnu.so in View.MemoryView.memoryview_cwrapper()

~/qiskit/qiskit-terra/qiskit/transpiler/passes/routing/cython/stochastic_swap/swap_trial.cpython-37m-x86_64-linux-gnu.so in View.MemoryView.memoryview.__cinit__()

ValueError: buffer source array is read-only

What is the expected behavior?

Suggested solutions

@nkanazawa1989 nkanazawa1989 added the bug Something isn't working label Dec 7, 2020
@nkanazawa1989
Copy link
Contributor Author

perhaps we need to update unittest too

@nkanazawa1989
Copy link
Contributor Author

sorry I solved this by myself. I just pulled the master but actually needed to compile cython again.

@mtreinish
Copy link
Member

Yeah, #5183 updated the cython code (it was necessary because the distance matrix is now returned directly from retworkx but is read only because it lives in the rust heap and not python's so the matrix parameter in cython is const now), if you have a local build from source whenever the cython source changes you'll have to rebuild it. Fortunately the cython code doesn't generally change to frequently so this shouldn't come up too often.

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

No branches or pull requests

2 participants