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

Transpile fails when multiple circuits with UnitaryGate or DiagonalGate #12953

Open
doichanj opened this issue Aug 14, 2024 · 6 comments · May be fixed by #12957
Open

Transpile fails when multiple circuits with UnitaryGate or DiagonalGate #12953

doichanj opened this issue Aug 14, 2024 · 6 comments · May be fixed by #12957
Assignees
Labels
bug Something isn't working mod: transpiler Issues and PRs related to Transpiler
Milestone

Comments

@doichanj
Copy link
Contributor

doichanj commented Aug 14, 2024

Environment

  • **Qiskit version1.3:
  • Python version:
  • Operating system:

What is happening?

Transpile fails when the list of input circuits contains UnitaryGate or DiagonalGate with error as following:

pyo3_runtime.PanicException: internal error: entered unreachable code: 'num_qubits' property is reserved for normal operations only.

And single circuit input with UnitaryGate or DiagonalGate

see https://github.com/Qiskit/qiskit-aer/actions/runs/10381689813/job/28743530145

How can we reproduce the issue?

from qiskit_aer import AerSimulator
from qiskit import QuantumCircuit, transpile
from qiskit.quantum_info.random import random_unitary

backend = AerSimulator(method="statevector", device="CPU")

qc1 = QuantumCircuit(2)
qc1.unitary(random_unitary(4, seed=123), [0, 1])
# using followings instead of unitary is OK
#qc1.h(0)
#qc1.cx(0, 1)
qc1.measure_all()

qc2 = QuantumCircuit(2)
qc2.unitary(random_unitary(4, seed=123), [0, 1])
# using followings instead of unitary is OK
#qc2.h(1)
#qc2.cx(1, 0)
qc2.measure_all()

circuits = [qc1, qc2]
# circuits = [qc1]   this is also OK
circuits = transpile(circuits, backend)

result = backend.run(circuits).result()
print(result)

What should happen?

No error in transpile

Any suggestions?

No response

@jakelishman
Copy link
Member

@raynelfss: this message is coming from the Target port - could you have a look into it?

Doi-san: I think you might be testing against Qiskit's main branch, rather than 1.2.0rc1? The error message in question isn't part of the 1.2 release - it'll be in 1.3, though (it's #12292, and was the point we branched 1.2 away).

@jakelishman jakelishman added the mod: transpiler Issues and PRs related to Transpiler label Aug 14, 2024
@doichanj
Copy link
Contributor Author

yes, this error only occurs on main branch

@jakelishman jakelishman added this to the 1.3 beta milestone Aug 14, 2024
@raynelfss
Copy link
Contributor

This error occurs when attempting to get the num_qubits property from a variadic operation. I can change this behavior to return None instead of panicking. As Python would usually just return a property instance.

@raynelfss
Copy link
Contributor

Hello @doichanj, what operating system are you on at the moment? The code snippet you provided doesn't seem to replicate the issue for me even when using the latest main in qiskit-aer.

@raynelfss raynelfss linked a pull request Aug 14, 2024 that will close this issue
@doichanj
Copy link
Contributor Author

I'm using Ubuntu 22.04.4 for script above.
And for the test on github (https://github.com/Qiskit/qiskit-aer/actions/runs/10381689813/job/28743530145) also on Ubuntu 22.04.4 and uses combinations of the latest main branches of Qiskit and Qiskit Aer

@raynelfss
Copy link
Contributor

Hello, I was finally able to replicate the issue on my end. But I had to go all the way back to the first commit that introduced Target in rust (898fdec), and had to also turn on QISKIT_PARALLEL. The error does not happen on newer versions of Qiskit or qiskit-aer (because of Qiskit/qiskit-aer@44bd7eb).

The issue is fixed by #12957 and I'm currently adding a test-case based on what you sent, but since I can't determine what specific circumstances trigger this (due to serialization) it will take more time and thorough testing.

@mtreinish mtreinish modified the milestones: 1.3 beta, 1.3.0 Sep 4, 2024
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.

4 participants