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

dynamic circuit fail to transpile without a backend #11906

Closed
1ucian0 opened this issue Feb 28, 2024 · 3 comments · Fixed by #11907
Closed

dynamic circuit fail to transpile without a backend #11906

1ucian0 opened this issue Feb 28, 2024 · 3 comments · Fixed by #11907
Assignees
Labels
bug Something isn't working mod: transpiler Issues and PRs related to Transpiler

Comments

@1ucian0
Copy link
Member

1ucian0 commented Feb 28, 2024

Environment

  • Qiskit version: 1.1.0.dev0+afdd1b7
  • Python version: 3.11.7
  • Operating system: MacOS

What is happening?

When transpiling a dynamic circuit without any backend, it fails with The control-flow construct 'if_else' is not supported by the backend.
This seems to be the backendless version of Qiskit/qiskit-ibm-runtime#1253

How can we reproduce the issue?

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, transpile

q = QuantumRegister(1)
c = ClassicalRegister(1)
circuit = QuantumCircuit(q, c)
circuit.h(q)
circuit.measure(q, c)
with circuit.if_test((c, 1)):
    circuit.x(q)

transpile(circuit)
TranspilerError: "The control-flow construct 'if_else' is not supported by the backend."

What should happen?

transpilation should work with dynamic circuits, just like the non-dynamic circuits:

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, transpile

q = QuantumRegister(1)
c = ClassicalRegister(1)
circuit = QuantumCircuit(q, c)
circuit.h(q)
circuit.measure(q, c)

transpiled = transpile(circuit)
transpiled.draw('mpl')

Any suggestions?

No response

@jakelishman
Copy link
Member

Whoops, looks like an oversight in the control-flow error check. Something like #11907 should do the job.

@jakelishman jakelishman added the mod: transpiler Issues and PRs related to Transpiler label Feb 28, 2024
@jakelishman
Copy link
Member

jakelishman commented Feb 28, 2024

Fwiw, the linked issue doesn't appear to be a problem with Terra (though could be related via #11877) - it seems like there are/were some backends in the IBM Runtime that weren't reporting their support for control-flow operations.

@1ucian0
Copy link
Member Author

1ucian0 commented Feb 28, 2024

wow! that's a quick fix! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mod: transpiler Issues and PRs related to Transpiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants