Skip to content
Tech Interview Prep
Technical interview guide

Quantum Error Correction, Noise & Decoherence

Why real qubits are noisy, the difference between physical and logical qubits, and how surface codes trade physical qubit count for error resilience.

Minutes to read
3
Practice MCQs
25
Interview Q&A
25
Edition
v3
Editorial status
Reviewed

Scope: IBM Quantum current QEC, noise, mitigation, and fault-tolerance guidance; surface-code and QEC literature reviewed 2026-09-04.

Interview Q&A

Treat each question like a live interview question: answer out loud first (structure, assumptions, tradeoffs), then open the model answer to spot gaps and rehearse a tighter follow-up.

Curated: · Written: · Reviewed:

25 questions

Q&A-1

What are the primary physical sources of noise and decoherence in physical qubits, and how are Markovian and non-Markovian noise processes distinguished in quantum error correction?

Answer

The 90-second answer

Physical qubit noise has two roots: uncontrolled coupling to the environment, and imperfect control. Environmentally you get energy relaxation: the qubit decays |1⟩ → |0⟩ at rate 1/T1, and dephasing, where the transition frequency wanders with no energy leaving the qubit. Control adds crosstalk and pulse errors. The Markovian/non-Markovian split is about memory. If the environment's correlation time is much shorter than the gate time, the noise is memoryless and the dynamics take Lindblad form. If the correlation time is comparable to or longer than the gate or a syndrome-extraction round, the environment remembers, information flows back into the qubit, and the decoder's assumption that syndrome outcomes are independent across rounds breaks.

Physical sources

PlatformRelaxation (T1) channelsDephasing (T2) channels
Superconducting transmondielectric loss at substrate/metal interfaces; quasiparticle tunneling across the Josephson junction; Purcell decay into the readout line1/f flux noise from unpaired surface spins in the SQUID loop; charge noise from trapped charges; drive phase noise
Trapped ionspontaneous emission from the laser-driven qubit transitionmagnetic-field noise; laser phase noise

Relaxation rate Γ1 = 1/T1. Dephasing obeys 1/T2 = 1/(2T1) + 1/T_phi. Worked example: T1 = 100 µs, T2 = 60 µs gives 1/T_phi = 1/60 − 1/200 = 0.0117 µs⁻¹, so T_phi ≈ 86 µs. Dephasing, not relaxation, is the limit here.

Control errors: residual ZZ coupling between neighbouring transmons, pulse over/under-rotation, off-resonant spillover.

Markovian vs non-Markovian

MarkovianNon-Markovian
Correlation timeτ_env ≪ t_gateτ_env ≳ t_gate or ≳ one syndrome round
GeneratorLindblad jump operators, CP-divisibletime-nonlocal master equation, not CP-divisible
Syndrome statisticsP(s_{t+1} | s_t) = P(s_{t+1})temporal clustering, P(s_{t+1} | s_t) ≠ P(s_{t+1})
Examplesspontaneous emission, white drive noise1/f flux noise, TLS switching, nuclear-spin bath

Worked trace

A two-level fluctuator near the qubit switches between two frequency offsets with a dwell time of ~1 ms. With a 1 µs gate and a 1 µs syndrome round, that is ~1000 rounds in one state. Suppose the bad offset makes a round fail with p_bad = 0.05 and the good offset with p_good = 0.001. Over 2000 rounds the observed defect counts are ~50 then ~1. A decoder that assumes one independent per-round probability uses the average p̄ = 0.0255 and assigns every space-time edge the same weight:

Python
import math
w = lambda p: math.log((1 - p) / p)
print(round(w(0.0255), 2), round(w(0.05), 2), round(w(0.001), 2))
# 3.64 2.94 6.91

The uniform prior prices a bad-dwell edge at 3.64 when it is really 2.94, so a long chain of defects during the dwell looks more expensive than it is and the matcher prefers a shorter, wrong explanation. During the good dwell it prices edges at 3.64 when they are really 6.91, so it invents errors that are not there.

Why it matters for QEC

MWPM assigns each space-time edge w = ln((1−p)/p) from an independent defect probability p. When a TLS shifts the qubit frequency over hundreds of cycles, errors cluster in time, the independent-edge model mis-weights the resulting chains, and you decode below the threshold the independent model predicted.

Mitigation: dynamical decoupling (CPMG, XY4) acts as a high-pass filter, suppressing low-frequency spectral density before the syndrome measurement; adaptive decoders re-weight priors from recent syndrome history or spectator-qubit readouts.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-2

What physical mechanisms determine T1 energy relaxation, how is it measured experimentally, and how does T1 bound the maximum usable depth of quantum circuits?

Answer

Energy relaxation ($T_1$) is the timescale over which an excited state $|1\rangle$ decays irreversibly to thermal equilibrium with its environment (predominantly ground state $|0\rangle$ when $\hbar \omega_{01} \gg k_B T$).

1. Physical Mechanisms and Trade-offs

$T_1$ dissipation follows Fermi's Golden Rule: $\Gamma_1 = 1/T_1 = \frac{1}{\hbar^2} |\langle 0 | \hat{H}{int} | 1 \rangle|^2 S{env}(\omega_{01})$. In planar superconducting transmons ($f_{01} \approx 4.5\text{--}5.2\text{ GHz}$, $T_1 \approx 100\text{--}300\ \mu\text{s}$), the primary loss channels include:

  • Dielectric Surface Loss: Dipole coupling to two-level systems (TLS) at substrate-metal and substrate-air interfaces. Mitigation requires enlarged capacitor footprints, which directly trades off against chip real estate and increases parasitic capacitive crosstalk.
  • Purcell Decay: State leakage through coupling $g$ into the readout resonator ($\omega_r$) that leaks into the $50\ \Omega$ feedline at rate $\kappa$: $\Gamma_{P} \approx (g/\Delta)^2 \kappa$, where $\Delta = \omega_{01} - \omega_r$. Large detuning ($|\Delta|/2\pi \sim 1\text{--}1.5\text{ GHz}$) or narrow-band Purcell filters protect $T_1$, but deliberately sacrifice dispersive readout speed (increasing measurement time from $300\text{ ns}$ to $>1\ \mu\text{s}$) and increase resonator ring-up/ring-down latency.
  • Non-equilibrium Quasiparticles: Unpaired electrons tunneling across Josephson junctions, triggered by ambient infrared radiation or ionizing radiation events.

2. Experimental Measurement and Operational Failure Modes

$T_1$ is characterized via an inversion recovery protocol:

  1. Apply a calibrated resonant $\pi$-pulse ($X_\pi$, typically $20\text{--}40\text{ ns}$) to prepare $|1\rangle$.
  2. Wait an idle delay $\tau$, stepped exponentially or linearly from $0$ to $4 T_1$ (e.g., $0\text{ to }1000\ \mu\text{s}$ across 60 points).
  3. Apply dispersive readout and measure the excited-state population: $P(|1\rangle, \tau) = A e^{-\tau / T_1} + B$.

In production systems, $T_1$ is not static; TLS defects exhibit spectral diffusion, drifting in frequency on minute-to-hour timescales:

Operational Failure Detection Trace:
Calibrated Baseline (08:00 UTC): T1 = 210 us, 2Q-CX error = 7.5e-3
TLS Drift Collision (11:30 UTC): T1 drops to 32 us, 2Q-CX error jumps to 3.8e-2
Root Cause: Resonant TLS defect crossed qubit f_01, detected via scheduled automated calibration.

Ionizing radiation (cosmic rays, substrate gamma rays) produces correlated $T_1$ collapses across entire dies, decaying hundreds of qubits simultaneously for milliseconds.

3. Circuit Depth Bounding

$T_1$ establishes a hard upper limit on circuit depth. An amplitude damping channel over duration $t_g$ imposes an intrinsic relaxation error probability: $$p_{\text{relax}} \approx 1 - e^{-t_g / T_1} \approx \frac{t_g}{T_1}$$ For a transmon with $T_1 = 150\ \mu\text{s}$:

  • Single-qubit gate: $t_{1Q} \approx 30\text{ ns} \implies p_{\text{relax}}^{1Q} \approx 30\text{ ns} / 150\ \mu\text{s} = 2.0 \times 10^{-4}$.
  • Two-qubit cross-resonance (CR) or CZ gate: $t_{2Q} \approx 300\text{ ns} \implies p_{\text{relax}}^{2Q} \approx 300\text{ ns} / 150\ \mu\text{s} = 2.0 \times 10^{-3}$.

For an $N$-qubit circuit executed across $D$ two-qubit layers, if each layer has average duration $t_{\text{layer}} \approx 350\text{ ns}$ (including dynamical decoupling and alignment delays), the total circuit execution time is $T_{\text{circ}} = D \cdot t_{\text{layer}}$. Under the requirement that circuit survival fidelity $\mathcal{F} \ge \mathcal{F}{\min}$ (bounded by $\mathcal{F} \approx \exp(-N{\text{active}} T_{\text{circ}} / T_1)$): $$D_{\max} \le \frac{T_1 \ln(1 / \mathcal{F}{\min})}{N{\text{active}} t_{\text{layer}}}$$ For $N_{\text{active}} = 10$ qubits and an acceptable survival threshold $\mathcal{F}{\min} = 0.5$: $$D{\max} \approx \frac{150\ \mu\text{s} \cdot 0.693}{10 \cdot 0.35\ \mu\text{s}} \approx \frac{104\ \mu\text{s}}{3.5\ \mu\text{s}} \approx 29\text{ layers}$$ Beyond this depth, the circuit register thermalizes toward ground state irrespective of algorithm, rendering output expectation values flat noise.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-3

How do T2 and T2* dephasing times differ, what environmental noise drives pure dephasing, and how do spin-echo and dynamical decoupling pulse sequences mitigate it?

Answer

The 90-second version

Assume a single qubit with a fixed transition frequency, classical Gaussian noise, and pulses short compared to the noise correlation time. Under those assumptions the two times differ only in which part of the noise spectrum they sample.

$T_2^$ is the free-induction decay you measure with a Ramsey fringe: $\pi/2$, wait $\tau$, $\pi/2$, read out. It includes every source of frequency scatter that is slow compared to $\tau$: field gradients, bias drift, $1/f$ flux noise. Those are quasi-static, so they don't average out; they smear the fringe. $T_2^$ is a lower bound on the true coherence time.

$T_2$ is the Hahn-echo time: $\pi/2$, wait $\tau/2$, $\pi$, wait $\tau/2$, $\pi/2$. The $\pi$ pulse flips the qubit, so phase picked up in the first half is unwound in the second. Anything constant over the whole sequence cancels exactly. So $T_2 \ge T_2^$, and it is bounded by energy relaxation: $1/T_2 = 1/(2T_1) + 1/T_\phi$, hence $T_2 \le 2T_1$. Ramsey carries the same $1/(2T_1)$ term plus a larger dephasing rate $1/T_\phi^$.

The distinction is entirely about filtering. Ramsey is low-pass: it sees noise down to DC. Echo is band-pass: blind below roughly $1/\tau$, still exposed above it.

What drives pure dephasing

Pure dephasing is frequency noise along $z$ (stochastic phase kicks $\delta\omega(t),\sigma_z$) with no energy exchanged with the bath. For superconducting qubits the three I'd name: $1/f$ flux noise from unpaired surface spins in the SQUID loop; charge noise from two-level systems in the substrate and oxide interfaces; and photon-number fluctuations in the readout resonator, which shift the qubit frequency through the AC Stark effect. Spin qubits see the nuclear-spin bath; trapped ions see magnetic-field and laser-phase noise.

Why the pulses work

Write the accumulated phase as $\phi = \int \delta\omega(t),s(t),dt$, where $s(t) = \pm 1$ is the sign the sequence imposes. Ramsey has $s(t) = +1$ throughout; a Hahn echo has $+1$ then $-1$. The overlap of $s(t)$ with the noise is the filter function, and it is the Fourier transform of $s(t)$ that decides which frequencies survive.

Trace it for a constant detuning $\Delta\omega$. After the first $\pi/2$ the state is $\alpha|0\rangle + \beta e^{-i\Delta\omega\tau/2}|1\rangle$. The $\pi$ pulse swaps the two amplitudes, so that phase now sits on $|0\rangle$. The second free interval adds $-\Delta\omega\tau/2$ to the $|1\rangle$ amplitude. At the end both amplitudes carry the same phase, so the relative phase is zero: independent of $\Delta\omega$. That is why the echo recovers a fringe the Ramsey measurement has already washed out.

CPMG repeats this with $N$ $\pi$ pulses spaced $\tau_d$ apart. The filter's high-pass corner moves down to roughly $1/\tau_d$, so more of the $1/f$ spectrum is suppressed. For a $1/f$ spectrum the gain is sublinear (coherence time grows roughly as $N^{2/3}$, not $N$) because the corner only moves as $1/\tau_d$ while the noise keeps rising below it. XY4 and XY8 alternate the pulse axis (X, Y, X, Y) so rotation-angle and detuning errors from imperfect pulses cancel to first order; plain CPMG accumulates them.

Ramsey ($T_2^*$)Hahn echo ($T_2$)CPMG / XY4
Filterlow-pass, sensitive to DCband-pass, blind below $\sim 1/\tau$high-pass corner at $\sim 1/\tau_d$
Removesnothingquasi-static offsets, slow drift$1/f$ and low-frequency TLS noise
Limited byinhomogeneous broadening$T_1$, noise faster than $1/\tau$pulse errors, finite pulse width

Failure modes

  • Pulse errors. Over-rotation and off-resonance error accumulate with pulse count. Detect by running CPMG and XY8 at the same $N$; if XY8 is much better, pulse error is your limit.
  • Finite pulse duration. Each $\pi$ pulse takes tens of ns, so $\tau_d$ cannot go below that and the filter cannot be pushed past roughly $1/(\text{pulse length})$.
  • High-frequency noise. DD is a high-pass filter and does nothing above the pulsing rate. If $T_2$ stops improving as you add pulses, the noise is fast or $T_1$-limited.
  • $T_1$ limit. If $1/(2T_1)$ dominates, no sequence helps. Measure $T_1$ and compare $1/T_2$ against $1/(2T_1)$.
  • Non-Gaussian noise. Telegraph noise from a single TLS breaks the Gaussian assumption; the echo decay becomes non-exponential and the filter picture is only qualitative.

What changes the answer: if the noise is white and fast, or $T_1$ is the bottleneck, DD is the wrong tool. You fix the hardware (shield the flux, filter the lines, cool the resonator) instead.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-25

What are the main decoherence channels (bit-flip, phase-flip, amplitude damping) and how do they map onto the Pauli error model that quantum error correction assumes?

Answer

Core (the first two minutes). QEC never sees your physical channel. A stabilizer code measures a syndrome and applies a Pauli frame correction, so the object that decides whether the code works is the effective Pauli channel: the probabilities p_I, p_X, p_Y, p_Z the code actually experiences. Bit-flip and phase-flip are already Pauli channels: bit-flip is X with probability p, phase-flip is Z with probability p. Amplitude damping is not Pauli: it is non-unital, with a preferred direction (|1⟩ → |0⟩), but it twirls into a Pauli channel with p_X = p_Y = γ/4 and p_Z = γ²/16. So to leading order amplitude damping is a bit-flip channel, which is why an X-correcting code is a real defence against energy relaxation, and why the residual Z error is second order in γ.

Mechanism: Kraus operators and the Pauli transfer matrix.

Bit-flip: E0 = √(1-p) I, E1 = √p X. Phase-flip: E0 = √(1-p) I, E1 = √p Z. Both are Pauli channels by construction.

Amplitude damping: E0 = diag(1, √(1-γ)), E1 = √γ |0⟩⟨1| = [[0,√γ],[0,0]]. Its Pauli transfer matrix R_PQ = ½ Tr(P E(Q)) is diagonal after twirling, with R_XX = R_YY = √(1-γ) and R_ZZ = 1-γ. Trace one entry: E(X) = E0 X E0† + E1 X E1† = √(1-γ) X + 0, because E1 X E1† = 0. So R_XX = √(1-γ).

Pauli twirling (averaging the channel over random Pauli frames, (1/4) Σ_P P E(P ρ P†) P†) kills the off-diagonal PTM entries and leaves a Pauli channel with

p_P = (1/4)(1 + R_PP − R_QQ − R_RR), {P,Q,R} = {X,Y,Z}, p_I = (1/4)(1 + R_XX + R_YY + R_ZZ).

Plugging in: p_X = p_Y = γ/4, p_Z = (2 − γ − 2√(1-γ))/4, p_I = (2 − γ + 2√(1-γ))/4.

Worked numbers, γ = 0.01 (one relaxation time constant of decay per gate):

√(1-γ) = 0.9949874 p_X = p_Y = 0.0025 p_Z = (2 − 0.01 − 1.9899749)/4 = 6.3×10⁻⁶ p_I = (2 − 0.01 + 1.9899749)/4 = 0.9949937

Sum = 1.0000000. The X rate is ~400× the Z rate, and γ²/16 = 6.25×10⁻⁶ matches the exact p_Z to two significant figures, so the small-γ expansion is safe for γ ≲ 0.01.

ChannelKraus operatorsPauli mappingNotes
Bit-flipE0=√(1-p)I, E1=√p XX with prob pExact Pauli
Phase-flipE0=√(1-p)I, E1=√p ZZ with prob pExact Pauli
DepolarizingE0=√(1-p)I, E1=√(p/3)X, E2=√(p/3)Y, E3=√(p/3)Zp_X=p_Y=p_Z=p/3Exact Pauli, symmetric
Amplitude dampingE0=diag(1,√(1-γ)), E1=[[0,√γ],[0,0]]After twirling: p_X=p_Y=γ/4, p_Z≈γ²/16Non-Pauli, non-unital; twirls to Pauli

Why the twirl is legitimate. For a stabilizer code, syndrome measurement plus Pauli recovery makes the effective error a Pauli operator drawn from the twirled distribution: the discretization argument. The code's recovery is Pauli, so only the Pauli components of the error survive to matter.

Trade-offs and failure modes.

  • The Pauli model is stochastic and i.i.d. Coherent errors (a systematic over-rotation, e.g. a miscalibrated π/2 pulse) add amplitudes, so n repetitions scale infidelity as n², not n. A code tuned to a stochastic p can be pushed below threshold by a coherent error of the same per-gate magnitude.
  • Non-Markovian noise (1/f charge noise, TLS defects) breaks independence; the twirled channel is then only an average and the instantaneous error rate can be far higher.
  • Biased noise: dephasing-dominated hardware gives p_Z ≫ p_X. Twirling discards that bias; biased codes (XZZX, repetition-code-based) keep it and get a better threshold.
  • Detection: randomized benchmarking gives the average Pauli error rate; gate set tomography or process tomography gives the full PTM and exposes the coherent part. If RB error is much lower than the coherent-error estimate, you have a coherent problem.
  • Mitigation: Pauli twirling (randomized compiling) converts coherent into stochastic at the cost of extra single-qubit gates; dynamical decoupling suppresses low-frequency dephasing; noise-adapted codes exploit bias.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-5

How is the depolarizing channel defined mathematically as a quantum operation, and what are its practical limitations when modeling realistic fault-tolerant quantum hardware?

Answer

The channel. With probability $p$ the qubit's state is discarded and replaced by the maximally mixed state; with probability $1-p$ it survives:

$$\mathcal{E}_p(\rho) = (1-p)\rho + p,\frac{I}{2}, \qquad p \in [0,1].$$

Three properties follow immediately and matter later. It is unital: $\mathcal{E}_p(I/2) = I/2$. On the Bloch sphere it shrinks the vector uniformly, $\mathbf{r} \mapsto (1-p)\mathbf{r}$, contracting toward the origin rather than toward $|0\rangle$. And it is a Pauli channel with equal rates, which is the form QEC papers actually use:

$$\mathcal{E}_p(\rho) = \left(1 - \tfrac{3p}{4}\right)\rho + \tfrac{p}{4}\left(X\rho X + Y\rho Y + Z\rho Z\right),$$

with Kraus operators $A_0 = \sqrt{1-3p/4},I$, $A_1 = \tfrac{\sqrt{p}}{2}X$, $A_2 = \tfrac{\sqrt{p}}{2}Y$, $A_3 = \tfrac{\sqrt{p}}{2}Z$, satisfying $\sum_k A_k^\dagger A_k = I$. (The form is valid for $p \le 4/3$, so the whole unit interval is fine.)

For $n$ qubits the standard convention applies each non-identity Pauli $P \in {I,X,Y,Z}^{\otimes n} \setminus {I^{\otimes n}}$ with equal probability $p/(4^n - 1)$. Watch the convention: some papers use $p$ as the probability of any error, others as the per-Pauli rate; mixing them changes a threshold by a factor of $4^n - 1$.

Why it is the default: a Pauli channel maps stabilizer states to mixtures of stabilizer states, so it can be sampled efficiently in the stabilizer formalism, and MWPM decoders are built for independent Pauli faults.

Where it breaks.

It is unital, so it cannot represent relaxation. $T_1$ decay is amplitude damping: it drives $\rho$ toward $|0\rangle$, not $I/2$, and no choice of $p$ reproduces that. It also forces $p_X = p_Y = p_Z$, while real platforms are biased. Transmons sit near $T_2 \approx T_1$, so their bias is mild; strongly biased noise is engineered, e.g. cat qubits whose bit-flip lifetime is orders of magnitude longer than their phase-flip lifetime. Bias-tailored codes (XZZX, Bonilla Ataides et al., Nat. Commun. 2021) only pay off if the model carries the bias.

Coherent errors are not depolarizing, and the gap grows with depth. A systematic over-rotation $U = e^{-i\theta Z}$ has single-gate infidelity $\approx \theta^2/4$ for a state on the equator. Ten identical over-rotations give total angle $10\theta$ and infidelity $\approx (10\theta)^2/4 = 25\theta^2$. Ten independent depolarizing events with the same per-step $p = \theta^2/4$ give $\approx 10\cdot\theta^2/4 = 2.5\theta^2$. Same per-gate number, 10× the damage at depth 10: coherent errors add amplitude, stochastic errors add probability. Randomized compiling (Pauli twirling) converts the former into the latter, at the cost of extra single-qubit gates.

Real noise is correlated. $1/f$ flux and charge noise is non-Markovian; spectator qubits couple via $ZZ$; cosmic rays deposit energy across a chip and produce bursts of correlated errors (McEwen et al., Nature 2022). The i.i.d. assumption is exactly what MWPM relies on, so correlated faults surface as decoder failures, not as a slightly higher $p$.

Leakage leaves the code space. A transmon can reach $|2\rangle$; leakage per CZ gate is typically $10^{-3}$–$10^{-2}$. Leakage is not a Pauli error, produces persistent syndrome defects, and spreads through gates. It needs leakage-reduction units or erasure conversion, neither of which a depolarizing model can express.

The parameter is not directly measurable. $p$ is inferred by fitting randomized-benchmarking decay to a depolarizing model, so "error per Clifford" is defined under the assumption being tested. Unitarity and purity benchmarking are needed to separate coherent from stochastic contributions.

AttributeDepolarizing modelTransmon hardware
Pauli rates$p_X = p_Y = p_Z = p/4$$Z$-biased when $T_\phi < T_1$; near-isotropic when $T_2 \approx T_1$
UnitalityUnital, $\mathbf{r} \mapsto (1-p)\mathbf{r}$Non-unital: $T_1$ drives toward $|0\rangle$
Correlationsi.i.d., memoryless$1/f$ drift, $ZZ$ crosstalk, cosmic-ray bursts
Hilbert spaceFixed at two levelsLeakage to $|2\rangle$

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-4

How do coherent errors differ from stochastic Pauli noise in terms of error accumulation rate and threshold calculations in quantum error correction codes?

Answer

What a strong candidate says first. Two things decide this: which error metric you use, and whether the coherent errors share an axis. In the worst-case norm that threshold theorems are stated in, coherent and stochastic errors accumulate at the same linear rate in depth. In average infidelity, what randomized benchmarking reports, same-axis coherent errors accumulate quadratically, $D^2\epsilon$ against $D\epsilon$. The practical consequence: a device characterized by average infidelity sits much further above threshold when its errors are coherent, because a coherent error's norm is $\sim\sqrt{\epsilon}$ while a stochastic error's norm is $\sim\epsilon$.

Accumulation. Stochastic Pauli noise is a probabilistic mixture, so independent faults add in probability: $D$ gates give total error probability $\approx Dp$ for $Dp \ll 1$. A coherent error is a unitary, so same-axis rotations add in amplitude: $D$ gates give a net rotation $D\theta$ and worst-case infidelity $\sin^2(D\theta/2) \approx D^2\theta^2/4$. For a single-qubit $Z$-rotation the per-gate average infidelity is $\epsilon = \theta^2/6$ (worst case is $\theta^2/4$; the diamond-norm distance is $2\sin(\theta/2) \approx \theta$). So the accumulated average infidelity is $D^2\epsilon$ versus $D\epsilon$.

The quadratic law is a worst case, not a generic property. It needs the errors to add in phase: identical axis, reproducible sign. If the rotation axis randomizes gate to gate, the accumulated angle is diffusive, $\sim\sqrt{D},\theta$, and the infidelity returns to linear, $D\epsilon$: indistinguishable from stochastic noise at the level of average infidelity. Systematic calibration drift, a fixed microwave over-rotation, and static $ZZ$ crosstalk are the cases that align.

QuantityStochastic PauliCoherent rotation by $\theta$
Per-gate average infidelity$(2/3)p$$\theta^2/6$
Accumulated average infidelity, $D$ gates$(2/3)Dp$$D^2\theta^2/6$ (same axis)
Diamond-norm distance per gate$2p$$\approx \theta$
After one syndrome roundunchangedprojected to Pauli with prob. $\sin^2(\theta/2)$
Python
import numpy as np

theta = 1e-3          # per-gate over-rotation angle about Z
D     = 100           # gates in the circuit
eps   = theta**2 / 6  # per-gate average infidelity of the rotation

r_coh = (2/3) * np.sin(D * theta / 2)**2   # same axis: amplitudes add
r_sto = (2/3) * (1 - (1 - eps)**D)         # independent Paulis: probabilities add
print(f"coherent {r_coh:.2e}  stochastic {r_sto:.2e}")

Output: coherent 1.67e-03 stochastic 1.11e-05. A factor 150 at $D = 100$.

Thresholds. Threshold theorems (Aharonov–Ben-Or; Knill–Laflamme–Milburn; Aliferis–Gottesman–Preskill) assume a local stochastic error model: faults are independent, and the per-location error is bounded in a worst-case norm. Coherent errors break both assumptions.

The norm gap is the sharpest effect. A coherent rotation with average infidelity $\epsilon$ has diamond norm $\approx \sqrt{6\epsilon}$; a Pauli channel with error probability $p$ has diamond norm $2p$. At equal average infidelity the coherent error is therefore $\sim 1/\sqrt{\epsilon}$ times larger in the metric the threshold is stated in. Concretely, take the circuit-level surface-code threshold $p_{\text{th}} \approx 0.6%$ for depolarizing noise (Fowler et al., 2012); in diamond-norm terms that is $\approx 1.2%$. A coherent rotation with the same diamond norm has $\theta \approx 0.012$ and average infidelity $\theta^2/6 \approx 2.4\times10^{-5}$. So the threshold expressed in average infidelity drops from $\approx 4\times10^{-3}$ (stochastic) to $\approx 10^{-5}$ (coherent): two orders of magnitude, before any code-specific effects.

Syndrome extraction partially rescues this. A stabilizer measurement that anticommutes with the rotation axis projects the coherent error into a Pauli error with probability $\sin^2(\theta/2)$ per round; a measurement that commutes with it leaves the coherence intact. What survives either way is coherence within a degenerate syndrome subspace: when the error is undetected, the post-measurement state is still a superposition, and repeated rounds can add amplitude along an undetected logical cycle.

What to do about it. Randomized compiling (Wallman & Emerson, 2016) inserts random Pauli gates that twirl the coherent error into an effective stochastic Pauli channel, restoring the standard threshold assumptions; the cost is extra single-qubit gates, no extra two-qubit gates. Randomized benchmarking alone will not reveal the problem, because it reports average infidelity.

The counter-case. Coherent errors are not always worse. If the rotation axis anticommutes with a stabilizer, the code detects the error and can correct it; at equal average infidelity, coherent errors can then beat stochastic ones (Huang, Doherty & Flammia, PRA 99, 022313, 2019). The $D^2$ bound is an upper bound, not a prediction.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-6

Design and validate a quantum reliability workflow for error discretization.

Answer

Core answer

Error discretization is where a continuous noise model (coherent over-rotations, amplitude damping, crosstalk) gets replaced by a Pauli channel, because surface-code decoders (MWPM) are defined on Pauli errors. The workflow is four steps: fix the noise model, discretize it, cross-check the discretized model against the un-discretized one on a small code, then validate against hardware on a memory experiment. Assumptions: circuit-level noise, one syndrome-extraction round per cycle, rotated surface code, MWPM decoder, superconducting qubits where single-qubit Paulis are virtual.

stepdovalidation criterionfailure symptom
1. ModelWrite the noise as a channel per gate: depolarizing p, dephasing, coherent Rz(θ)Parameters fit to RB / tomography on the deviceModel matches RB but not memory
2. DiscretizePauli-twirled channel: p_Q = |Tr(Q U)|²/4 for a unitary; or randomized compiling on hardwareTwirled channel has the same average fidelity as the originalTwirl changes multi-gate error growth
3. Cross-checkExact density-matrix sim at d=3 vs. sampled Pauli simLogical error rates agree within statistical error (10⁶ shots)Sampler misses correlated events
4. HardwareMemory experiment, sweep distancep_L(d=5) < p_L(d=3) at the operating pointp_L flat or rising with d

Circuit-level depolarizing threshold for the surface code is ~0.6% (Fowler et al., PRA 86, 032324, 2012); below it p_L ∝ (p/p_th)^((d+1)/2), so the d=5/d=3 ratio is a sharp test of the model.

Twirling is exact per gate, not per circuit. For Rz(θ), the twirled channel is p_I = cos²(θ/2), p_Z = sin²(θ/2). At θ=0.01 rad, p_Z ≈ 2.5×10⁻⁵. Over N=100 gates the twirled (stochastic) model gives total error ≈ N·p_Z = 2.5×10⁻³, but the un-twirled coherent errors add in amplitude: total infidelity ≈ (Nθ)²/4 = 0.25. A factor of 100. A Pauli model validated at one depth can therefore be wrong at another. Randomized compiling (Wallman & Emerson, PRA 94, 052325, 2016) fixes this by making the physical noise Pauli, at the cost of extra single-qubit gates.

Python
import numpy as np
I = np.eye(2, dtype=complex)
Z = np.diag([1, -1]).astype(complex)
theta = 0.01
U = np.diag([np.exp(-1j*theta/2), np.exp(1j*theta/2)])  # Rz(theta)
p_I = abs(np.trace(I @ U))**2 / 4
p_Z = abs(np.trace(Z @ U))**2 / 4
print(p_I, p_Z)   # 0.999975 2.49998e-05

Failure modes and how to catch them

  • Coherent error treated as Pauli. Symptom: simulation matches hardware at shallow depth, hardware degrades faster as rounds grow. Detection: plot p_L vs. rounds; coherent contributions grow quadratically. Fix: randomized compiling, or model the coherent term explicitly.
  • Correlated error below distance. A single event (cosmic ray, leakage, TLS) flips several qubits; if the pattern aligns with a weight-<d logical operator, the code fails at a rate the independent-Pauli model never predicts. Detection: histogram the weight of detected error patterns, look for excess weight-2/3 events. Fix: raise d, add flag qubits or leakage-reduction units.
  • Recovery convention mismatch. Decoder and simulator disagree on the Pauli frame (basis or logical-operator sign). Symptom: p_L ≈ 0.5 regardless of d. The decoder is guessing. Detection: inject a known single Pauli error, check the correction; run a noiseless sim and require zero logical errors.
  • Logical information measured. A hook error couples a data qubit to the logical observable, so syndrome extraction collapses the logical state. Symptom: logical fidelity drops with zero injected noise. Detection: run the syndrome circuit on a known logical state, noiseless, and check it is preserved.

Alternatives. A full Pauli channel (4ⁿ−1 parameters) is exact but intractable past ~10 qubits; depolarizing (1 parameter) is cheap but wrong for biased noise. A Pauli channel with an X/Z bias parameter is the usual middle ground. Exact density-matrix simulation is feasible at d=3 and is the reference the sampler must match.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-11

Design and validate a quantum reliability workflow for no-cloning compatibility.

Answer

What you say first (60–120 s). "No-cloning compatibility" means the reliability scheme must recover a logical state without ever copying an unknown quantum state, which unitarity forbids. The resolution is that encoding is an isometry, not a copy: it entangles the logical state across physical qubits so no subsystem holds it, and recovery is a decode, not a duplicate. So I'd design the encode → syndrome → decode pipeline, then validate two properties: no physical subsystem carries the state, and the logical state is reconstructible after a correctable fault. Assumptions: a stabilizer code, a single-qubit error/erasure model, and a goal of recovering the logical state rather than keeping a backup copy.

Why encoding isn't cloning. Cloning needs a unitary U with U|ψ⟩|0⟩ = |ψ⟩|ψ⟩ for every |ψ⟩. Taking inner products forces ⟨φ|ψ⟩ = ⟨φ|ψ⟩², so ⟨φ|ψ⟩ ∈ {0,1}: only orthogonal states could be copied. Encoding instead maps |ψ⟩ → U|ψ⟩|0…0⟩, an isometry on the code subspace; the information moves into correlations between qubits.

Worked check (9-qubit Shor code). |0_L⟩ = (|000⟩+|111⟩)^⊗3 / 2√2, |1_L⟩ = (|000⟩−|111⟩)^⊗3 / 2√2. Encode |ψ⟩ = α|0⟩+β|1⟩ as α|0_L⟩+β|1_L⟩. Tracing out qubits 2–9 leaves qubit 1 in I/2, independent of α and β: the operational signature of no-cloning compatibility. Now inject X on qubit 4. The eight stabilizer generators are measured: six Z-type (Z1Z2, Z2Z3, Z4Z5, Z5Z6, Z7Z8, Z8Z9) and two X-type across blocks. Z4Z5 and Z5Z6 flip to −1, localizing the error to qubit 4; the X-type syndromes are unchanged because X4 commutes with them. Applying X4 restores the state; decode and compare to the input: fidelity 1 on a noiseless circuit.

Validation table.

checkpass criterionfirst production miss
No-cloning compatibilityEvery single-qubit reduced state is I/2 and independent of the inputA reduced state depends on α, β: the encoder is copying
IsometryU†U = I on the code subspace, or stabilizers verifiedEncoder is non-unitary, e.g. a mid-circuit measurement
ReconstructionAfter one injected error, decoded fidelity ≥ 1 − εDecoder corrects the wrong qubit
AncillaAncilla is in the zero state before the entangling gateAncilla prepared in the logical state: that is cloning

Trade-offs. The 3-qubit repetition code uses 3 physical qubits per logical and corrects one X error, but its single-qubit reduced state is diag(|α|², |β|²): it leaks the Z-basis probabilities and cannot correct phase errors. Shor uses 9 and corrects any single-qubit error. A surface code of distance d uses roughly 2d²−1 qubits, corrects (d−1)/2 errors, and has a threshold near 1%, with logical error rate scaling as (p/p_th)^((d+1)/2). Pick the smallest code whose correctable set covers your measured error model; anything larger is overhead you pay in syndrome-extraction depth.

Failure modes and detection. Measuring a logical operator instead of a stabilizer collapses the state: detect by confirming every measured generator commutes with the logicals. Assuming recovery is universal: a distance-3 code corrects one error, not two. Inject two errors and confirm the decoder reports an uncorrectable syndrome rather than silently mis-correcting.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-7

Design and validate a quantum reliability workflow for stabilizer generators.

Answer

Assume n physical qubits and m Pauli generators. I want the stabilizer group S to be abelian, to exclude -I, and to have rank m so the code space is 2^(n-m) dimensional. The workflow is six stages: parse, pairwise commutation, GF(2) rank, minus-identity membership, encoded dimension, phase convention. Commutation and rank get all the attention; minus-identity and phase convention are where production breaks.

Worked example. Take n=2 with generators g1=XX, g2=ZZ, g3=YY. Write each in symplectic form (x|z) per qubit, with X=(1,0), Z=(0,1), Y=(1,1):

g1 = (11|00), g2 = (00|11), g3 = (11|11).

g3 = g1 ⊕ g2 over GF(2), so rank = 2 while m = 3: the generators are dependent. Rank alone gives k = n - rank = 0, dimension 2^0 = 1. Now check the nullspace combination g1 ⊕ g2 ⊕ g3 = 0. Its accumulated phase is g1·g2·g3 = (XX)(ZZ)(YY) = (XZ⊗XZ)(YY) = (-iY⊗-iY)(YY) = (-YY)(YY) = -I. So -I ∈ S and the code space is empty: dimension 0, not 1. That is the check rank misses.

Code. Stim does commutation and independence in one call:

Python
import stim
gens = [stim.PauliString("XX"), stim.PauliString("ZZ"), stim.PauliString("YY")]
stim.Tableau.from_stabilizers(gens)  # ValueError: redundant generators

It stops there. To catch -I you need the nullspace, which means your own GF(2) elimination: pack each generator into 2n bits plus a phase bit, row-reduce, and for every nullspace vector accumulate the phase; a -1 result means -I ∈ S.

Failure modes, detection, and cost.

failuredetectioncost if shipped
anticommuting pairsymplectic product g_i·g_j ≠ 0syndrome extraction ill-defined; decoder sees garbage
dependent generatorsGF(2) rank < mdecoder double-counts a check; inflated logical error rate
-I in the groupnullspace combination with phase -1empty code space; encoder emits no valid state
qubit order mismatchcross-check generator index against circuit qubit indexsilent wrong code, passes every local check
phase convention mismatchround-trip a Y-type generator through both librariesY-type generators flip sign; syndromes inverted

