I am trying to run my circuit which is the following on a simulator. However, when I want to execute this on almost all the simulators the following error pops up:

"The control-flow construct 'switch_case' is not supported by the backend.". I will let you informed as soon as possible"

My code is:

from qiskit import QuantumCircuit, transpile
from qiskit.tools.jupyter import *
from qiskit.visualization import *
from ibm_quantum_widgets import *
from qiskit import *
from qiskit_ibm_provider import IBMProvider
from qiskit import QuantumCircuit, execute,  Aer
from qiskit.result import marginal_counts
from qiskit.providers.ibmq.job import job_monitor
from qiskit.tools.visualization import plot_histogram
from qiskit_ibm_runtime import QiskitRuntimeService, Sampler, Estimator, Session, Options
from math import pi

service = QiskitRuntimeService(channel="ibm_quantum")
provider = IBMProvider()
backend = provider.get_backend('ibmq_qasm_simulator')

from qiskit.circuit import QuantumCircuit, ClassicalRegister, QuantumRegister
qreg = QuantumRegister(4)
creg = ClassicalRegister(6)
qc = QuantumCircuit(qreg, creg)
qc.measure([0, 1, 2], [0, 1, 2])

with qc.switch(creg) as case:
    with case(7):

qc.measure(qreg[3], creg[3])

job = execute(qc, backend = backend, shots = 1000)
results = job.result()

1 Answer 1


The latest version of Qiskit Aer (version 0.13) supports SwitchCaseOp. So, if it's OK to run your circuit locally, you can use Aer simulators:

from qiskit_aer import AerSimulator

backend = AerSimulator()
qc = transpile(qc, backend=backend)
job = backend.run(qc)
results = job.result()
  • $\begingroup$ it still comes up with the same error: The control-flow construct 'switch_case' is not supported by the backend." $\endgroup$ Nov 20 at 20:45
  • $\begingroup$ Do you have Qiskit Aer version 0.13? $\endgroup$ Nov 21 at 3:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.