Surface Code Decoding Lab

Place your own errors on data qubits, run a real decoder, and see whether the logical qubit survived.

?How this works

Data qubits are the small dots (the edges of the grid). Stabilizers are the squares. Click a data qubit to toggle a bit-flip error (red). Each error flips the stabilizers at its endpoints — those light up as syndromes.

The decoder (MWPM = Minimum-Weight Perfect Matching) pairs syndromes along the shortest paths, or connects a lone syndrome to the nearest rough boundary (yellow bars). Its guess is the green correction.

A logical error happens when your error + the decoder's correction together form a chain that crosses from the left boundary to the right — a logical operator. Then the data is silently corrupted. A distance-3 code is guaranteed to fix any 1 error(s).

This shows one error type (bit-flip). Phase-flip decoding is identical by symmetry.

Run both on the same errors — greedy can create a logical error where MWPM succeeds.

Legend

data qubit (click to add error)
bit-flip error
lit stabilizer (syndrome)
decoder correction
matching
rough boundary

Physical Qubit Calculator

10⁻¹10⁻610⁻¹⁵

At 10% physical error rate:

Distance 3: 17 qubits
Distance 5: 49 qubits
Distance 7: 97 qubits

A distance-d rotated surface code uses d² data + (d²−1) ancilla = 2d²−1 physical qubits.

Why this matters

Physical qubits fail ~1 in 100–1000 operations. To run a real algorithm you need a logical error rate near 10⁻¹⁵ — which means wrapping thousands of physical qubits around each logical one. Estimates put factoring RSA-2048 at roughly 20 million physical qubits. That gap is why error correction, not just more qubits, is the central challenge.

Measurement Errors & Rounds

Real stabilizer measurements are themselves noisy. A single round can't tell a measurement error from a data error — you repeat the measurement and decode across time.

Compares a naive single-round decoder vs a space-time decoder (5-round) as measurement noise rises.

Export

JSON captures your errors, syndromes, correction, and verdict. The .dem is the decoding graph — feed it straight to PyMatching / Stim.

Click any data qubit (dot) to add or remove a bit-flip error, then run the decoder.

Illustrative curves. Click “Run Monte-Carlo” to sample real errors, decode them, and plot the empirical logical error rate — the curves will cross at the code's true threshold.