Skip to content

TranspilerError occurs when transpiling a circuit with for_loop #14338

@YaegakiY

Description

@YaegakiY

Environment

  • Qiskit version: 2.0.0
  • Python version: 3.13.2
  • Operating system: Windows 11, Version 24H2, Build 26100

What is happening?

When transpiling a circuit that uses an for_loop conditional statement, a TranspilerError occurs.

qiskit.transpiler.exceptions.TranspilerError: 'Unable to translate the operations in the circuit: ["for_loop", "clifford"] to the backend\'s (or manually specified) target basis: {"mcy", "sxdg", "rzx", "mcx", "unitary", "switch_case", "delay", "initialize", "h", "cswap", "mcx_gray", "x", "reset", "u2", "crx", "diagonal", "set_stabilizer", "mcp", "cu2", "save_density_matrix", "mcu3", "mcrz", "pauli", "mcsx", "cu3", "set_density_matrix", "set_statevector", "z", "save_expval_var", "save_stabilizer", "crz", "cp", "ry", "save_state", "measure", "save_matrix_product_state", "qerror_loc", "save_amplitudes", "save_superop", "save_expval", "cy", "save_statevector", "tdg", "mcz", "ccx", "cz", "cu", "u3", "continue_loop", "for_loop", "t", "mcu1", "quantum_channel", "save_statevector_dict", "roerror", "ecr", "cu1", "if_else", "s", "cry", "save_unitary", "cx", "mcphase", "ccz", "superop", "store", "mcrx", "u1", "set_unitary", "save_clifford", "rxx", "set_matrix_product_state", "rz", "mcu", "mcry", "u", "break_loop", "rx", "sx", "save_amplitudes_sq", "sdg", "csx", "ryy", "p", "id", "mcu2", "save_probabilities", "multiplexer", "save_probabilities_dict", "while_loop", "kraus", "r", "set_superop", "y", "rzz", "swap", "mcswap", "mcr", "barrier", "snapshot"}. This likely means the target basis is not universal or there are additional equivalence rules needed in the EquivalenceLibrary being used. For more details on this error see: https://docs.quantum.ibm.com/api/qiskit/qiskit.transpiler.passes. BasisTranslator#translation-errors'

How can we reproduce the issue?

Minimal Working Example:

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, transpile
from qiskit_aer import Aer
from qiskit.transpiler.passes import *
from qiskit.transpiler import PassManager

qreg = QuantumRegister(5)
creg = ClassicalRegister(5)
qc = QuantumCircuit(qreg, creg)

with qc.for_loop(range(5)) as i:
	qc.cx(4, 3)
	qc.cz(0, 4)

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

simulator = Aer.get_backend("aer_simulator")

p = PassManager(CollectCliffords())
qc = p.run(qc)

compiled_circuit = transpile(qc, backend = simulator, optimization_level = 3, routing_method = "sabre", layout_method = "noise_adaptive", approximation_degree = 1 )
job = simulator.run(compiled_circuit, shots=10000)
result = job.result().get_counts()
print(result)

What should happen?

The circuit should be successfully transpiled and executed.

Any suggestions?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions