Quantum Computing · Part D — 15

Thresholds & Magic

The surface code can fix errors — but only if your hardware is good enough to begin with. There is a sharp line, the threshold: cross to the good side and making the code bigger crushes the error rate exponentially; stay on the bad side and bigger only makes things worse. Then one last gap: stabilizer codes can’t do every gate for free. The missing piece is magic.

↩ before you start · keep these handy
·From QC 14: distance d sets the code’s toughness, and a tile costs ≈ d² physical qubits.
·From QC 13: stabilizer codes only handle Clifford gates (H, S, CNOT) natively.
·From QI 11: real devices have per-operation error rates of roughly 0.1–1%.
🔑 symbol decoder · every new mark, in plain words
p (physical)the chance any single physical operation goes wrong — your hardware’s raw error rate. pₗ (logical)the chance the whole encoded qubit fails after error correction — what you actually care about. pₜₕ (threshold)the magic line. If p < pₜₕ, growing the code drives pₗ toward zero. The surface code’s is about 1%. Clifford gateH, S, CNOT — the gates a stabilizer code can apply cheaply and fault-tolerantly. T gatea 45° phase turn — a non-Clifford gate. You need it for universal computing, and the code can’t do it for free. magic statea special pre-cooked qubit that, when fed in, lets you perform a T gate — manufactured by distillation.
feel

A line in the sand

Adding more qubits to a code is a bet. On one side of the threshold the extra qubits help: each step up in distance multiplies your reliability, and the logical error rate plummets. On the other side they hurt: more qubits just means more places to fail, so a bigger code is a worse code. The threshold theorem says this line is sharp and that, once you’re safely below it, arbitrarily reliable computation is possible — you simply pay in qubits.

🏛️ everyday picture

Think of bailing water from a boat. If you can scoop faster than the leak lets water in, then a bigger bucket (more effort) keeps you ever drier — you’ll never sink. But if the leak outpaces you, a bigger bucket just tires you out faster while the boat fills anyway. The leak rate is your hardware error p; your bailing skill is the threshold. Beat the threshold and effort pays off without limit; fall short and no amount of effort saves you.

recapBelow threshold, bigger code → exponentially lower error. Above it, bigger code → worse. The line is sharp.
play

Cross the threshold

Drag your hardware’s physical error rate p. The three curves are surface codes of distance 3, 5 and 7. Watch what happens as you slide past the threshold (the dashed line at 1%): to its left the bigger codes dive toward zero; to its right they fan out and the bigger codes are worse.

▸ threshold bench{{ sideLabel }}
{{ t.label }} threshold 1% {{ c.label }} physical error rate p → logical error pₗ
p = {{ pLabel }}
d = {{ r.d }} · {{ r.q }} qubits
{{ r.pl }}
{{ r.verdict }}
recapLeft of the threshold, larger d wins by a widening margin; right of it, larger d loses. The hardware must clear the bar first.
math

Exponential suppression — for a price

The logical error rate of a distance-d surface code follows a clean scaling law:

pₗ ≈ A · (p ⁄ pₜₕ)(d+1)⁄2
p < pₜₕ → the base is < 1, so raising d crushes pₗ

Because d sits in the exponent, every two steps of distance roughly multiply the suppression again — you buy as many decades of reliability as you like. The bill is the qubit count, which grows as d²:

physical qubits per logical qubit ≈ (2d − 1)²   — hundreds to thousands
reliability is cheap in the exponent, expensive in the hardware
✎ worked example · ten times below threshold
1.Take p = 0.1%, pₜₕ = 1%, so p⁄pₜₕ = 0.1, and A ≈ 1.
2.d = 3: exponent (3+1)⁄2 = 2 → pₗ ≈ 0.1² = 10⁻².
3.d = 5: exponent 3 → pₗ ≈ 0.1³ = 10⁻³. d = 7 → 10⁻⁴.
4.Each +2 in distance buys another factor of 10 — for ≈ (2d−1)² qubits.
recappₗ ≈ A(p⁄pₜₕ)^((d+1)⁄2): d in the exponent gives exponential suppression for a d² qubit cost.
why

The last gate needs magic

There’s a catch the threshold can’t fix. A stabilizer code applies Clifford gates (H, S, CNOT) cleanly — but the Gottesman–Knill theorem says Clifford-only circuits are simulable on a laptop. To get real quantum power you need at least one non-Clifford gate, the T gate, and the code refuses to do it transversally.

The fix is magic-state distillation. You can’t apply a T gate directly, but if someone hands you a perfect “magic” qubit |T⟩, you can consume it with cheap Clifford gates to enact one T. Real magic states are noisy — so you take many mediocre copies and run a small protocol that outputs fewer, much cleaner ones, repeating until they’re good enough.

✎ the distillation bargain
1.Clifford gates are free-ish; the T gate is the bottleneck — it is what makes a circuit hard.
2.A magic state lets you “teleport in” one T using only Cliffords.
3.Distillation: 15 noisy copies (rate p) → 1 copy at rate ≈ 35p³ — far cleaner.
4.Distillation factories often dominate the qubit budget of a real machine.
recapCodes do Cliffords for free but Cliffords alone are weak; the T gate is added by consuming distilled magic states.
⚠ common misconceptions

“Below the threshold the error is zero.” It is never exactly zero — just suppressed exponentially in d. You pick a d large enough that pₗ is small enough for your whole computation, then stop.

“Error correction makes qubits free.” The opposite — one good logical qubit can cost hundreds to thousands of physical ones, plus separate magic-state factories. The overhead is the central engineering challenge.

“If Cliffords are protected, we’re done.” Clifford-only circuits are classically simulable (Gottesman–Knill). The quantum advantage lives in the T gates — which is exactly why magic states matter.

✓ you can now
state the threshold theorem and what “below threshold” buys you
use pₗ ≈ A(p⁄pₜₕ)^((d+1)⁄2) to estimate logical error and overhead
explain why Clifford gates aren’t enough and where the T gate comes in
describe magic-state distillation and why it dominates the qubit budget
← 14 The Surface Code Part D complete · back to QC home