Part III · Keeping Quanta Alive · Chapter 12
Thresholds and Fault Tolerance
Codes correct errors — but the correcting circuitry is itself made of faulty gates. The astonishing answer is that a single number decides everything: below one critical error rate, arbitrarily long quantum computation is possible; above it, no code can save you.
Sources: Nielsen & Chuang 10.6 · Aharonov–Ben-Or · Bravyi–Kitaev (2005)
Chapter 10 gave us codes that catch errors; Chapter 11 gave us the stabilizer machinery and the surface code, and showed a logical error rate falling as the code distance grows — provided the syndrome measurements are perfect. They are not. Every gate that extracts a syndrome, every gate that corrects, can itself fail. So the real question is not “does encoding help?” but “does encoding help when the encoder is as broken as the thing it protects?” The answer is the deepest result in the field — the threshold theorem — and by the end of this chapter you will have watched its phase transition happen in a real Rust decoder: every leaf-error pattern enumerated, the threshold located by bisection and again by Monte-Carlo, and the textbook recursion graded against both.
What this chapter covers
- 12.1Errors that spread. Why naive redundancy fails: a single faulty gate can corrupt many qubits at once. Fault tolerance means errors must not cascade.
- 12.2Concatenation. Encode the encoded qubits again, L levels deep. The logical error obeys a recursion p_L = f(p_{L−1}) — a code inside a code inside a code.
- 12.3The threshold theorem. The recursion's fixed point p_th splits the world: below it, doubly-exponential suppression; above it, doubly-exponential blow-up.
- 12.4Fault-tolerant gates. Transversal gates don't spread errors — but Eastin–Knill forbids a universal transversal set. Something non-Clifford must come from elsewhere.
- 12.5Magic-state distillation. Manufacture the missing T gate from noisy 'magic' states: the 15-to-1 protocol suppresses their error cubically, ε → 35ε³.
- 12.6The honest overhead. The bill: thousands of physical qubits per logical qubit. Why a useful Shor run is still years of engineering away.
- 12.7The Lab. A real concatenated decoder and a weight enumeration of the 15-to-1 code, with referees locating the two thresholds from enumeration and Monte-Carlo rather than algebra.
12.1Errors that spread
F · FormalismStart with the trap. Chapter 10's three-qubit code stores one logical bit in three physical ones and corrects any single flip by majority vote. If each physical qubit fails independently with probability , the encoded bit fails only when two or more of the three fail:
For small this is : encoding helps. So why not stop here? Because (12.1) quietly assumes the qubits fail independently and that the majority vote is computed for free. Neither holds. The vote is a circuit of real gates, and a single faulty two-qubit gate touches both its qubits at once — one fault becomes two errors, in exactly the qubits the code assumed would fail alone. Worse, a copies a bit-flip from control to target and a phase-flip from target to control: errors don't just appear, they propagate.
This is the whole difficulty of the subject in one sentence. A construction is fault-tolerant if a single fault anywhere — in a data qubit, an ancilla, a gate, a measurement — produces at most one error per encoded block, so that a distance- code still corrects it. Get that property and (12.1) becomes honest: the effective per-block failure really is quadratic in a physical rate. Lose it and no amount of encoding converges. Everything below assumes the circuits have been made fault-tolerant in this sense; our subject is what the resulting recursion does.
12.2Concatenation
F · FormalismC · ConceptsIf one layer of encoding turns into , do it again. Take each of the three physical qubits and encode it in three more; encode those in three more; levels deep. This is concatenation, a code inside a code. A level- logical qubit is a tree with physical qubits at its leaves:
Because each level is the same map applied to the level below, the logical error rate obeys a one-line recursion:
Everything now turns on the dynamics of iterating one function. Drag below and watch all six level-curves at once — the physical rate on the horizontal axis, the logical rate on the vertical:
Below p_th the levels fan down: each round of encoding shrinks the logical error, and it collapses toward 0 super-exponentially. This is the regime fault tolerance lives in.
0.3500
p_0
0.2817
p_1
0.1934
p_2
0.0978
p_3
0.0268
p_4
0.0021
p_5
Two things jump out. The curves all pass through a single point, and on either side of it they fan in opposite directions. That pivot is the whole story.
12.3The threshold theorem
F · FormalismThe pivot is a fixed point of the recursion: a rate that maps to itself, . Solving it for our code,
(the other roots, and , are the stable “perfect” and “dead” states). The value is this code's threshold. Below it, iterating drives ; above it, . To see how fast, look near the perfect state, where , and keep only that leading term: the pure-quadratic model , with for our code. One caution before trusting it: is a different map with a different threshold — its nonzero fixed point is , not 's — so models the collapse deep below threshold, not the location of the transition. For , write and define ; then exactly, so
Read (12.4) carefully — it is the theorem in miniature. The exponent is , so the error is suppressed doubly exponentially in the number of levels whenever . To reach a target logical error you need only levels, i.e. physical qubits per logical one. That is the threshold theorem: if the physical error rate is below , arbitrarily long quantum computation is possible with only polylogarithmic overhead. Above , the very same formula blows up doubly exponentially — encoding accelerates the failure. There is no gentle middle: it is a phase transition.
12.4Fault-tolerant gates
F · FormalismA threshold for storage is not enough; we must also compute on encoded qubits without letting one fault cascade. The cleanest way is a transversal gate: apply the physical gate qubit-by-qubit across the block, the -th physical qubit of one block interacting only with the -th of another. A fault in one such gate can corrupt only one qubit per block — exactly the fault-tolerance property of §12.1. Transversal gates are the gold standard: they are fault-tolerant essentially for free.
So why not build the whole computer from them? Because of a hard no-go, the Eastin–Knill theorem (2009): for any code that detects errors, the set of transversal gates is finite, so it cannot be universal. Typically the transversal gates give you the entire Clifford group — the , , and of Chapters 2 and 5 — and, by the Gottesman–Knill theorem of Chapter 5, a circuit of only Clifford gates is efficiently classically simulable. To get any quantum advantage at all you need one more gate outside the Clifford group — the non-Clifford — and that is precisely the gate transversality refuses to hand you. The missing ingredient must be manufactured another way.
12.5Magic-state distillation
F · FormalismC · ConceptsThe escape, due to Sergey Bravyi and Alexei Kitaev (2005), is to move the hard gate off-line. A gate can be applied to a logical qubit using only Clifford operations if you are also given a special ancilla — a magic state . The magic state is consumed to inject the gate. So the whole non-Clifford difficulty is reduced to one question: how do you make clean magic states, when everything you build them from is noisy?
You distil them. Feed many noisy copies, each carrying error , into a small Clifford circuit that checks a stabilizer condition and outputs fewer, cleaner copies. The celebrated 15-to-1 protocol takes fifteen noisy magic states and produces one whose error is
The suppression is cubic for a counted reason. The protocol's checks are the parity checks of the classical [15,11,3] Hamming code, whose minimum distance is 3: no one- or two-error input pattern slips through undetected, and exactly 35 of the three-error patterns do — the lab counts them by walking all patterns, and 35 is what it finds. Iterating rounds gives another fixed-point story. At leading order the distillation threshold solves , i.e. ; the enumerated map keeps every order in and its fixed point lands below that — the leading-order threshold is an overestimate, and the lab's panel reports both. Below threshold each round cubes the error, so on a log–log plot versus approaches a straight line of slope 3 — a slope the lab measures off the enumerated map, to better than .
12.6The honest overhead
C · ConceptsIt is tempting to read the threshold theorem as good news and stop. It is good news — but the honest scorecard is sobering. The polylog overhead is asymptotic; the constants are brutal. A useful logical qubit built on a surface code near a realistic threshold needs hundreds to thousands of physical qubits. Magic-state distillation is often the dominant cost: factories that churn out clean states can occupy the majority of the chip, each round consuming fifteen inputs for one output.
Concretely, current estimates put a cryptographically relevant Shor factorization (Chapter 8) at millions of physical qubits running for hours or days — orders of magnitude beyond today's few-hundred-qubit devices. This is not a wall of principle; the threshold theorem says the wall is not there. It is a wall of engineering: driving physical error rates well below and building the millions of qubits the constants demand. That gap — provably surmountable, presently enormous — is exactly why the next chapter asks a different question.
12.7The Lab — two recursions, two thresholds
P · PracticeA lab whose subject is a one-line recursion has an occupational hazard: it is dangerously easy to grade a closed form against itself and report a triumphant zero. So the instruments here never take the polynomial on trust. The first is an actual decoder — majority votes running bottom-up over the leaves of a concatenation tree — and the exact logical rate comes from enumerating every one of the leaf patterns that decoder gets wrong (all 512 of them at level 2):
1/// Majority vote over three error flags: the block is wrong iff >= 2 of 3 are.2fn majority3(a: bool, b: bool, c: bool) -> bool {3 (a & b) | (b & c) | (a & c)4}56/// Decode a level-L concatenation tree bottom-up from its 3^L leaf error flags.7/// Returns true iff the LOGICAL bit is wrong. No closed form appears here.8fn decode_tree(leaves: &[bool], scratch: &mut Vec<bool>) -> bool {9 scratch.clear();10 scratch.extend_from_slice(leaves);11 let mut len = scratch.len();12 while len > 1 {13 for k in 0..len / 3 {14 scratch[k] = majority3(scratch[3 * k], scratch[3 * k + 1], scratch[3 * k + 2]);15 }16 len /= 3;17 }18 scratch[0]19}2021// …2223/// Exact 3-qubit majority-vote logical error: fail iff >= 2 of 3 bits flip.24fn f_majority(p: f64) -> f64 {25 3.0 * p * p - 2.0 * p * p * p26}
The second instrument answers the 15-to-1 question by counting rather than quoting. A pattern of errors on the fifteen inputs is detected exactly when it fails a Hamming parity check, and an accepted pattern hurts the output exactly when its weight is odd — so walking all patterns yields the protocol's full weight spectrum, and the 35 of (12.5) falls out of it as a count rather than a quote:
1/// Syndrome of a Z-error pattern: XOR of the H columns the pattern selects.2/// Zero syndrome means the protocol accepts the round.3fn syndrome(pattern: u32, cols: &[u8]) -> u8 {4 let mut s = 0u8;5 for (i, &c) in cols.iter().enumerate() {6 if (pattern >> i) & 1 == 1 {7 s ^= c;8 }9 }10 s11}1213/// An accepted pattern is stabilizer-equivalent to the identity iff it lies in14/// the even-weight subcode; odd weight means it acts as the logical Z, i.e. the15/// distilled output carries an error.16fn is_harmful(pattern: u32) -> bool {17 pattern.count_ones() % 2 == 118}1920/// Exhaustive walk over all 2^15 Z-error patterns on the 15 inputs. Returns21/// (accepted_by_weight, harmful_by_weight), each indexed by Hamming weight.22fn distill_spectrum(cols: &[u8]) -> (Vec<u64>, Vec<u64>) {23 let mut accepted = vec![0u64; N_MAGIC + 1];24 let mut harmful = vec![0u64; N_MAGIC + 1];25 for pattern in 0u32..(1u32 << N_MAGIC) {26 if syndrome(pattern, cols) != 0 {27 continue; // detected — the round is thrown away28 }29 let w = pattern.count_ones() as usize;30 accepted[w] += 1;31 if is_harmful(pattern) {32 harmful[w] += 1;33 }34 }35 (accepted, harmful)36}
The lab runs its referees and writes them to JSON, which the panel below reads live. Each grades one code path against an independent other: the enumerated decoder against the recursion (to at level 2); a Monte-Carlo tree against both, in ; the threshold as a bisected crossing of the two enumerated level curves (within of the algebraic ) and again as a million-shot measured crossing with a genuine error bar; the multiplier differenced off the enumerated curve (repelling, ); and, on the distillation side, the counted 35, the measured cubic coefficient and exponent, a sampled check of the exact acceptance and harm probabilities, and the cascade run on the exact map. Every number in the panel — thresholds, cascade, slope — is whatever your last cargo run --release produced.
cargo run --release in Rust-QML/ch12-threshold)Run it yourself with cargo run --release in Rust-QML/ch12-threshold. The two curves are the whole chapter: a family of level-curves pivoting on , and an error that collapses cubically once you are below .
12.8Exercises
1. (F) Solve for the three-qubit majority code by hand. Show the nontrivial fixed point is exactly , and confirm from that and are stable while is unstable — which is exactly why it is a threshold.
2. (F, hard) For the pure-quadratic model with fixed point , prove the closed form by induction. (Hint: let and show .) Then invert it: how many levels to reach a target logical error , and why is that ?
3. (C) Using the threshold explorer, set (just below threshold) and read off the six . Then set . Explain why the same code that suppresses errors in the first case amplifies them in the second, even though the two rates differ by only .
4. (P) Add a referee that sweeps and, for each concatenation level , extracts the crossing point of with . Verify all crossings converge to — the threshold read off the plot rather than solved for.
5. (P, hard) Model a more honest distillation cost. The 15-to-1 round consumes 15 inputs per output, so producing one clean state after rounds needs raw states. Compute, for a target starting from , the number of rounds and the total raw-state budget. Discuss why distillation dominates the qubit count of a real fault-tolerant machine.
The bridge → Chapter 13: NISQ and Variational Circuits
Where you stand. You have the threshold theorem: below a critical physical error rate, concatenation suppresses logical error doubly-exponentially with only polylog overhead, and magic-state distillation supplies the missing non-Clifford gate by cubing its error. You located the fixed point p_th = ½ by bisecting an exhaustively enumerated decoder, and counted the 35 in ε → 35ε³ by walking every error pattern of the 15-to-1 code.
The open question. Full fault tolerance works in principle but costs thousands of physical qubits per logical one — a useful Shor run is years of engineering away. What can we compute on today's noisy, few-hundred-qubit machines, with no error correction at all?
What comes next. We enter the NISQ era: shallow parameterized circuits run on noisy hardware, with a classical optimizer tuning the parameters. Variational algorithms — VQE for ground-state energies, and the machinery that carries us into Part IV's quantum machine learning — trade guaranteed speedups for something that might just run before fault tolerance arrives.