Tradeoffs. Stim's from_stabilizers is one C++ call and the right CI gate, but it fails fast without naming the offending pair. Qiskit's PauliList.commutes gives the full pairwise matrix and lives next to QuantumCircuit, at the cost of Python-level loops. Hand-rolled elimination is the only one that yields the nullspace for the -I check. Sizing: n=1000, m=500, pairwise commutation is C(500,2)=124,750 pairs × 1000 qubits ≈ 1.2×10^8 bit ops; packed-bitset rank is 500^2 × 1000/64 ≈ 3.9×10^6 word ops, so rank is roughly 30× cheaper. Run it first and only build the pairwise matrix when rank passes.

Phase convention. Stim and Qiskit both take Y = iXZ, but a generator's overall sign is separate from the sign of the Pauli product. Round-trip one Y-type generator through both and compare signs; a mismatch inverts every syndrome that generator contributes.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-8

How is the error syndrome extracted from a stabilizer code, and what makes a syndrome-measurement circuit fault-tolerant?

Answer

Core answer

A stabilizer code is the +1 eigenspace of an abelian group S = ⟨g₁…g_m⟩. The syndrome is the vector of eigenvalues λ_i ∈ {+1,−1} of the generators on the corrupted state. You never measure the data qubits directly: you measure each generator by coupling it to an ancilla.

For one generator g with support {q₁…q_w}: prepare an ancilla in |0⟩, apply a controlled-g (CNOT for each X in g, CZ for each Z), then measure the ancilla in the Z basis. Outcome 0 → λ = +1, 1 → λ = −1. For CSS codes the X-type and Z-type checks are extracted by separate ancillas; the two sets commute, so they can be measured in either order.

Worked example. 3-qubit bit-flip code, S = ⟨Z₁Z₂, Z₂Z₃⟩. Ancilla a₁: CNOT(a₁→q₁), CNOT(a₁→q₂), measure. Ancilla a₂: CNOT(a₂→q₂), CNOT(a₂→q₃), measure. An X on q₁ anticommutes with Z₁Z₂ only → syndrome (1,0); X on q₂ → (1,1); X on q₃ → (0,1). The decoder maps those three nonzero syndromes to X₁, X₂, X₃.

Fault tolerance is a property of the extraction circuit, not of the code. The rule: any single fault anywhere in the circuit (ancilla preparation, any gate, ancilla measurement) must produce at most one error on the data qubits, and that error must be correctable (weight ≤ t = ⌊(d−1)/2⌋).

rulewhyfailure if violated
Ancilla prepared in one basis and verified (cat state / Shor-style)a prep fault must not spreadone prep fault → correlated data error
Each data qubit touched at most once per ancillaan ancilla fault propagates to every qubit it still touchesweight-w error from a single fault
CNOT direction chosen so ancilla errors are the other Pauli typeX-check ancilla errors become X errors, caught by the Z-checksundetectable error
Repeat d rounds, decode over space-timemeasurement errors are time-like errorsa measurement error is misread as a data error

Hook errors. With a weight-4 stabilizer, a single fault on the ancilla after two CNOTs propagates to two data qubits. If those two qubits lie along a logical operator, the effective distance drops from d to ⌊d/2⌋. Fixes: flag qubits that detect the hook, or a CNOT ordering (Z-shaped vs N-shaped) that makes the hook parallel to the logical operator instead of perpendicular.

Failure modes and how they show up. (a) Hook error → p_L scales with ⌊d/2⌋ rather than d; detect by comparing measured p_L against the circuit-level model, or by the flag-qubit firing rate. (b) Leakage out of the computational subspace on the ancilla → correlated errors; detect with leakage-detection units. (c) Extraction that reveals logical information: the ancilla must start in a known state and be measured, never left entangled with the logical subspace.

Numbers. With fault-tolerant extraction, p_L ≈ A(p/p_th)^⌊(d+1)/2⌋. Fowler et al. (arXiv:0803.0272) report p_th ≈ 0.75% for the surface code under circuit-level depolarizing noise. Below threshold, going d=3→5 should drop p_L by roughly the ratio p/p_th.

Alternatives. Shor-style cat-state ancilla (verified preparation, more qubits) versus a single ancilla plus flag qubits (fewer qubits, more classical processing). Trapped-ion and neutral-atom platforms often use transversal or measurement-based extraction with mid-circuit measurement and reset.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-12

Design and validate a quantum reliability workflow for CSS codes.

Answer

What a strong candidate says first

A CSS code is a stabilizer code whose checks split into X-type and Z-type, each defined by a classical binary code. Pick C1, C2 ⊆ F2^n with C2^⊥ ⊆ C1. Then H_X (rows = a basis of C2^⊥) and H_Z (rows = a basis of C1^⊥) satisfy H_X H_Z^T = 0, so every X check commutes with every Z check. Logical X operators live in C1 \ C2^⊥, logical Z in C2 \ C1^⊥. Validation is four things: the commutation identity, logical anticommutation, the distances d_X and d_Z, and a circuit-level simulation. Assume depolarizing circuit-level noise at rate p per gate and an MWPM decoder unless stated otherwise.

Workflow

  1. Choose C1, C2. Steane [[7,1,3]]: C1 = C2 = [7,4,3] Hamming. Shor [[9,1,3]]: C1 = three copies of the [3,1,3] repetition code, C2^⊥ = span{111111000, 000111111}. Build H_X and H_Z.
  2. Check H_X H_Z^T = 0 mod 2. If it fails, the code is not CSS and syndrome extraction returns random outcomes.
  3. Build logical representatives and check L_X L_Z^T = I_k mod 2. A zero block means you built H_X from C1^⊥ instead of C2^⊥: the code is still valid, but X and Z are swapped.
  4. Compute d_X = min weight in C1 \ C2^⊥, d_Z = min weight in C2 \ C1^⊥. Brute force for n ≤ 20; for larger n use QDistRnd (GAP) or a MILP formulation. Steane: d_X = d_Z = 3.
  5. Simulate. Stim builds the syndrome-extraction circuit and samples syndromes under depolarizing noise; PyMatching decodes. Sweep p and fit the logical error rate per round.

Validation checks

#CheckPass conditionFailure it catchesDetection
1CommutationH_X H_Z^T = 0 mod 2X and Z checks anticommuteone noiseless round yields a nonzero syndrome
2Logical anticommutationL_X L_Z^T = I_k mod 2X/Z convention swappedproduct is the zero matrix
3Distancemin(d_X, d_Z) equals the design valuedecoder returns a logical operatorlogical error rate plateaus as p → 0
4Noise modeldepolarizing includes Y (probability p/3)Y errors droppedlogical error rate too low
5DecoderMWPM or exact coset lookupdegeneracy ignoredlogical error rate above the exact-decoder curve

Below threshold the logical error rate per round scales as p^⌈d/2⌉, so a log-log fit of rate against p should give slope ⌈d/2⌉: 2 for Steane, 3 for a distance-5 code. A slope that disagrees with the computed distance means the distance or the decoder is wrong.

Mechanisms

Degeneracy: many errors share a syndrome and differ by a stabilizer. A decoder that returns a minimum-weight correction can return a logical operator when the true error was stabilizer-equivalent to a lower-weight one. Exact coset lookup, or MWPM on the matching graph (optimal for the surface code under independent X/Z errors), avoids this; a naive syndrome→correction table does not.

Y errors: Y = XZ. Under depolarizing noise each fault is X, Y or Z with probability p/3 each. Simulating X and Z independently drops the Y correlation and understates the logical error rate.

Transpose: H_X is r_X × n. H_X^T is n × r_X; using it makes checks act on the wrong qubits, and the commutation product is either nonzero or dimensionally invalid.

Trade-offs

CSS splits decoding into two independent classical problems, so a lookup decoder needs 2^{r_X} + 2^{r_Z} entries instead of 2^{n-k}, where r_X = rank(H_X), r_Z = rank(H_Z) and r_X + r_Z = n - k. For Steane that is 2^3 + 2^3 = 16 instead of 2^6 = 64. It costs rate: for fixed n and d some non-CSS codes encode more qubits. And it is the wrong choice under strong bias: with 90% Z errors the XZZX surface code's threshold rises with bias, approaching 50% at infinite bias (Bonilla Ataides et al., 2021), while the CSS surface code's does not. Use CSS when noise is roughly depolarizing and you want modular decoding.

Artefact

Python 3.11, numpy 1.26:

Python
import numpy as np
from itertools import product

# Steane [[7,1,3]]: C1 = C2 = [7,4,3] Hamming, parity check H
H = np.array([[1,0,1,0,1,0,1],
              [0,1,1,0,0,1,1],
              [0,0,0,1,1,1,1]], dtype=np.uint8)
n = 7

def rowspace(rows):
    return {tuple((np.array(c, dtype=np.uint8) @ rows) % 2)
            for c in product([0,1], repeat=len(rows))}

def code(H):
    return {v for v in product([0,1], repeat=n)
            if not ((H @ np.array(v, dtype=np.uint8)) % 2).any()}

C2perp = rowspace(H)                 # X stabilizers
C1     = code(H)                     # C1^⊥ = rowspace(H) = Z stabilizers
print("commutes:", not ((H @ H.T) % 2).any())     # True
print("|C1|, |C2perp|:", len(C1), len(C2perp))    # 16 8
L_X = C1 - C2perp
print("d_X:", min(sum(v) for v in L_X))           # 3
Lx, Lz = (1,1,1,0,0,0,0), (1,1,1,0,0,0,0)
print("L_X . L_Z mod 2:", sum(a*b for a,b in zip(Lx, Lz)) % 2)   # 1

Trace: every row of H has weight 4, and row_i · row_j = 2 for i ≠ j (rows 1·2, 1·3 and 2·3 all give 2), so H H^T mod 2 is all zeros and commutes prints True. C1 is the Hamming code, 2^4 = 16 codewords; C2perp is the rowspace of H, 2^3 = 8. L_X = C1 \ C2perp has 8 vectors and its minimum weight is 3 (e.g. 1110000), so d_X = 3. Lx · Lz = 3 mod 2 = 1, confirming the logical operators anticommute.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-9

Design and validate a quantum reliability workflow for code distance.

Answer

A distance workflow has three stages: pin which distance you mean, compute it, then validate it against measured logical-error scaling. "Distance" is four different numbers, and a workflow that skips the definition validates the wrong one.

Stage 1: define against the noise model. Distance is only meaningful once the noise model is fixed:

  • Code distance d: minimum weight of a logical operator on data qubits, noiseless. For CSS codes, d_X and d_Z are separate numbers.
  • Circuit-level (fault) distance: fewest fault locations in the noisy circuit that produce an undetectable logical error.
  • Erasure distance: fewest heralded erasures that produce a logical error; erasure decoding corrects up to d−1 of them.

Stage 2: compute. Code distance is a minimum-weight logical operator problem: minimize |v| over v in rowspace(L) \ rowspace(H). Exact via integer programming for small codes; randomized upper bounds (QDistRnd) for large LDPC codes. Circuit-level distance comes from Stim's search_for_undetectable_logical_errors.

Stage 3: validate by scaling. Below threshold, p_L ≈ A·(p/p_th)^((d+1)/2). Sample detection events, decode, fit the exponent, and check it matches the computed distance. A mismatch means the distance is wrong or the decoder is suboptimal.

Python
import stim, pymatching, numpy as np

d, rounds = 5, 5
circuit = stim.Circuit.generated(
    "surface_code:rotated_memory_z",
    distance=d, rounds=rounds,
    after_clifford_depolarization=0.003,
    before_measure_flip_probability=0.003,
    after_reset_flip_probability=0.003,
)

# circuit-level distance: fewest faults forming an undetectable logical error
fault_path = circuit.search_for_undetectable_logical_errors(
    dont_explore_detection_event_sets_with_size_above=4,
    dont_explore_edges_with_degree_above=4,
    dont_explore_edges_increasing_symptom_degree=False,
)
print("circuit distance =", len(fault_path))   # expect 5 for a clean d=5 memory

# validate by scaling: decode and measure logical error rate
dem = circuit.detector_error_model(decompose_errors=True)
matching = pymatching.Matching.from_detector_error_model(dem)
dets, obs = circuit.compile_detector_sampler().sample(
    shots=200_000, separate_observables=True)
pred = matching.decode_batch(dets)
print("p_L =", np.mean(np.any(pred != obs, axis=1)))
distancedefinitionhow to computed=5 example
code (data)min-weight logical operator on data qubitsILP / QDistRnd5
circuit-levelmin faults → undetectable logical errorStim search5, drops to 3 with bad syndrome extraction
erasuremin erasures → logical errorerasure decodercorrects up to 4 erasures

