# Which backends implement the if-else operation?

On which backends (Basic, AER, Simulation, IBMQ) is the qiskit.circuit.controlflow.if_else Operation implemented currently?

I want to create a circuit depending on qubit states, e.g.:  with circuit.if_test((qreg_c[cnt], 0)) as else_:

 #add instruction to circuit with else_: # insert another instruction to circuit 

Normal "circuit.draw()" operation works, but when I try to run it on "qasm_simulator" I get the following error: QiskitError: "Cannot unroll the circuit to the given basis, ['u1', 'u2', 'u3', 'rz', 'sx', 'x', 'cx', 'id', 'unitary']. Instruction if_else not found in equivalence library and no rule found to expand."

So, how can this be solved?

• Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
– Community Bot
Jan 10 at 12:21

That being said there is a general limitation around the classical control flow instruction in qiskit right now in that the transpiler doesn't know how to work with them yet. So you're not able to run them through the transpiler and pass them to an Aer backend like you normally would you'll have to build your circuit in instructions supported by the simulator and pass your circuit directly to the run() method on the backend
• It already works with the latest version of the aer simulator, you just can not transpile your circuit with if/else or loops in your circuit yet (which will be fixed in a future release). For example:  import qiskit from qiskit.providers.aer import AerSimulator qc = qiskit.QuantumCircuit(4, 4) qc.y(0) qc.h(qc.qubits[1:4]) qc.barrier() qc.measure(0, 0) with qc.if_test((0, 1)): qc.h(qc.qubits[1:4]) qc.measure(1, 1) qc.measure(2, 2) qc.measure(3, 3) job = AerSimulator(method="statevector").run(qc)  will work fine Jan 11 at 13:04