ZKSF logo, a neon quantum brainZKSF
← All articles

Simulating Quantum Error Correction: How Logical Qubits Are Tested

· 13 min read · ZKSF team

A logical qubit is not a single physical qubit. It is one reliable qubit built from many unreliable ones, protected by an error-correcting code that detects and reverses errors faster than they accumulate. Because physical qubits carry two-qubit gate error rates ranging from about 0.01 percent on the best devices to around 1 percent on widely available ones, and because even the best is far short of what a long algorithm needs, error correction is the bridge every hardware roadmap must cross to reach useful computation.

Interactive diagramInside the surface codeA distance-5 lattice, a live error → syndrome → decode → correct cycle, and the threshold plot where increasing code distance flips from suppressing errors to amplifying them

The lattice on the left is a distance-5 surface code: 25 physical qubits protecting a single logical qubit. A physical error strikes a data qubit and flips two neighboring stabilizer checks, then a minimum-weight perfect matching decoder pairs up the flipped checks and applies the correction. The plot on the right tracks logical error rate against physical error rate for three code distances and shows the crossover near 1 percent: below that threshold a larger code suppresses errors more, above it a larger code makes things worse.

That bridge is not tested on quantum hardware first. It is tested in simulation, at scales real devices will not reach for years, and understanding why that simulation is possible at all is central to the field.

The problem quantum error correction has to solve

Classical error correction copies bits and takes a majority vote. Neither step is available quantum mechanically. The no-cloning theorem forbids copying an unknown state, and measuring a qubit to check it destroys the superposition being protected.

The resolution, due to Shor and Steane in the mid-1990s, is to encode one logical qubit in an entangled state of many physical qubits and to measure only *joint* properties that reveal whether an error occurred without revealing the encoded information. Measuring the parity of two qubits tells you whether they differ without telling you what either is, which is precisely the information needed and no more.

These joint measurements are the stabilizers. A stabilizer code defines its logical subspace as the joint +1 eigenspace of a set of commuting Pauli operators; a measurement returning -1 indicates an error has moved the state out of that subspace, and the pattern of such violations across the code is the syndrome.

Why these circuits are classically simulable

Stabilizer measurements are built from Hadamard, phase and CNOT gates together with computational-basis measurement, which is to say entirely from Clifford gates. The Gottesman-Knill theorem guarantees that such circuits simulate classically in polynomial time regardless of qubit count.

This is a striking exception to the usual exponential wall, and it is the reason the subfield with the largest qubit counts is also the one classical simulation handles best. A distance-d surface code protecting one logical qubit uses on the order of d^2 physical qubits repeated over many measurement rounds; a serious study involves thousands of qubits and hundreds of thousands of measurements. Statevector simulation cannot approach that scale. Stabilizer simulation completes it in a fraction of a second. The mechanism is set out in Clifford circuits and Stim.

Noise does not break this. Pauli noise is sampled rather than represented: the simulator draws which errors occurred according to their probabilities, inserts them as ordinary gates, and simulates the resulting pure stabilizer circuit. Averaging over many samples reproduces the noisy behaviour exactly, provided the noise is a Pauli channel, which is what Pauli twirling arranges when it is not.

The surface code

The surface code leads current hardware efforts for reasons that are practical rather than theoretical. It requires only nearest-neighbour interactions on a two-dimensional grid, which matches how superconducting processors are fabricated, and it has the highest known threshold among codes with that property.

Physical qubits alternate between data qubits, which carry the encoded state, and measurement qubits, which repeatedly measure the X-type and Z-type stabilizers of their neighbourhood. Errors on data qubits flip the outcomes of adjacent stabilizer measurements, producing detection events at the endpoints of error chains. The code distance d is the length of the shortest chain that connects opposite boundaries and therefore causes an undetectable logical error.

What researchers measure

The dominant open-source tool is Stim, which samples measurement outcomes for circuits with millions of qubits and gates. A typical workflow constructs a noisy surface-code circuit, generates a detector error model describing which physical error mechanisms flip which detectors, samples many shots, and feeds the syndrome data to a decoder.

The standard decoder is minimum-weight perfect matching, which treats detection events as vertices in a graph and finds the lowest-weight pairing that explains them, corresponding to the most probable set of errors. Union-find decoders trade a little accuracy for substantially better speed, and neural decoders are an active research direction. Decoder latency is a hard engineering constraint rather than an academic concern: a decoder slower than the syndrome measurement cycle causes the backlog to grow without bound.

The output of the workflow is a logical error rate. Repeating across code distances and physical error rates produces the figure the field tracks most closely.

The threshold

The threshold theorem states that below a critical physical error rate, increasing code distance suppresses the logical error rate exponentially. Above it, adding qubits makes matters worse, because more physical components introduce more errors than the code removes.

Code distance d   Physical qubits (~d^2)   Below threshold   Above threshold
                3                       ~9   error falls       error rises
                5                      ~25   falls further     rises further
                7                      ~49   falls further     rises further
               25                     ~625   falls further     rises further

The surface code threshold sits near 1 percent under circuit-level depolarizing noise, which is why hardware teams work specifically to push two-qubit gate errors below that figure and why the difference between 0.5 percent and 1.5 percent is the difference between a viable roadmap and an unviable one.

Below threshold the logical error rate scales roughly as (p / p_threshold) raised to the power (d+1)/2, so each increase of two in distance multiplies the suppression by a further factor. This is what makes the qubit budget calculable: a target logical error rate implies a distance, which implies a physical qubit count per logical qubit, typically in the hundreds to low thousands at realistic error rates.

From threshold to engineering

This is where simulation stops being an academic exercise. Decoder speed, code layout, biased noise, leakage out of the computational subspace, correlated errors and measurement error all shift the threshold, and each variation is a simulation experiment before it is ever a hardware experiment.

A researcher can characterise a code, tune a decoder and estimate the qubit budget for a target logical error rate without spending hardware time, then use hardware to test whether the device's actual noise resembles the model. The simulation establishes what should happen; the hardware run establishes whether the noise model was right. Neither substitutes for the other.

Running it

The stabilizer engine on this platform is built for this workload: Clifford circuits at thousands of qubits returning exact results in milliseconds, through the same API as every other backend. A 1001-qubit error-correcting code circuit runs for $0.001 and carries a public certificate, verifiable without an account at api.zksf.org/certify/86125198363b4d02.

For work on logical qubits the simulator is not a preliminary step before the real experiment. It is the laboratory, and it will remain so for as long as the codes under study are larger than the devices available to run them.

Run your own 100-qubit circuit, with an error bar.

Share this articleLink copied