Skip to main content
All visualizations
Advanced

Decoder Duel: Lookup vs Learned

A neural decoder trains live in your browser and chases majority vote — which, on this code, it can only ever tie.

Decoder Duel: Lookup vs Learned visualization

Top: each decoder’s running logical error rate as shots accumulate, with the exact optimal rate as the dashed line. Bottom: the syndrome trace — the parity bits that are the only thing either decoder is shown, with each contestant’s verdict per shot (dot = corrected, ✕ = logical error). Both decoders see the same syndromes in the same order.

The rules of the duel

The distance-5 repetition code stores one logical bit as 5 copies. Noise flips each copy independently with probability p, and neither decoder ever sees the bits — only the 4 adjacent-pair parities, the syndrome. Exactly two error patterns are consistent with any syndrome: a candidate chain and its bitwise complement. Decoding is choosing between them, and choosing wrong is a logical error — the stored bit silently flips and no later measurement can tell.

Contestant one is majority vote: take the lighter of the two consistent patterns, a one-line lookup. Contestant two is a genuine two-layer perceptron — 16 tanh hidden units, a sigmoid output — trained by streaming gradient descent on 60,000 noisy shots sampled at your chosen p, in your browser, the moment you change a control. The “Trained in” stat is a real wall-clock measurement of that run.

Spoiler: the network cannot win — and that is the lesson

For a repetition code under independent bit-flip noise at p < ½, majority vote is the maximum-likelihood decoder, and it coincides with minimum-weight perfect matching on this code’s one-dimensional syndrome graph: the two consistent patterns differ only in weight, and the lighter one is strictly more probable. There is no information in the syndrome that majority vote fails to use. The best any decoder — neural or otherwise — can do here is make the same decisions.

So watch what the violet line actually does: early in training-quality terms it can sit above the teal line, and as the network converges the two lines meet at the dashed optimum. A demo that showed a neural decoder “beating” majority vote on this code would be rigged, and plenty of flashy ML-for-QEC demos quietly are. The honest claim is narrower and more interesting: the network learns the optimal decoder from samples alone, without ever being told the majority rule.

Then why does anyone train decoders?

Because real codes are not repetition codes. On a distance-d surface code the lookup table has 2d²−1 rows — about 17 million at d = 5, beyond astronomical at d = 11 — and matching decoders, while fast, are provably optimal only for independent noise. Real devices have correlated errors, faulty syndrome measurements, crosstalk, and leakage, none of which the matching graph models cleanly. That is the regime where learned decoders (transformer and graph-network decoders in the recent literature, including on real hardware data) genuinely outperform the classical baselines: they can absorb noise structure that no one hand-modelled.

This page is the control experiment for those claims. On a code where the optimum is computable in one line, a trained network should reach it and stop — and here you can verify, shot by shot, that it does. When you next see a learned decoder beat MWPM on a surface code, you will know exactly what question to ask: what structure in the noise did it find that the matching graph was blind to?

What the distance buys, measured live

Run the duel at each distance and keep p fixed at 5%. The optimal logical error rate is exact and printed in amber: 0.73% at d = 3, 0.12% at d = 5, 0.02% at d = 7 — each two extra physical bits buy better than a 5× improvement, because failure now needs 2, 3, 4 simultaneous flips respectively. Your Monte Carlo estimates should straddle those numbers; the same scaling law, run on this engine, is asserted in this page’s test suite rather than taken on faith.

One honest limitation: this is a classical repetition code protecting against bit flips only, with perfect syndrome extraction — the “hello world” of error correction, not the surface code. It is used here precisely because its optimal decoder is provable, which is what makes an honest duel possible. For the real thing — two error types, a 2-D lattice, and a matching decoder that can be legitimately fooled — see The Surface Code visualization.