Failure modes, with detection and cost.

  1. Distance inferred from qubit count. A 49-qubit rotated surface code is d=5 (25 data + 24 ancilla), but a 49-qubit LDPC code can be d=3 or d=6. Detect by computing from H, never from n. Cost: you overstate correction by 2× and the decoder fails at weight-2 errors.
  2. Erasure bound confused with Pauli distance. Erasure decoding corrects up to d−1 erasures with a threshold near 50%, versus roughly 0.5–1% for circuit-level depolarizing noise. Detect by checking whether the noise model heralds lost qubits. Cost: threshold estimate off by ~70×.
  3. Biased distances omitted. Under dephasing-dominated noise d_X and d_Z differ; a repetition code has d_Z=1. Detect by computing both axes separately. Cost: logical error is dominated by the weak axis and the fitted exponent is wrong.
  4. Circuit faults equated to data errors. A d=5 code can have circuit distance 3 when one CNOT fault spreads to a weight-3 data error. Detect with search_for_undetectable_logical_errors. Cost: measured p_L scales as p² instead of p³.

The workflow closes when the fitted exponent equals (d+1)/2 for the distance you defined in Stage 1: that is the only check that ties the number to the hardware.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-10

Design and validate a quantum reliability workflow for logical versus physical.

Answer

First two minutes. Pin the assumptions: superconducting transmons, circuit-level depolarizing noise at physical error rate p per gate and per round, a rotated surface code of distance d, MWPM decoding via PyMatching, and a target logical error rate per algorithm run. The workflow is five stages, each with a gate that must pass before the next is trusted.

1. Fix the logical/physical boundary. A physical error is a fault on one qubit. A logical error is a Pauli that commutes with every stabilizer but anticommutes with an observable. In the detector error model that distinction is mechanical, so check it mechanically rather than by argument:

Python
import stim  # 1.12+
dem = circuit.detector_error_model(decompose_errors=True)
for inst in dem.flattened():
    if inst.type != "error":
        continue
    dets = [t for t in inst.targets if t.is_relative_detector_id()]
    obs  = [t for t in inst.targets if t.is_logical_observable_id()]
    if not dets and obs:
        print("undetectable logical fault:", inst)

A physical fault lights detectors. A logical fault flips an observable and lights none. If that loop prints nothing at p = 1e-3, the code is not yet at a distance where logical faults are reachable, and any "logical error rate" you measure is really a decoder bug.

2. Build the noise model and layout. Map each physical source onto the syndrome-extraction circuit: two-qubit gate error, measurement error, idle decoherence, leakage out of the computational subspace. Gate: simulated syndrome statistics reproduce measured ones within roughly a factor of two. Otherwise the decoder is being validated against the wrong noise.

3. Decode and track the Pauli frame. The decoder's correction is a frame that must be propagated through every subsequent gate. Gate: inject a known logical error and confirm the frame update flips the correct observable. A dropped frame update turns a logical X into a silent logical Z.

4. Validate by distance scaling. This is the measurement that decides the design:

Python
import numpy as np, stim, pymatching  # pymatching 2.0+

def logical_error_rate(d, p, shots=200_000):
    circuit = stim.Circuit.generated(
        "surface_code:rotated_memory_z", distance=d, rounds=d,
        after_clifford_depolarization=p,
        before_measure_flip_probability=p,
        after_reset_flip_probability=p,
        before_round_data_depolarization=p)
    dem = circuit.detector_error_model(decompose_errors=True)
    matching = pymatching.Matching.from_detector_error_model(dem)
    dets, obs = circuit.compile_detector_sampler().sample(
        shots=shots, separate_observables=True)
    pred = matching.decode_batch(dets)
    return np.mean((pred != obs).any(axis=1))

for d in (3, 5, 7):
    print(d, logical_error_rate(d, 1e-3))

Gate: p_L falls as d rises, and the fitted suppression factor Λ = p_L(d)/p_L(d+2) matches prediction within the confidence interval. If p_L is flat or rising, you are above threshold and the rest of the design is void.

One shot, traced. d = 3, memory-Z, p = 1e-3. Round 1: no faults, all four Z-stabilizers read +1, no detection events. Between rounds 1 and 2 an X error lands on the centre data qubit. It anticommutes with the two Z-stabilizers touching that qubit, so round 2's syndrome flips on exactly those two; round 3 matches round 2, so nothing fires there. The sampler reports two detection events, both in round 2, on adjacent stabilizers. MWPM pairs them with a single-qubit X correction, the error itself, and the residual is identity. The final Z̄ measurement is unchanged: one physical fault, zero logical faults. Now replace that single X with a chain of X errors spanning the patch. Interior stabilizers flip in pairs and cancel; only the two boundary stabilizers fire, in the same round. MWPM has two equally short pairings, differing by the logical operator, and picks one. When it picks wrong the residual is a logical X̄, Z̄ flips, and the shot counts as a logical error. The decoder is never asked to find the error, only a correction that differs from it by a stabilizer.

5. Gate on the error budget. Fit p_L ≈ A·(p/p_th)^((d+1)/2). Take p = 1e-3, p_th = 1e-2, A = 1 (illustrative; real prefactors are O(0.1) and shift the absolute numbers, not Λ):

dphysical qubits 2d²−1exponent (d+1)/2p_L per roundΛ
31721e-2—
54931e-310
79741e-410

