Module 10 set up the decoding problem and solved it with minimum-weight perfect matching. Matching is accurate, but it has two limits. It needs graphlike errors, and it is a fairly heavy algorithm to run in real time on custom hardware. This module covers the main alternatives. Union-Find is almost as accurate and much simpler. Belief propagation is the workhorse of classical LDPC codes, but it struggles on quantum codes, and the fix is BP+OSD. Then we turn to the question every decoder is judged by: is there a threshold, and how far below it are we? The module ends with Google’s 2024 Willow experiment, the first clear demonstration of a surface-code memory operating below threshold.
Learning goals. After this module you should be able to
run the peeling decoder and the Union-Find decoder by hand on a small instance, and explain why UF runs in almost-linear time;
write the belief-propagation update rules on a Tanner graph, and explain with an example why degeneracy and short cycles break BP on quantum codes;
describe ordered-statistics post-processing (OSD) and why it always returns a correction consistent with the syndrome;
state the threshold theorem informally and derive the doubly exponential suppression of concatenated codes;
estimate a threshold from crossing curves, convert per-shot to per-round error rates, and compute the suppression factor ;
summarize what the Willow experiment did and did not show.
1. The decoder landscape
A decoder trades accuracy against speed and generality. Here are the decoders in this course, side by side. “Graphlike” means each error flips at most two detectors (Module 10).
decoder
needs graphlike?
accuracy on surface codes
cost
lookup table
no
exact (MW or ML)
memory , tiny codes only
MWPM / sparse blossom
yes
minimum weight (exact MPE)
polynomial; near-linear in practice
Union-Find
yes (hypergraph variants exist)
slightly below MWPM
BP alone
no
poor (degeneracy)
linear per iteration
BP+OSD
no
close to MWPM; general qLDPC
cubic (Gaussian elimination)
tensor network
no
near-ML for code capacity
, poor for many rounds
neural network
no
best reported on hardware data
expensive training, fast inference
2. Peeling and Union-Find
The peeling decoder for erasures
Start with an easier problem. Suppose we know which qubits might have failed: an erasure, such as a photon loss or a detected leakage event. In the matching-graph picture we are given a set of erased edges, and the error is supported somewhere inside . We need an edge set whose boundary is exactly the defect set.
Definition 11.1 (Peeling decoder).
Input: an erased edge set and the defects.
Pick a spanning forest of : a maximal subset with no cycles. If a component contains the boundary node, root its tree there.
Repeatedly take a leaf edge of , where is the leaf. If is a defect, add to and toggle the defect status of . Then delete from .
When is empty, output .
Lemma 11.1 (Peeling is correct).
If every component of that does not contain the boundary has an even number of defects, the peeling decoder returns an edge set with equal to the defect set. Among subsets of the tree , is the unique such set.
Proof
Induct on the number of edges of . A leaf is met by exactly one edge of , namely . So is forced exactly when is a defect. In either case, after deleting and updating , the defects remaining in the smaller tree still have even parity per component, because toggling moves the defect from to . Each step is forced, so the result is unique. When only a root is left, its defect status must be 0 (even parity), or the root is the boundary node, where any parity is allowed.
Peeling touches each edge once, so it runs in linear time. Delfosse and Zémor (arXiv:1703.01517) showed it is an ML decoder for the erasure channel on surface codes.
Union-Find: turn errors into erasures
For ordinary errors we do not know where the error is. The Union-Find (UF) decoder of Delfosse and Nickerson (arXiv:1709.06218, Quantum 5, 595 (2021)) guesses an erasure. It grows a small region around each defect until every region can be explained internally, and then peels.
Definition 11.2 (Union-Find decoder).
A cluster is a connected set of nodes together with the fully or half grown edges between them. A cluster is odd if it contains an odd number of defects and does not touch the boundary node. Otherwise it is even.
Start with one cluster per defect.
Grow: every odd cluster grows by half an edge in every direction.
Fuse: when an edge becomes fully grown, merge the clusters at its two ends.
Repeat 2 and 3 until no odd cluster remains.
Treat the fully grown edges as an erasure and run the peeling decoder.
The name comes from the data structure that tracks clusters. Find(v) returns a representative (root) of ‘s cluster. Union(a, b) merges two clusters. Each root also stores the cluster’s defect parity and whether it touches the boundary. With union by size and path compression, any sequence of these operations costs amortized per operation, where is the inverse Ackermann function. For every you will ever meet, . The full decoder runs in worst-case time, “almost linear”.
Theorem 11.1 (Union-Find guarantees (Delfosse and Nickerson)).
On surface codes, the Union-Find decoder runs in time . It corrects every error of weight at most , and every erasure of at most qubits. Growing the smallest odd clusters first, the toric code has code-capacity threshold about (MWPM: ), and about with faulty syndrome measurements.
Example 11.1 (Union-Find on a repetition code).
Take the distance-9 repetition code: checks on a path, with the boundary at both ends, and edges . The error produces defects at .
Round 1. Each of the four clusters grows half an edge to each side. The half edges of coming from and from meet, so becomes fully grown and fuse into an even cluster, which stops. The clusters around and are still odd.
Round 2. grows and fully, and grows and fully. Both reach , so they fuse into one cluster spanning , with two defects: even. No odd clusters remain.
Peel. Cluster has a single edge , which is forced. The second cluster is the path . Peel leaf (not a defect: drop ), then (defect: flip , which toggles ), then (now a defect: flip , which clears ), then is dropped.
The output is , the true error. Our Python implementation reproduces these steps exactly.
How close is UF to matching in practice? We coded the decoder above (smallest-odd-clusters-first growth) and ran it next to PyMatching on the toric code with i.i.d. Z errors, decoding with the vertex checks. As a sanity check of Theorem 11.1, it corrected all Z errors of weight at most 2 on the torus. Monte Carlo logical failure rates (any logical flipped):
decoder, size
MWPM, (20000 shots)
0.132
0.191
0.265
0.339
MWPM, (20000 shots)
0.090
0.158
0.252
0.348
UF, (1500 shots)
0.127
0.199
0.280
0.343
UF, (800 shots)
0.107
0.188
0.285
0.389
For both decoders the larger lattice is better at and worse at . The UF numbers have statistical errors of about , so this small run cannot separate from . It does show the two decoders are close.
3. Belief propagation and why it struggles
Tanner graphs and message passing
For a code with check matrix (an binary matrix: when decoding X errors, for Z errors), the Tanner graph is bipartite. It has a variable node for each error bit, a check node for each row, and an edge whenever . Belief propagation (sum-product) passes log-likelihood ratios (LLRs) along the edges. Start from the prior , the same weight as in Module 10. Each iteration does three things.
The syndrome bit enters as the sign : an unsatisfied check tells its neighbors “an odd number of you flipped”. Stop when or after a maximum number of iterations. The posterior flip probability is .
On a tree, BP computes the exact marginal probability of each bit after a number of iterations equal to the depth. Each iteration costs time linear in the number of edges. That is why BP is the standard decoder for classical LDPC codes, whose Tanner graphs have few short cycles.
Two quantum obstacles
Degeneracy splits beliefs. BP estimates, bit by bit, the probability that each qubit flipped. In a degenerate quantum code there are often two or more equally likely minimum-weight errors that differ by a stabilizer. BP has no way to break the symmetry, so it assigns each bit an intermediate probability. The bitwise hard decision is then often not a valid explanation of the syndrome.
Example 11.2 (Split beliefs on one plaquette).
On the toric code, apply a Z error on two edges forming an L from vertex to . The defects are diagonal corners of one plaquette. There are two shortest corrections, the two halves of the plaquette boundary, and they differ by the plaquette stabilizer. We ran sum-product BP (the ldpc package, , 50 parallel iterations). The four plaquette edges all end with posterior flip probability . Every other edge is near . All posteriors are below , so the hard decision is , which does not satisfy the syndrome. BP did not converge. The same input passed to BP+OSD-0 (below) returns one of the two weight-2 paths, which is a correct decoding.
Short cycles. BP is exact only on trees. Quantum codes are full of short loops. If you decode X and Z together (the “GF(4)” or non-CSS picture), every X-type check and Z-type check that overlap share an even number of qubits, at least 2, because they must commute. That creates unavoidable 4-cycles. Even for CSS decoding, the low-weight checks of the toric code form many small loops. On loopy graphs BP can oscillate or settle on wrong fixed points. Poulin and Chung (arXiv:0801.1241) analyzed both obstacles.
The effect is dramatic. On the toric code (2000 shots per point):
BP alone: failure (of which non-converged)
BP+OSD-CS (order 7)
MWPM
0.03
0.268 (0.268)
0.0010
0.0015
0.05
0.485 (0.484)
0.016
0.019
0.08
0.805 (0.801)
0.111
0.136
Plain BP fails a quarter of the time at , a noise level where matching almost never fails, and nearly every failure is a non-converged run. One cheap post-processing step closes the gap.
4. BP + ordered statistics decoding
Ordered statistics decoding (OSD) uses BP’s soft output to choose which bits to trust. It then solves the syndrome equation exactly by linear algebra. It was adapted to quantum LDPC codes by Panteleev and Kalachev (arXiv:1904.02703) and developed into a general tool by Roffe, White, Burton and Campbell (arXiv:2005.07016).
Definition 11.3 (OSD-0 post-processing).
Run BP. If , output . Otherwise:
Sort the columns of by posterior flip probability, most likely first.
Scan in that order and keep the first linearly independent columns, an information set.
Solve by Gaussian elimination over , set for , and output .
Higher-order OSD also tries setting small patterns of the remaining bits to 1. For each pattern it re-solves for and keeps the most probable result. The “combination sweep” variant OSD-CS of order tries all single flips and all pairs among the most likely remaining bits.
Proposition 11.1 (OSD always satisfies the syndrome).
If is the syndrome of some error, then the OSD-0 output satisfies .
Proof
The syndrome lies in the column space of . The columns in are linearly independent and there are of them, so they form a basis of that column space. Hence has a unique solution, and .
So BP+OSD never “gives up” the way plain BP does. BP’s role is to put the likely bits first, so the forced solution tends to be light and in the right class. In the split-belief example, the four plaquette edges are at the top of the list. OSD picks an independent subset and commits to one of the two paths.
The price is the Gaussian elimination, in the worst case. This is acceptable offline but a real challenge for real-time decoding of large codes. Roffe et al. found a code-capacity threshold of for BP+OSD on the toric code, close to matching. Its real strength is generality: it works for any sparse code, including the qLDPC codes of Module 12, where matching does not apply.
5. Tensor-network and neural decoders, briefly
Tensor networks. For code-capacity noise on the surface code, the class probabilities from Module 10 can be written as the contraction of a 2D tensor network. Bravyi, Suchara and Vargo (arXiv:1405.4883) contracted it approximately, as a matrix product state of bond dimension , at cost . They obtained essentially ML decoding at modest . Repeated rounds turn the network three-dimensional, and the method becomes much harder.
Neural networks. A neural decoder learns the map from detection events to “did the logical flip?” from data. AlphaQubit (Bausch et al., Nature 2024, arXiv:2310.05900) is a recurrent transformer. It was pretrained on simulated data and fine-tuned on experimental samples. It outperformed correlated matching on Google’s Sycamore data. In the Willow experiment below, the most accurate offline decoder was a neural network fine-tuned on processor data. Neural decoders can learn hardware effects such as leakage and correlated errors that are hard to put into a DEM. The open issues are training cost, scaling to large distance, and latency.
6. The threshold theorem
Why should adding more qubits help at all, when every added qubit adds noise? The threshold theorem says it does, provided the hardware is good enough.
Theorem 11.2 (Threshold theorem (informal)).
For local, weakly correlated noise there is a constant with the following property. If every elementary operation (preparation, gate, idle, measurement) fails with probability , then any ideal circuit of size can be simulated with total failure probability at most using physical operations.
This was proved in the late 1990s by Aharonov and Ben-Or, by Knill, Laflamme and Zurek, and by Kitaev. The rigorous constants are pessimistic: Aliferis, Gottesman and Preskill proved for a concatenated distance-3 code. Numerical thresholds for surface codes are much higher, around .
The core mechanism is easy to see with concatenation.
Proposition 11.2 (Doubly exponential suppression under concatenation).
Suppose one level of encoding in a distance-3 code fails only if at least two of its components fail, so the logical error rate is for some constant (the number of “bad pairs”). Then after levels
so for the error falls doubly exponentially in . The size grows only exponentially in , for example qubits for the Steane code.
Proof
Induction: .
For example, with and , three levels give using qubits per logical qubit. Topological codes do the same job by increasing instead of the number of levels. Module 10 gave the matching estimate
for odd , where the exponent is the minimum number of faults that can cause a logical error. For general the exponent is .
7. Estimating thresholds from crossing curves
The threshold is defined by the limit of large codes. Numerically we can only simulate a few sizes, so we look for a crossing.
Definition 11.4 (Threshold and pseudo-threshold).
For a code family, noise model and decoder, the threshold is the largest such that, for every , the logical error rate as . For a single fixed code, the pseudo-threshold is the at which : the break-even point between using the code and using one bare qubit. (For codes with several logical qubits, conventions for the comparison vary.)
Recipe. Simulate for a few distances on a grid of values. Plot on log-log axes. Below threshold the curves are ordered with larger lower, and above threshold the order is reversed. The crossing estimates . For precise work, fit a finite-size scaling form near the crossing (Wang, Harrington, Preskill 2003).
Code capacity. Our toric-code MWPM data from §2 (now including ) cross between and . For versus , linear interpolation gives , consistent with the known .
Circuit level. We simulated the rotated surface-code memory generated by Stim, with the same error rate on every gate, reset, measurement and idle, rounds = d, decoded with PyMatching ( shots per point):
cross0.3%0.5%0.7%0.9%1.1%1e-31e-21e-1physical error rate p (log scale)logical error per shotd=3d=5d=7
0.3%
0.5%
0.6%
0.7%
0.8%
1.1%
0.0070
0.0174
0.0243
0.0315
0.0395
0.068
0.0029
0.0146
0.0234
0.0348
0.0488
0.105
0.0014
0.0093
0.0193
0.0326
0.0528
0.135
By linear interpolation, the and curves cross near , and and cross near . The crossing drifts with size, a finite-size effect, so a careful estimate needs larger and a scaling fit. For this noise model the threshold is roughly . Different circuit noise models give values from about to (Fowler et al. 2012 report for theirs).
Remark 11.1 (Per shot versus per round).
A memory experiment with rounds reports a per-shot logical error . Codes run for different numbers of rounds (here ) should be compared per round. If each round independently flips the logical with probability , then , so
The crossing above uses per-shot numbers with . The per-round curves cross at a somewhat different point.
8. The suppression factor Λ
Below threshold, the useful number is not itself but how much each step up in distance buys you.
Definition 11.5 (Suppression factor).
With the logical error per round (per cycle) at distance ,
If Eq. holds, then and . In practice is fitted as the slope of against .
means “below threshold”: bigger is better. The size of sets the qubit overhead. With , each factor of in logical error costs about steps of in distance. With it costs just one step.
From the runs of Module 10 (, and shots), the per-round errors are , and . These give and . The value rests on 71 failures, a statistical uncertainty of about . Real hardware in 2024 was far from this idealized model.
Google’s Willow experiment
Google Quantum AI, “Quantum error correction below the surface code threshold”, Nature 638, 920 (2025), published online December 2024 (arXiv:2408.13687):
Devices. Two “Willow” superconducting processors: 105 qubits (distance-7 memory) and 72 qubits (distance-5 with real-time decoding). The cycle time was . On the 105-qubit chip, mean .
Code. Rotated surface-code memories at . The code used data qubits, measure qubits and extra qubits for leakage removal, in total. It ran for up to 250 cycles, with data-qubit leakage removal each cycle, and results were averaged over X and Z bases.
Suppression. with a neural-network decoder, and per cycle. An ensembled matching decoder gave .
Beyond break-even. The logical qubit lived . This beats the best physical qubit on the chip () by a factor of .
Real time. On the 72-qubit chip at , a real-time decoder had average latency over up to cycles.
Repetition codes and floors. Repetition codes up to reached , but hit an error floor near . The floor comes from rare correlated error bursts, about once an hour. This is a reminder that Eq. assumes independent errors.
Note what was shown: three points with and a constant ratio, not a measured crossing. The paper extrapolates that reaching would need about , or physical qubits per logical qubit, at the measured .
Example 11.3 (Lambda arithmetic).
With and : and . To reach we need , that is 10 steps, so . This matches the paper’s projection. If instead at the same , then suffices ( qubits). Improving is worth more than adding qubits.
Summary
Peeling solves erasure decoding in linear time (Definition 11.1, Lemma 11.1). Union-Find grows odd clusters until they are even, then peels (Definition 11.2). It runs in almost-linear time and is nearly as accurate as matching (Theorem 11.1, Example 11.1).
Belief propagation is exact on trees, but quantum degeneracy splits its beliefs between equivalent errors (Example 11.2), and stabilizer structure forces short cycles. Plain BP fails badly on the toric code.
BP+OSD uses BP’s soft information to order the bits, then solves the syndrome equation exactly (Definition 11.3, Proposition 11.1). It is accurate and general, but cubic in cost.
The threshold theorem (Theorem 11.2) rests on suppression with code size: doubly exponential for concatenation (Proposition 11.2) and for surface codes.
Thresholds are estimated by crossing curves (Definition 11.4). They depend on noise model and decoder: about for code capacity and around to for circuit noise. Compare codes per round (Remark 11.1).
The suppression factor (Definition 11.5) measures how far below threshold you are. Willow achieved at (Example 11.3).
Next: Module 12 uses BP+OSD on codes that beat the surface code’s overhead. Practice in Homework 11.
Further reading
N. Delfosse, N. H. Nickerson, “Almost-linear time decoding algorithm for topological codes”, Quantum 5, 595 (2021), arXiv:1709.06218.
N. Delfosse, G. Zémor, “Linear-time maximum likelihood decoding of surface codes over the quantum erasure channel”, PRR 2, 033042 (2020), arXiv:1703.01517.
D. Poulin, Y. Chung, “On the iterative decoding of sparse quantum codes”, QIC 8, 987 (2008), arXiv:0801.1241.
P. Panteleev, G. Kalachev, “Degenerate quantum LDPC codes with good finite length performance”, Quantum 5, 585 (2021), arXiv:1904.02703.
J. Roffe, D. R. White, S. Burton, E. Campbell, “Decoding across the quantum low-density parity-check code landscape”, PRR 2, 043423 (2020), arXiv:2005.07016. Software: the ldpc Python package.
S. Bravyi, M. Suchara, A. Vargo, “Efficient algorithms for maximum likelihood decoding in the surface code”, PRA 90, 032326 (2014), arXiv:1405.4883.
J. Bausch et al., “Learning high-accuracy error decoding for quantum processors”, Nature 635, 834 (2024), arXiv:2310.05900.
P. Aliferis, D. Gottesman, J. Preskill, “Quantum accuracy threshold for concatenated distance-3 codes”, QIC 6, 97 (2006), arXiv:quant-ph/0504218; D. Aharonov, M. Ben-Or, arXiv:quant-ph/9611025.
A. G. Fowler, M. Mariantoni, J. M. Martinis, A. N. Cleland, PRA 86, 032324 (2012), arXiv:1208.0928.
Google Quantum AI and collaborators, “Quantum error correction below the surface code threshold”, Nature 638, 920 (2025), arXiv:2408.13687.