"Circuit is too deep" / results are garbage on real hardware
Circuit depth exceeds the hardware's coherence time. Superconducting qubits decohere in roughly 100 microseconds. A circuit with hundreds of gate layers takes longer than that to execute, so qubit state degrades before measurement completes.
Diagnose first
Check the depth of the circuit after transpilation, not before. The raw circuit depth is meaningless; what runs on the chip is the transpiled version, which can be much deeper due to SWAP insertion.
from qiskit import transpile
# Check depth before and after transpilation
print("Original depth:", qc.depth())
transpiled = transpile(qc, backend=backend, optimization_level=1)
print("Transpiled depth (opt 1):", transpiled.depth())
transpiled_opt = transpile(qc, backend=backend, optimization_level=3)
print("Transpiled depth (opt 3):", transpiled_opt.depth()) Fixes
- Use
optimization_level=3intranspile(). This applies Sabre routing and gate cancellation. Depth reductions of 30-60% are common. - Rewrite multi-qubit gates using only native gates (
cx,u,ecrdepending on backend). Each non-native gate decomposes into several native gates, multiplying depth. - Replace
CCX(Toffoli) gates with the 6-CNOT relative-phase variant where phase accuracy is not required. - Split long circuits into subcircuits and use mid-circuit measurement or classical feed-forward where the algorithm allows.