A 1e6-round run at d = 7 gives 1e-4 × 1e6 = 100 logical errors. To land at 1e-6 per run you need p_L per round ≤ 1e-12, i.e. (d+1)/2 = 12, d = 23: 1057 physical qubits per patch. If the hardware Λ is 2.1 rather than the idealised 10 (Google's 2023 d = 3→5 surface-code experiment reported Λ ≈ 2.1), the same target needs d ≈ 65, or 8449 qubits per patch. That gap, 1057 versus 8449, is the difference between a paper threshold and a device.

Trade-offs. Rotated surface code plus MWPM is the mature choice: ~0.5–1% circuit-level threshold, 2D-local, exact matching. BB/LDPC codes reach roughly 10× better encoding rate but need BP+OSD decoding, have no 2D locality, and are less validated on hardware. Real-time decoders such as Fusion Blossom exist because MWPM must keep up with the round time, on the order of a microsecond per round on superconducting hardware, or the frame falls behind the circuit.

Failure modes. Decoding mid-gate: a partial syndrome during lattice surgery misattributes a measurement error as a data error, corrupting the observable. Ancilla counted as data: flag-qubit measurement errors inflate the apparent logical rate. Dropped frame: silent logical error with no syndrome signature. Detect all three by injecting faults and checking the observable, not the syndrome.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-13

Design and validate a quantum reliability workflow for surface codes.

Answer

What I'd say first. The workflow is: fix the noise model, size the patch, build the syndrome circuit, pick a decoder that fits the cycle budget, then validate by measuring how logical error per cycle scales with distance. That scaling is the whole point. The surface code's threshold is model-dependent: roughly 1% per operation under circuit-level depolarizing noise with minimum-weight perfect matching, a few tenths of a percent once leakage and correlated two-qubit errors are in the model. If logical error per cycle does not fall as distance grows, the design is above threshold and adding qubits makes it worse.

Assumptions. Superconducting transmons: ~1 µs syndrome cycle, two-qubit gate error 0.3%, measurement error 1%, idle error 0.1%. Target: 10⁻⁶ logical error per cycle. Over a 10⁶-cycle run that is ~1 expected failure, so a real algorithm wants ~10⁻⁹ per cycle; I'd size to that.

Geometry. Rotated surface code: d² data qubits plus d²−1 measure qubits, so 2d²−1 total; d=7 is 97 qubits. Distance d corrects ⌊(d−1)/2⌋ errors, so d=7 corrects 3. Logical X is a chain of X operators terminating on the two X-type boundaries; logical Z terminates on the Z-type boundaries. Check the assignment by computing the minimum-weight logical operator: a shortest path between the two same-type boundaries in the matching graph. It must come out at weight d; anything shorter means the boundaries are mis-assigned and the patch is weaker than its size suggests.

Syndrome circuit. Four CNOT layers per round, each measure qubit touching its four neighbours in a fixed order, X and Z stabilizers measured in parallel. Verify in stim: build the circuit, extract the detector error model, and confirm every single-qubit and two-qubit fault fires the detectors it should. stim's shortest_graphlike_error gives the circuit-level distance: it must equal d, not d−1.

Decoder. MWPM (PyMatching) is the accuracy baseline but has to return a correction inside the ~1 µs cycle. Union-find is faster and comes close on threshold, with worse sub-threshold scaling. Neural decoders (Google's AlphaQubit, 2024) beat MWPM on real device data but need retraining as the device drifts. If the decoder can't keep up, buffer syndromes and pay the latency.

Validation: the decisive test. Measure logical error per cycle at d=3, 5, 7 and fit Λ = p_L(d)/p_L(d+2). Under p_L = A(p/p_th)^⌊(d+1)/2⌋, Λ = p_th/p, independent of A. Hypothetical numbers: p = 0.3%, p_th = 1%, so Λ = 3.3. With A = 0.1, p_L(d=7) = 0.1 × 0.3⁴ ≈ 8×10⁻⁴ per cycle. Every two units of distance divide that by 3.3, so 10⁻⁹ per cycle needs ⌊(d+1)/2⌋ = 16, i.e. d ≈ 31: about 1900 qubits per logical qubit before routing and magic-state distillation. Google's 2023 d=3/d=5 experiment reported Λ ≈ 2.14, the shape a working device should show.

DecisionCheckFailure signature
ThresholdRe-simulate with your own error channelsΛ ≤ 1 on hardware while the paper's model predicts Λ > 1
BoundariesCompute the minimum-weight logical operatorWeight < d
LeakageThree-level readout, or repeated flips on one ancilla|2⟩ population grows; threshold drops
Correlated faultsCompare syndrome-weight distribution to the independent-noise predictionExcess high-weight syndromes
OverheadCount 2d²−1 per patch plus routing and distillationBudget assumed d²

In production, track syndrome weight, leakage rate and Λ drift; a drift in Λ is the earliest sign the device has moved.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-14

Design and validate a quantum reliability workflow for repeated syndrome rounds.

Answer

Let me clarify the scenario. We're designing a workflow for repeated syndrome rounds in a quantum error correction cycle. I'll assume a distance-5 surface code, cycle time around 1 microsecond per round, and we run 1000 rounds. The goal is to keep the logical error rate per round below a target that depends on the code distance and physical error rate.

The workflow has four stages: initialization, repeated syndrome extraction, decoding, and validation.

Initialization: Reset all data qubits to |0> and ancilla qubits to |0> or |+> depending on the code. Record the initial state to avoid edge effects.

Repeated syndrome extraction: For each round, apply the syndrome extraction circuit: entangle data and ancilla, measure ancilla. Record measurement outcomes with a round index and timestamp. Retain every round, not just the last one. For a distance-5 surface code, you need at least 5 rounds to decode a single logical operation, but for repeated rounds you just keep cycling.

Decoding: Use a space-time decoder that takes the full history of syndromes. The standard is minimum weight perfect matching (MWPM) on a space-time graph, implemented in PyMatching. But MWPM assumes independent errors; if measurement errors are correlated with data errors, you need a correlated matching decoder, like the one from Google's 2023 Nature paper. The decoder should use change-based decoding: compare consecutive rounds to identify detection events. A data error persists across rounds, so it flips the same stabilizer in consecutive rounds, creating a chain of detection events. A measurement error flips a stabilizer in one round and then flips back in the next, creating two adjacent detection events. This is why you can't trust a single noisy syndrome.

Trade-offs: You can decode per round (fast, low memory) but you ignore temporal correlations, which increases logical error rate. Or you can batch decode all rounds at the end (slow, high memory) but more accurate. For real-time decoding, you need to decode within the cycle time. PyMatching's runtime depends on the number of detection events and the hardware; you must measure it on your target. If it exceeds the cycle time, consider a sliding-window decoder or an FPGA implementation. The deciding criterion: if measurement error rate is comparable to data error rate (e.g., both 0.1%), you need space-time decoding; if measurement errors are negligible, per-round decoding may suffice.

Failure modes:

  • First/last boundary omitted: If you don't include initialization and final measurement, the decoder sees open boundaries and misinterprets errors near the edges. Detection: check that the detection event graph has no dangling edges.
  • Missing round: A dropped syndrome round creates a gap. The decoder must handle missing data, or you lose the ability to correct errors that span that gap. Detection: monitor round timestamps for gaps.
  • Measurement bit flip interpreted as data chain: If you use change-based decoding, a measurement error appears as two detection events, not a chain. If you misinterpret it as a data error, you apply the wrong correction. Detection: compare the pattern of detection events; a measurement error has two events separated by one round, a data error has a chain of events.
  • Temporal correlation ignored: If you decode each round independently, you miss that a data error persists. Detection: measure the logical error rate; it will be higher than expected.

Worked trace: Consider a repetition code with 3 data qubits and 2 ancilla, measuring Z1Z2 and Z2Z3. Initialize to |000>. Round 1: syndromes 00. Suppose a data X error on qubit 2 occurs after round 1. Round 2: syndromes 11. Round 3: syndromes 11. The detection events: round 1->2: both ancilla flip; round 2->3: no change. That's a data error. Now suppose instead a measurement error on ancilla 1 in round 2. Round 1: 00. Round 2: 10. Round 3: 00. Detection events: round 1->2: ancilla 1 flips; round 2->3: ancilla 1 flips back. That's a measurement error. So change-based decoding distinguishes them.

RoundData error on qubit 2Measurement error on ancilla 1
10000
21110
31100
Detection events1->2: both flip; 2->3: none1->2: ancilla 1 flips; 2->3: ancilla 1 flips back

Validation: Use Stim to generate the syndrome measurement circuit and simulate with known error rates, e.g., p=0.001 for both data and measurement. Run 10^6 shots. Compare logical error rate per round for three decoders: per-round MWPM, space-time MWPM, and correlated matching. Set your acceptance criterion based on the code distance and target error rate. For a distance-5 surface code at p=1e-3, simulations give logical error per round around 1e-4 to 1e-3. To reach 1e-6, you need distance roughly 11-15. So if your target is 1e-6, you must use a larger code. Also check the detection event fraction: it should be around 2p per round. If it's much higher, you have a bug in the circuit or decoder. Finally, test boundary conditions: run with 1 round, 2 rounds, and many rounds; ensure the decoder handles the first and last round correctly.

That's the workflow and how to validate it.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-15

Design and validate a quantum reliability workflow for decoder.

Answer

What I'd say first. "Decoder" is underspecified, so I'd pin it down before designing anything: I'll assume MWPM decoding of a rotated surface code, superconducting qubits, circuit-level depolarizing noise, and a syndrome extraction cycle of about 1 µs. The workflow then has three parts: a frozen noise model, an offline harness that measures logical error rate against it, and a real-time path that proves the decoder returns inside the cycle deadline. Validation means each part has a pass criterion that can fail.

Design.

StageArtefactPass criterion
Noise modelDetector error model (DEM) generated from the syndrome-extraction circuitSampled syndrome statistics match the DEM within statistical error
Offline decodeLogical error rate (LER) per round vs code distanceLER falls by a factor Λ > 1 per two distance steps
Real-time pathPer-shot decode latency distributionp99 decode time < cycle budget
Online monitorSyndrome weight and LER over timeNo drift beyond control limits

Validation harness. Stim generates the circuit and its DEM; PyMatching decodes; Sinter samples and fits Λ.

Python
import stim, pymatching
circuit = stim.Circuit.generated(
    "surface_code:rotated_memory_z",
    distance=5, rounds=5,
    after_clifford_depolarization=0.001)
dem = circuit.detector_error_model(decompose_errors=True)
matching = pymatching.Matching.from_detector_error_model(dem)
dets, obs = circuit.compile_detector_sampler().sample(
    shots=100_000, separate_observables=True)
pred = matching.decode_batch(dets)
print((pred != obs).any(axis=1).mean())

The printed value is LER per shot for d=5 at p=0.001. Run the same script at d=3 and d=7 with the same seed policy and fit Λ; the workflow passes only if Λ > 1 across the range you care about. Google's 2023 d=3→5 surface-code experiment reported Λ ≈ 2.1, so a decoder that shows Λ ≈ 1 is not decoding, it's guessing.

Latency arithmetic. If the cycle is 1 µs and measurement plus control eats ~400 ns, the decoder budget is ~600 ns. A batch decoder that takes 10 µs per shot is 16× over budget; the backlog grows without bound and corrections get applied to stale syndromes. Measure the p99, not the mean: a decoder that is fast on average and slow on the hard syndromes is the one that fails in production.

Failure modes and how to catch them.

  • Model mismatch: leakage, crosstalk or correlated noise absent from the DEM. Detect by injecting a known correlated model and checking the decoder's LER degrades as predicted; if it doesn't, the DEM is wrong.
  • Stale calibration: drift in the syndrome weight distribution. Track mean syndrome weight per round against a control limit.
  • Double correction: the Pauli frame applied both in the decoder and the control path. Detect with a parity check on the accumulated frame.
  • Train/test leakage: tuning decoder weights on the shots used to report LER. Hold out a fresh seed and report on it.

Trade-offs. MWPM is fast and near-optimal for surface codes but assumes independent errors. BP+OSD handles hypergraph and correlated noise better at higher latency. Neural decoders can hit FPGA latency but need retraining whenever the noise model shifts, which is exactly the drift the online monitor is there to catch.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-16

Design and validate a quantum reliability workflow for Pauli frame.

Answer

Core answer

Assume a stabilizer code (surface code, distance d) whose decoder returns a Pauli correction per round, and a control stack that can either apply that correction as physical gates or record it as a Pauli frame. The design is: record, don't apply. The frame is a 2n-bit classical register: one X and one Z component per qubit. Propagate it through every Clifford gate with the conjugation rules, flip measurement outcomes where the frame has X or Y on the measured qubit, and materialize the frame as physical gates only when a non-Clifford gate forces it or at final readout.

Why it works, and where it breaks

Clifford gates conjugate Paulis to Paulis, so the frame update is a classical lookup with no quantum cost. CNOT: X on the control becomes X on control and target; Z on the target becomes Z on control and target. H swaps X and Z. S sends X to Y. A Z-basis measurement flips its reported bit if the frame holds X or Y on that qubit, and is unchanged for Z or I.

T is the wall. T X T† = (X+Y)/√2, which is not a Pauli, so a pending frame cannot be propagated through a T gate. Two options: apply the physical correction before the T (one extra gate, order 10⁻³ error per single-qubit gate on current superconducting hardware), or inject the T by gate teleportation, where the frame update becomes a conditional S driven by the injection measurement. Surface-code architectures use the second.

Worked trace

Circuit: H(q0); CNOT(q0,q1); M(q0); M(q1). The decoder reports correction X on q0.

stepframe state
startI on q0, I on q1
apply frame X_q0X on q0
after CNOTX on q0, X on q1
measure q0X present → flip reported bit
measure q1X present → flip reported bit

Raw 00 corrects to 11; raw 11 corrects to 00. The Bell correlation survives, which is the property the frame must preserve.

Validation

Three layers. First, unit-test the propagation rules against a reference frame simulator: Stim's FrameSimulator tracks Pauli frames through Clifford circuits, and the frame bitstrings must match exactly on random Clifford circuits. Second, equivalence: run the same circuit once with explicit physical corrections and once with frame tracking; the corrected logical outcome distributions must agree within shot noise (total variation distance below ~0.01 over 10⁵ shots). Third, fault injection: place a known Pauli at a known location, confirm the frame records it and the corrected outcome is unchanged.

Failure modes and detection

  • Frame lost across a job boundary: logical error rate jumps at boundaries; detect by per-boundary logical error rate.
  • Non-Clifford update mishandled: a T gate applied with a pending frame gives a deterministic logical error; detect by comparison to a reference simulation.
  • Decoder race: frame applied before the decoder returns; detect with a frame version counter and timestamps.
  • Bit mapping mismatch: frame bit order disagrees with qubit index order, producing correlated logical errors; detect with a known-state test (prepare |0⟩, inject X, check the corrected bit).
  • Stale correction: a frame from a previous round is applied; detect with the same version counter.

Trade-off

Frame tracking saves one gate per correction, and each saved gate avoids its own error and latency. The cost is that the correction is deferred, so the frame must survive the whole circuit and every job boundary, and it cannot cross a non-Clifford gate without extra machinery. Fall back to physical correction when T-gate density is high enough that the frame materializes almost every round, or when the decoder reports non-Pauli errors the frame cannot represent.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-17

How do faults propagate through a fault-tolerant circuit, and what determines whether a single fault can spread to multiple qubits within a code block?

Answer

What I'd say first. Fault tolerance is a statement about fault spread: a circuit is fault-tolerant if a single fault anywhere in it produces at most one error per code block, and t-fault-tolerant if t faults produce at most t errors per block. Everything else (transversal gates, cat states, flag qubits, CNOT ordering) is machinery to enforce that bound. Assume a distance-d stabilizer code, circuit-level depolarizing noise at rate p, and a decoder that corrects up to ⌊(d−1)/2⌋ errors per block.

Where spread comes from. Errors spread only through entangling gates. A CNOT copies X from control to target and Z from target to control. So a single-qubit fault on a qubit that is about to be the control of k more CNOTs becomes an error on k+1 qubits. Two design rules follow: never let one physical qubit touch more than one qubit per code block in a logical gate, and never let an ancilla that has already interacted with data interact with more data before it is measured or verified.

Transversal gates. A transversal logical gate is a tensor product of physical gates each acting on at most one qubit per block. Transversal CNOT between blocks A and B is d physical CNOTs pairing qubit i of A with qubit i of B. A fault on one of those CNOTs puts one error in A and one in B: weight 1 per block, correctable. Transversal single-qubit gates cannot spread at all. The catch is Eastin–Knill: no code admits a transversal universal gate set, so T is done by magic-state injection, and that gadget needs its own spread analysis.

The hook error. The interesting case is syndrome extraction with a shared ancilla. Take a weight-4 Z stabilizer Z1Z2Z3Z4 measured with one ancilla a: prepare a in |0>, then CNOT d1→a, d2→a, d3→a, d4→a, measure a in Z. Suppose an X fault hits a after the second CNOT. X on the ancilla propagates back through the remaining CNOTs: through d3→a it becomes X on d3 and X on a; through d4→a, X on d4 and X on a. Net result: X on d3 and d4, a weight-2 data error, plus a flipped syndrome bit. For d=3 that weight-2 error is uncorrectable; it is indistinguishable from a weight-1 error on a different qubit. This is a hook error, and it is why a naive single-ancilla extraction circuit is not fault-tolerant.

What fixes it.

GadgetWorst-case spread per blockMechanism
Transversal CNOT, blocks A↔B1 error in A, 1 in Beach physical CNOT touches one qubit per block
Transversal single-qubit gate1 errorno coupling
Single-ancilla weight-4 extractionup to 3 data errorsancilla fault propagates through remaining CNOTs
Verified cat-state ancilla≤1 data errorverification rejects any ancilla with ≥1 fault
Flag-qubit extraction≤1 data error, flag raisedflag catches the hook, decoder uses it

Three levers. Gate ordering: in the rotated surface code the CNOT order is chosen so the hook is a straight line of weight ≤ (d−1)/2, which the code can still correct. The hook is a correctable error, not a logical one. Ancilla preparation: for weight-w stabilizers, prepare a w-qubit cat state |0…0>+|1…1>, verify it by measuring the parity of adjacent pairs, and discard and reprepare if any check fails; a verified cat state has at most one fault, so it spreads at most one error to data. Flag qubits: a single flag qubit coupled to the ancilla at the right points catches the hook and tells the decoder to treat that syndrome bit as unreliable.

Failure modes. An unverified cat state is the classic one: a fault during preparation becomes a weight-2 data error and the decoder silently mis-corrects. Reset errors on the ancilla leak the previous round's error into the next. A non-transversal logical gate (lattice surgery, code deformation) reintroduces spread inside a block and needs its own analysis. Leakage out of the computational subspace is not a Pauli error and propagates differently; it needs leakage-reduction units. Detection: track the fraction of shots where the decoder's correction has weight above ⌊(d−1)/2⌋, and the flag rate; both should scale with p, not with d.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-18

Design and validate a quantum reliability workflow for transversal gates.

Answer

Assumptions first. I'll assume a stabilizer code with a fault-tolerant logical layer: Steane [[7,1,3]] as the concrete example, noting where the surface code differs. Physical error rate sits below the code's threshold, and we want a universal logical gate set. The constraint that shapes the whole workflow is East–Knill (Eastin & Knill, PRL 102, 110502, 2009): no quantum code admits a universal set of transversal gates. So the job is not "find a code with transversal universality": it is enumerate what is transversal, validate it, and supply the rest by magic-state injection.

Step 1: Enumerate the transversal set. For Steane, that set is the Clifford group: H⊗7, S⊗7, and transversal CNOT between corresponding qubits of two blocks. For the surface code, only transversal CNOT between patches is available; H and S are not. Bravyi–König (PRL 110, 170503, 2013) explains why: for 2D local stabilizer codes, transversal gates are contained in the Clifford group.

codetransversal gatesmissing for universality
Steane [[7,1,3]]H, S, CNOT (Clifford)T
Surface codeCNOT between patchesH, S, T
Reed–Muller [[15,1,3]]T, CNOTH, S

Step 2: Validate each transversal gate. A transversal gate g is valid iff it maps the stabilizer group to itself: g S g† = S for every generator. For Steane's H⊗7, conjugating each generator swaps the X-type and Z-type sets, so it realises logical H. Check this generator by generator, then confirm the gate acts as the intended logical operator on the codespace.

Step 3: Supply the missing non-Clifford gate. T is not transversal in Steane. Prepare noisy |T⟩ = T|+⟩ states, distill with the 15-to-1 Reed–Muller protocol, then inject by gate teleportation.

Worked trace of T-gate teleportation. Data |ψ⟩ = α|0⟩ + β|1⟩, ancilla |T⟩ = (|0⟩ + e^{iπ/4}|1⟩)/√2.

  1. CNOT(data → ancilla): [α|00⟩ + αe^{iπ/4}|01⟩ + β|10⟩ + βe^{iπ/4}|11⟩]/√2
  2. Measure ancilla in Z:
    • m=0: α|0⟩ + βe^{iπ/4}|1⟩ = T|ψ⟩
    • m=1: αe^{iπ/4}|0⟩ + β|1⟩; apply S → e^{iπ/4}(α|0⟩ + βe^{iπ/4}|1⟩) = e^{iπ/4} T|ψ⟩ So the correction is S on m=1.

Distillation arithmetic: 15-to-1 Reed–Muller gives p_out ≈ 35 p_in³. With p_in = 10⁻³, p_out ≈ 3.5×10⁻⁸: below the ~10⁻⁶ target for a logical T.

Step 4: Validate the workflow end to end. Run fault-injection simulation: inject one fault per location, confirm the logical error rate scales as p^(⌊d/2⌋+1) = p² for d=3, and measure the threshold.

Failure modes and detection.

  • Leakage: a transmon leaking to |2⟩ is not corrected by the code and propagates through transversal gates. Detect with leakage-detection measurements; mitigate with leakage-reduction units.
  • Correlated/crosstalk errors: transversality assumes independent faults, but simultaneous pulses cause correlated errors. Detect with cycle benchmarking; the correlated rate can exceed the independent rate by an order of magnitude.
  • Block misalignment: transversal CNOT requires matching qubit ordering; a wrong permutation applies CNOT to wrong pairs. Detect by verifying the permutation before the gate.
  • Logical phase convention: the S correction depends on the magic state's phase convention; a sign error gives a logical error. Detect by tomography of the injected state.

Trade-off: distillation vs code switching. Distillation keeps one code but spends 15 T states and roughly 15× the physical qubits per logical T. Code switching (e.g., surface ↔ color code) uses a code with transversal T but pays a conversion cost and needs both decoders. Choose distillation when the code is fixed and T demand is low; choose switching when T count is high enough to amortise the conversion.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-19

Design and validate a quantum reliability workflow for magic states.

Answer

Core answer. "Magic state reliability" is two problems glued together: getting the logical error per T state under the algorithm's budget, and delivering those states fast enough that the algorithm never waits. Assume a surface-code architecture, raw T-state error p = 10⁻³, and an algorithm with 10⁹ T gates and a 1% total error budget. That budget sets the target: each T state must be good to ≤ 10⁻¹¹. That number drives the protocol choice, not the other way round.

Design. Use Bravyi–Kitaev 15-to-1 distillation ([[15,1,3]] Reed–Muller code, 2005): 15 noisy inputs, one output, output error ≈ 35p³. The cascade:

levelinput erroroutput erroracceptance
0 raw10⁻³——
110⁻³35·(10⁻³)³ = 3.5×10⁻⁸≈ 1 − 15p ≈ 0.985
23.5×10⁻⁸35·(3.5×10⁻⁸)³ ≈ 1.5×10⁻²¹≈ 1

One level misses the 10⁻¹¹ target by ~3500×; two levels overshoot it by ten orders of magnitude, which is where to stop: the cubic law stops holding once Clifford-gate error floors the output. Cost is 15² = 225 raw states per final state, ~230 once the level-1 rejection rate is counted.

The factory is a dedicated surface-code block running that circuit continuously. Match rates: if the algorithm consumes one T every 100 ns and one factory produces one every 1 µs, you need ten factories, or the algorithm stalls and the factory sets the runtime. Routing a state from factory to consumption site is lattice surgery along a path, roughly d cycles per patch crossed at distance d; keep factories adjacent to the consuming block or routing latency dominates.

Validate. Four measurements, in order. Characterize p_in by randomized benchmarking or a distillation experiment. Check the measured acceptance rate against 1 − 15p; a mismatch means correlated or miscalibrated inputs. Measure the distilled output error by injecting the state into a small circuit with a classically known answer and compare to 35p³. Instrument the schedule and confirm produced-per-cycle ≥ consumed-per-cycle. Simulate the Clifford skeleton in stim and model the T injection separately.

Trade-offs. 15-to-1 is the default: cubic suppression, well characterized, but 15 logical input slots per round is a lot of qubits. 10-to-2 (Meier–Eastin–Knill 2012) yields two states per round from a more complex circuit: better when input states are the scarce resource. Cultivation (Gidney–Fowler 2019) trades time for qubits and wins when qubit count, not latency, binds. Extra distillation levels buy suppression at 15× the input cost each; if p_in is already 10⁻⁴, one level may suffice and you should not pay for two.

Failure modes. Correlated inputs: 35p³ assumes independent errors, so 15 inputs sharing a physical source give a higher true output error. Detect by comparing measured p_out to the model. Post-selection: accepted states are conditioned on trivial syndrome, so the accepted sample is not representative; ignore the rejection rate and you under-provision factories. Bottleneck: a production/consumption mismatch shows up as idle cycles in the schedule. Byproduct frame: T injection leaves an S correction conditioned on the ancilla measurement; if the classical frame tracker drops or mis-orders that outcome, the logical state is silently wrong. Detect with a known-T-count circuit checked against simulation.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-20

Design and validate a quantum reliability workflow for threshold theorem.

Answer

Core answer (first 90 seconds). "Threshold" is not a device number. The threshold theorem says: for a fixed noise model and a fixed fault-tolerant scheme, there exists a p_th such that if every fault location fails with probability p < p_th, the logical error rate can be driven arbitrarily low by growing the code distance, at polylog overhead. So the workflow is: pin the noise model, pick the scheme, measure p against that model, then demonstrate suppression with distance. If any of those four is mismatched, the theorem does not apply to your machine and the number you quote is meaningless.

State the assumptions up front: (1) faults are local and Markovian; (2) faults are independent per location; (3) the decoder is ideal, or its latency is bounded below the cycle time; (4) leakage and correlated errors are either negligible or actively converted back to Pauli errors.

Design.

  1. Fix the model. Code-capacity (data qubits only), phenomenological (data + measurement), or circuit-level (every gate, idle, prep, measurement). Thresholds differ by roughly an order of magnitude across these, so the model is the first decision, not an afterthought.
  2. Pick code + decoder matched to the model. Surface code with MWPM or a matching-based decoder; 2D color code if you need transversal Clifford gates; qLDPC if you need high encoding rate and can afford a heavier decoder.
  3. Estimate p from the device. Randomized benchmarking for gate error, separate measurement-error characterization, and an explicit leakage measurement (population outside the computational subspace).
  4. Simulate at d = 3, 5, 7, 9 under the chosen model, with the real decoder, not a lookup table.
  5. Validate scaling. Fit logical error rate p_L(d) and extract the suppression factor Λ per distance step. Sub-threshold means p_L falls monotonically with d; if it flattens, you are at or above threshold regardless of what the datasheet says.

Thresholds by model (approximate, from the primary literature).

ModelSurface code2D color code
Code-capacity~10% (Dennis et al. 2002)~10%
Phenomenological~2.9% (Raussendorf & Harrington 2007)~1%
Circuit-level~0.5–1% (Fowler et al. 2012, ~0.57% for standard depolarizing circuit noise)~0.2–0.5%

Worked arithmetic. For the surface code, p_L ≈ A·(p/p_th)^((d+1)/2). Take p = 0.1%, p_th = 0.6%, A ≈ 0.03. Then p/p_th = 1/6.

  • d = 3: (1/6)² = 0.028 → p_L ≈ 8×10⁻⁴
  • d = 5: (1/6)³ = 4.6×10⁻³ → p_L ≈ 1.4×10⁻⁴
  • d = 7: (1/6)⁴ = 7.7×10⁻⁴ → p_L ≈ 2.3×10⁻⁵

Λ ≈ 6 per two distance steps. That is the number to defend: it is what tells you whether adding qubits buys anything.

Failure modes and how they show up.

  • Leakage: transmon |2⟩ population breaks the Pauli assumption; p_L stops falling with d. Detect by measuring leakage per cycle, not just RB error.
  • Correlated / crosstalk errors: violate independence; the effective p is higher than the per-gate number. Detect by comparing simultaneous-gate RB to isolated-gate RB.
  • Decoder latency: if decoding takes longer than a syndrome cycle, the backlog becomes an error source. Detect by measuring decode time against cycle time.
  • Finite-size crossover: below d ≈ 5–7 the asymptotic scaling is not visible; a flat curve there is not evidence of being above threshold.

Trade-offs. Surface code: highest circuit-level threshold, planar layout, but k = 1 logical qubit per patch and no transversal non-Clifford. Color code: transversal Clifford, lower threshold, harder decoding. qLDPC: much higher encoding rate, lower threshold, decoder cost dominates. Choose by which constraint binds first: threshold margin, gate set, or qubit budget.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-21

Design and validate a quantum reliability workflow for break-even.

Answer

Break-even is ambiguous, so pin it down first. Two definitions matter: (1) a logical qubit's error per cycle beats the best physical qubit on the same device; (2) it beats a matched ensemble of the N physical qubits spent to build it, after encoding, decoding and measurement overhead. Design for (2): (1) is necessary but not sufficient, because you can beat one physical qubit and still lose to the 97 you spent.

Assumptions: superconducting transmons, rotated surface code, MWPM decoder, Clifford-plus-measurement workload. Non-Clifford gates or a color code change the numbers, not the workflow.

Stage 1: freeze the workload. Circuit depth, gate set, measurement schedule, and the physical baseline: the best N physical qubits running the same circuit, not one qubit idling.

Stage 2: measure p_L at d = 3, 5, 7. Same shots per distance, same decoder, disjoint syndrome sets for training and evaluation.

Stage 3: fit Λ and check monotonicity.

Stage 4: compare to the baseline with pre-registered CIs and a discard cap.

Here is the arithmetic, as a script I would actually run:

Python
# python 3.11
from math import sqrt

def wilson(k, n, z=1.96):
    p = k / n
    denom = 1 + z*z/n
    centre = p + z*z/(2*n)
    half = z * sqrt(p*(1-p)/n + z*z/(4*n*n))
    return (centre - half)/denom, (centre + half)/denom

runs = {3: (1_000_000, 6550), 5: (1_000_000, 3060), 7: (1_000_000, 1430)}
prev = None
for d in sorted(runs):
    n, k = runs[d]
    lo, hi = wilson(k, n)
    lam = "" if prev is None else f"  Lambda={prev/(k/n):.2f}"
    print(f"d={d}  p_L={k/n:.5f}  95% CI=[{lo:.5f}, {hi:.5f}]{lam}")
    prev = k/n

Output:

d=3  p_L=0.00655  95% CI=[0.00639, 0.00671]
d=5  p_L=0.00306  95% CI=[0.00272, 0.00340]  Lambda=2.14
d=7  p_L=0.00143  95% CI=[0.00136, 0.00151]  Lambda=2.14

The counts are hypothetical, chosen so Λ matches the published value; the estimator is the real one. Hand-check the d=7 row: p = 1430/10^6 = 0.00143, and the Wilson half-width is 1.96·√(0.00143·0.99857/10^6 + 1.96²/(4·10^12)) = 7.41e-5, giving [0.00136, 0.00151]. Λ = 0.00306/0.00143 = 2.14.

Now the baseline. A d=7 rotated surface code uses 2d²−1 = 97 physical qubits. If the best physical qubit on the device has error per cycle p_phys = 0.3% (hypothetical), the logical qubit at 0.143% beats it by 2.1×. Against the 97-qubit ensemble, which fails if any member fails, the ensemble error per cycle is 1 − (1 − 0.003)^97 = 25.3%, so the logical qubit wins by 177×. Both numbers go in the report; the single-qubit comparison is the one that can fail.

Why it works: below threshold, p_L ≈ A(p/p_th)^((d+1)/2), so each +2 in d suppresses p_L by Λ = p_th/p. Google's Willow (Nature, Dec 2024) reported Λ = 2.14 ± 0.02 and a d=7 logical error per cycle of 0.143% ± 0.003%, with the d=7 logical qubit below the device's best physical qubit. Above threshold Λ < 1 and adding distance makes things worse, so the first check is always: is p_L monotonically decreasing in d?

Design choices. Post-selection: discarding shots with high syndrome density or detected leakage lowers p_L but costs shots and biases the estimate if the rule is chosen after seeing the data. Pre-register the rule, report p_L with and without it, and if the discard rate exceeds 10% the post-selected number is not the headline. Decoder: MWPM is the baseline; correlated matching or a neural decoder can lower p_L on the same syndromes, but must be trained on a disjoint syndrome set.

checkpassfailhow it's detected
thresholdp_L falls d=3→5→7, Λ > 1flat or risingmonotonicity test on the three points
baselinebeats best N physical, matched depthbeats one idling qubitrecompute baseline as best-of-N
post-selectiondiscard ≤ 10%, both numbers reported> 10%, only post-selecteddiscard-rate counter
decodertrained on disjoint syndromestrained on eval syndromesholdout audit
metricpre-registered, same both armsswitched mid-runcompare against the pre-registration
uncertainty95% CIs disjointCIs overlapthe Wilson intervals above

If all six pass, declare break-even for that workload. If not, report the gap and the dominant error source (leakage, erasure, or measurement error) and the distance at which it would close.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-22

Design and validate a quantum reliability workflow for suppression.

Answer

Core answer (first 90 seconds)

"Suppression" here means dynamical decoupling: filling idle windows with π-pulse sequences so quasi-static dephasing is refocused. The workflow has four steps: characterize the qubits you will idle, pick a sequence that matches the noise spectrum and your pulse-error budget, insert it with the scheduler, then validate it on the real circuit against DD-off, reporting the distribution across the device rather than the best qubit.

Assumptions: superconducting transmons on a fixed lattice, Qiskit 1.x with qiskit-ibm-runtime, and a circuit with measurable idle windows (a surface-code memory experiment, or a wide shallow circuit).

Mechanism

A π pulse flips the qubit, so phase accumulated from a slowly varying frequency offset reverses sign and cancels across the sequence. That refocuses dephasing (T2* → T2 echo). It does nothing for amplitude damping: a relaxation event is not a phase that can be undone. The sequence also acts as a low-pass filter: noise slower than roughly 1/(2τ), where τ is the pulse spacing, is not refocused.

Workflow

  1. Characterize T1, T2* (Ramsey) and T2 echo (Hahn) on every qubit you plan to idle.
  2. Pick the sequence. XY4 is the default: it cancels π-pulse amplitude error to first order. CPMG filters better when pulse calibration is tight, but its error grows linearly with pulse count. XX (XpXm) is the cheap check.
  3. Insert it. In Qiskit Runtime:
Python
estimator.options.dynamical_decoupling.enable = True
estimator.options.dynamical_decoupling.sequence_type = "XY4"
estimator.options.dynamical_decoupling.skip_reset_qubits = True

The transpiler-level equivalent is PadDynamicalDecoupling after ALAPScheduleAnalysis. skip_reset_qubits matters: you do not want DD on a qubit being measured or reset.

  1. Validate against DD-off on the same circuit, same shots, same qubits: the logical error rate of a memory experiment, or a repeated-idle circuit measured in X and Z.

Worked check (illustrative numbers)

Idle window 40 µs, T2* = 20 µs, T2 echo = 120 µs, T1 = 100 µs, π pulse 40 ns, XY4 with τ = 1 µs.

  • No DD: coherence ≈ exp(−(40/20)²) ≈ 0.02. Essentially gone.
  • XY4: 10 blocks × 4 pulses = 40 pulses, 40 × 40 ns = 1.6 µs overhead, 4% of the window. Noise below 1/(2τ) = 500 kHz is not refocused.
  • T1 floor: exp(−40/100) = 0.67, so ~33% relaxation error survives whatever DD does. If DD-on and DD-off curves converge there, you are T1-limited, not dephasing-limited.
  • Pulse error: with 1% π-amplitude error, CPMG accumulates ~Nε ≈ 0.4 rad over 40 pulses; XY4 leaves ~Nε² ≈ 4×10⁻³ rad.

Failure modes and detection

failuredetection
T1 loss claimed as correctedT1 experiment with the same DD inserted; if the residual tracks exp(−t/T1), DD is not the fix
timing collisionschedule analysis: count idle windows shorter than the sequence; check for overlap with a neighbour's two-qubit gate
stale π calibrationinterleaved RB of the π pulse; repeated-pulse error vs N (CPMG degrades first)
crosstalksimultaneous RB on adjacent pairs, DD on vs off
best-only reportingreport median and worst-qubit improvement, not the maximum

When not to use it

Skip DD when the idle window is shorter than the sequence, when T1 dominates, when the device has strong ZZ crosstalk (DD pulses on one qubit shift a neighbour's phase), or when the circuit has almost no idle time. DD is physical-layer suppression, complementary to mitigation such as ZNE or PEC: it is not error correction and does not create a logical code.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-23

Design and validate a quantum reliability workflow for mitigation.

Answer

Core answer (first 90 seconds). Assume a near-term gate-based device, no logical qubits, and the deliverable is an expectation value ⟨P⟩ of a Pauli observable with an error bar. The workflow is characterize → choose → design → validate. Validation is what makes it a workflow rather than a recipe: you pre-register the fit family and the shot budget, then check that the noise scaling the extrapolation assumes actually holds. If it does not, you report the model spread, not the extrapolated point.

Characterize. Randomized benchmarking per gate plus readout calibration. What you are testing is uniformity: if error rates differ across qubits or drift over the run, ZNE's single-λ scaling assumption is false and extrapolation is meaningless.

Choose. For expectation values ZNE is the default: fold the circuit to noise factors λ = 1, 3, 5 by inserting G†G pairs, fit E(λ), extrapolate to λ = 0. PEC is unbiased but its sampling overhead is Γ² with Γ = ∏ᵢ γᵢ; for a depolarizing channel with error rate p, γ = (1+2p/3)/(1−4p/3) ≈ 1+2p. The exponent is the whole story:

gates, p = 0.01 eachγΓoverhead Γ²
201.02031.492.2×
1001.02037.4455×
10001.02035.2×10⁸2.7×10¹⁷

CDR regresses on Clifford circuits with known results and assumes the noise channel is similar between training and target.

Design. Global folding gives λ = 1 + 2k for k = 0, 1, 2. Pick λ that span enough range without killing the signal. Shots: statistical error falls as 1/√N and the signal decays with λ, so the SE at the largest λ is the largest. Weight shots there. Pre-register the fit family: linear, quadratic, exponential, Richardson. Richardson assumes a polynomial and amplifies variance; exponential assumes exponential decay, more stable but biased if the true decay is not exponential.

Worked example.

Python
# Python 3.11, numpy 1.26
import numpy as np

def fold_scales(k_max):
    # global folding C -> C (C^dag C)^k gives noise factor 1 + 2k
    return np.array([1 + 2 * k for k in range(k_max + 1)], dtype=float)

def zne(lams, vals, ses):
    X = np.vstack([np.ones_like(lams), lams]).T
    coef, *_ = np.linalg.lstsq(X, vals, rcond=None)
    exp_coef, *_ = np.linalg.lstsq(X, np.log(vals), rcond=None)
    XtX_inv = np.linalg.inv(X.T @ X)
    cov = XtX_inv @ (X.T @ np.diag(ses**2) @ X) @ XtX_inv
    return coef[0], np.sqrt(cov[0, 0]), np.exp(exp_coef[0])

lams = fold_scales(2)                       # [1. 3. 5.]
vals = np.array([0.80, 0.65, 0.55])
ses  = np.sqrt((1 - vals**2) / 10_000)      # shot noise, N = 10^4
lin0, lin_se, exp0 = zne(lams, vals, ses)
print(lams)
print(round(lin0, 4), round(lin_se, 4), round(exp0, 4))

Output:

[1. 3. 5.]
0.8542 0.0078 0.8726
λE(λ)SE (N = 10⁴)
10.800.0060
30.650.0076
50.550.0084

Linear extrapolation to λ = 0 gives 0.8542 ± 0.0078; exponential gives 0.8726. The two models disagree by 0.018, larger than the statistical error. That gap is model uncertainty, and it is the number to quote against the target error bar. If the target is 0.01, three points and two models are not enough: add λ = 7 or fix the model from a pilot run.

Validate. (a) Uniformity: plot E(λ) per qubit and per gate type; if slopes differ by more than the fit SE, do not extrapolate. (b) Fit family: compare models on held-out λ or by cross-validation, report the spread. (c) Shots: bootstrap; if the extrapolated error bar is smaller than the input error bars, you have ignored covariance. (d) Physical range: a Pauli expectation must land in [−1, 1]. (e) Non-foldable ops: mid-circuit measurement, reset, and non-unitary gates cannot be folded. Exclude them or switch mitigation.

Failure modes.

SymptomDetectionAction
Non-uniform scalingper-qubit slopes differ by > fit SEdon't extrapolate; report per-qubit or switch
Unstable extrapolationlarge variance across bootstrap resamplesadd λ points, fix model
Shrunk uncertaintybootstrap SE > analytic SEcovariance ignored; use bootstrap
Fit selection biasbest fit chosen post hocpre-register or cross-validate
Out-of-rangeE(0) ∉ [−1, 1]model wrong; report the violation

Trade-off. ZNE is cheap but biased; PEC unbiased but expensive; CDR cheap but assumes noise similarity. Pick by acceptable bias against sampling budget.

Curated: · Written: · Reviewed:

Difficulty: Hard
Q&A-24

Design and validate a quantum reliability workflow for logical resource estimates.

Answer

Assumptions: superconducting qubits, physical error p = 1e-3, surface-code threshold p_th ≈ 1e-2, target 1e-12 logical error per operation, 15-to-1 magic-state factory, algorithm = 100 logical qubits and 1e9 T gates. All figures hypothetical, for illustration.

The workflow is compile → map → validate, with a cross-check gate between stages: no estimator output is trusted until a second method reproduces it.

Compile. Pull logical qubit count, T-count, T-depth and measurement count from QIR or Q#. The output is a logical circuit: no physical numbers yet.

Map. Choose code distance d so that d · p_L ≤ 1e-12, where p_L ≈ 0.03 (p/p_th)^((d+1)/2) is the per-syndrome-cycle logical error and a logical operation spans ~d cycles. Search the odd distances:

Python
def per_op_error(d, p=1e-3, p_th=1e-2, prefactor=0.03):
    return d * prefactor * (p / p_th) ** ((d + 1) / 2)

for d in range(3, 32, 2):
    e = per_op_error(d)
    print(d, f"{e:.2e}", "PASS" if e <= 1e-12 else "fail")

Trace: d=17 → 17 × 3e-11 = 5.1e-10 fail; d=19 → 5.7e-11 fail; d=21 → 6.3e-12 fail; d=23 → 23 × 3e-14 = 6.9e-13 PASS. So 23 is the smallest odd distance that meets budget.

d(d+1)/2p_L/cycleper-op errorphys/logical (2d²)100 logical
1793e-115.1e-1057857,800
23123e-146.9e-131058105,800
27143e-168.1e-151458145,800

At d=23: 100 logical qubits = 105,800 physical. A 15-to-1 factory is 15 logical qubits = 15,870 physical; 10 factories = 158,700. Runtime: 1e9 T gates / 10 factories = 1e8 per factory; one T state per d cycles = 23 µs at 1 µs/cycle, so 1e8 × 23 µs ≈ 2300 s ≈ 38 min.

Validate. Three independent checks.

  1. Cross-check the same QIR with Azure Quantum Resource Estimator. A physical-qubit or runtime figure differing by more than ~10% means the layout or noise model is wrong.
  2. Simulate the code and measure the logical error rate directly:
Python
import stim, pymatching, numpy as np

def logical_error_rate(d, p, rounds, shots=100_000):
    circuit = stim.Circuit.generated(
        "surface_code:rotated_memory_z", distance=d, rounds=rounds,
        after_clifford_depolarization=p,
        before_measure_flip_probability=p,
        after_reset_flip_probability=p,
    )
    dem = circuit.detector_error_model(decompose_errors=True)
    matching = pymatching.Matching.from_detector_error_model(dem)
    det, obs = circuit.compile_detector_sampler().sample(shots, separate_observables=True)
    pred = matching.decode_batch(det)
    P = np.mean(pred[:, 0] != obs[:, 0])
    return (1 - (1 - 2 * P) ** (1 / rounds)) / 2   # per-round rate

At d=23, p=1e-3, the per-round rate should land near 3e-14; higher means raise d. 3. Apply yield: at 90% physical-qubit yield, 105,800 / 0.9 ≈ 117,500. Then add I/O (classical control, cryogenic wiring, measurement feedback) which adds latency and qubits.

Trade-offs. d=27 costs 1458 physical per logical, 38% more than d=23, for two more orders of logical suppression. Each extra factory cuts runtime linearly and adds 15,870 qubits. MWPM decodes more accurately but slower than union-find; at 1 µs cycles MWPM latency is tight, so parallel decoders per logical qubit are usually needed.

Failure modes and detection.

  • Logical = physical: compare estimator output to the naive count; the miss is a 2d² = 1058× underestimate.
  • Decoder compute ignored: measure decoder latency against cycle time; a 10 µs decoder on a 1 µs cycle needs ~10 parallel decoders per logical qubit or runtime blows up.
  • Factories free: count factory qubits and cycles; the miss is 15× per factory.
  • Yield ignored: divide by yield; the miss is 10–20% more qubits.
  • Error independence assumed: simulate correlated errors (leakage, cosmic rays); logical error comes out above prediction.
  • I/O excluded: include classical control and wiring; the miss is added latency and qubits.

Curated: · Written: · Reviewed:

Difficulty: Hard