Error correction pays only if adding qubits makes things better. Below a critical physical error rate, the threshold, a bigger surface code fails exponentially less often. Above it, a bigger code fails more often. Here you find that point yourself: each figure runs a Monte Carlo simulation in your browser when you press Run.
The central promise
Every physical qubit fails now and then. A code spreads one logical qubit over many physical ones, checks read out parities of neighbouring qubits, and a decoder uses the checks to guess which errors happened. When the guess is wrong in the wrong way, the logical qubit is flipped. That is a logical error.
A distance-d surface code has d × d data qubits and fails only when errors, together with the decoder's correction, form a chain across the patch. That takes about d/2 errors, so when each qubit errs with a small probability p, a failure costs roughly p to the power (d+1)/2. A bigger patch also offers more places for a chain to start. At small p the first effect wins, and growing the code drives the logical error rate down as far as you like. At large p the second wins, and growing the code makes things worse. The physical error rate where the two balance is the threshold. It is the promise of error correction in one number: beat it, and you can buy any logical error rate by paying in qubits.
Reading the plot
The horizontal axis is the physical error rate p, the chance that a given data qubit suffers an error. The vertical axis is the logical error rate, the fraction of simulated shots in which the errors and the decoder's correction together flipped the logical qubit. Both axes are logarithmic, so a power law is a straight line and each curve is steeper the larger d is. Every point counts failures out of N shots, and its bar is one binomial standard error, the square root of r(1 − r)/N for a rate r.
The figure starts in the simplest setting, code capacity: each data qubit is flipped independently with probability p, once, and the checks are then read perfectly. The decoder is union-find, from the previous lesson: it grows clusters around the fired checks until each cluster can be explained by errors inside it, then corrects within each cluster. Press Run with the defaults and watch the left end of the plot, where p is small, then follow the curves to the right.
The figure needs JavaScript. The text around it says what it shows.
Show data as tableFig. 1Logical error rate of the rotated surface code against physical error rate p, simulated in your browser with the union-find decoder. Bars are one binomial standard error. Each distance has its own marker and line style. The orange marks along the bottom are this run's estimates of where neighbouring curves cross. Crosses (×), when shown, are stored reference rates from stim and pymatching for bit-flip noise.
You should have seen the order flip. Left of the crossing the biggest code is best; right of it, the biggest code is worst. The curves do not meet at exactly one point: small codes carry corrections that fade only as d grows, so the crossing of d = 3 with 5 and of 5 with 7 need not agree. The page interpolates each pair of curves in log p to locate the crossing, and widens it to a range using the error bars. Read it as this run's estimate for this decoder, not as the threshold of the surface code.
Try depolarizing noise too. Each qubit then suffers X, Y or Z, each with probability p/3, and a shot fails if either logical operator is flipped. This decoder handles the X and Z parts separately, so it does not use the fact that a Y error is both at once. For comparison, Dennis, Kitaev, Landahl and Preskill (2002) tied the threshold of the surface code to a phase transition in a disordered model from statistical physics, and Wang, Harrington and Preskill (2003) computed where minimum-weight matching stops working: near 10.3% when the checks are read perfectly, and near 2.9% when the readings are noisy. Both are lower bounds on the best possible threshold. Those two numbers come from the literature, not from this page.
Below threshold
Pick a p well left of the crossing and read along a vertical line. Each time d grows by 2, the logical error rate falls by roughly the same factor. That factor is often called Lambda. Against d on a log axis the points lie close to a straight line, and its slope gives Lambda. Run the second figure at its default p, then move p toward the crossing and run it again.
The figure needs JavaScript.
Show data as tableFig. 2Logical error rate against code distance at one physical error rate, with the measurement setting and noise chosen in Fig. 1. The orange line is a weighted least-squares fit of the logarithm of the rate against d; Lambda is the factor it falls by per step of 2 in distance. Distances with no failures are left out of the fit.
Near the crossing Lambda falls toward 1, where a bigger code buys nothing. Far below it Lambda is large, and every extra ring of qubits divides the failure rate by that factor. A measured Lambda greater than 1 between two code sizes is what an experiment means when it says it runs below threshold.
When the checks themselves are noisy
Code capacity assumes perfect checks. Real readouts are sometimes wrong, and one wrong readout looks like an error that appears and then vanishes. To tell the two apart the checks are repeated for several rounds and the decoder works in space and time at once. The phenomenological model does exactly this: d rounds, each with fresh data errors of probability p and each check readout flipped with probability p, then one final perfect readout taken by measuring the data qubits. Switch Fig. 1 to noisy measurement and press Run; the p range moves down with it.
The crossing moves to a much lower p. Each check can now lie, and the decoder must rule out chains through time as well as across the patch.
What these models leave out
Neither model is a circuit. On hardware each check is measured by an ancilla qubit coupled to its data qubits by a sequence of two-qubit gates, and every gate can fail. One fault halfway through that sequence can spread to two data qubits; ancillas can be reset wrongly; qubits idle while others are measured. Circuit-level noise includes all of these, and circuit-level thresholds are lower than phenomenological ones by a wide margin. The models here keep the geometry of the problem and drop the circuit.
Why the number depends on the decoder
A threshold belongs to a code, a noise model and a decoder together. A decoder that guesses better fails less often at the same p, and its crossing sits further right. The table runs this page's union-find decoder at the points of a reference computed offline with stim, a stabilizer circuit simulator, and pymatching, a minimum-weight perfect matching decoder, for bit-flip noise. Press Run comparison.
The table needs JavaScript.
Fig. 3Surface code, bit-flip noise. The matching column is reference data computed offline with stim and pymatching and stored with this page; the union-find column is computed in your browser when you run it. The last column divides the two.
Union-find should fail more often than matching at every point, and the gap should widen with d. That lost accuracy is what pulls its crossing to a lower p in Fig. 1. The small distances matter as well: crossings between small codes sit below the threshold and move up as d grows, which you can see by adding d = 9 and 11. A note measures this drift up to d = 21. In exchange union-find is simple and runs in close to linear time in the worst case, which matters when a decoder has to keep pace with a device that produces new check results without pause.
Cite this lesson T. Pandey, "The threshold", Quantum Error Correction in Practice (2026), https://pandey-tushar.com/qec-in-practice/threshold.html