-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
Environment
- Qiskit Terra version: 0.24.0
- Python version: 3.10.8
- Operating system: IBM Quantum Lab
What is happening?
A QuantumCircuit is producing an invalid OpenQASM 2.0 output when calling .qasm()
method. There is a definition of a subroutine calling itself.
How can we reproduce the issue?
import random
from qiskit.quantum_info import Statevector
from qiskit.algorithms import AmplificationProblem, Grover
secret = random.randint(0, 7) # the owner is randomly picked
secret_string = format(secret, "03b") # format the owner in 3-bit string
oracle = Statevector.from_label(secret_string) # let the oracle know the owner
problem = AmplificationProblem(oracle, is_good_state=secret_string)
grover = Grover(iterations=1)
circuit = grover.construct_circuit(problem)
circuit.qasm()
Invalid OpenQASM output:
OPENQASM 2.0;
include "qelib1.inc";
gate circuit_136 q0,q1,q2 { rz(pi/4) q0; cx q1,q0; rz(pi/4) q0; cx q2,q0; rz(pi/4) q0; cx q1,q0; rz(pi/4) q0; cx q2,q0; }
gate ucrz(param0,param1,param2,param3) q0,q1,q2 { circuit_136 q0,q1,q2; }
gate circuit_140 q0,q1 { rz(-pi/4) q0; cx q1,q0; rz(-pi/4) q0; cx q1,q0; }
gate ucrz_139619649377696(param0,param1) q0,q1 { circuit_140 q0,q1; }
gate circuit_144 q0 { rz(-pi/4) q0; }
gate ucrz_139619649377840(param0) q0 { circuit_144 q0; }
gate gate_Diagonal q0,q1,q2 { ucrz(pi,0,0,0) q0,q1,q2; ucrz_139619649377696(-pi/2,0) q1,q2; ucrz_139619649377840(-pi/4) q2; }
gate gate_Q q0,q1,q2 { gate_Q q0,q1,q2; }
qreg q[3];
h q[0];
h q[1];
h q[2];
gate_Q q[0],q[1],q[2];
gate gate_Q q0,q1,q2 { gate_Q q0,q1,q2; }
<- this is the error line
What should happen?
It shouldn't produce a gate subroutine calling itself.
Any suggestions?
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working