English static mirror for SEO/GEO · AI-assisted translation · Read Chinese original

Running a Surface Code Error-Correction Cycle on a Simulator

Forum topic · 小凯 · 2026-11-07

Summary

This tutorial walks through a complete surface code error-correction cycle (QEC cycle) on a simulator, using the minimal d=3 board with 9 data qubits and 8 stabilizer ancilla qubits. The cycle has four steps: run the logical operation, read the stabilizer sentinels (measuring parity without touching logical information), decode the syndrome (minimum-weight matching to find the most likely error chain), and apply correction (often just bookkeeping in software frames). Three hands-on experiments demonstrate core concepts: a clean board yields an all-zero syndrome; a single injected X error lights up exactly two adjacent stabilizer checks, and the pattern shifts with error location, revealing how syndromes encode position; X and Z errors trigger separate stabilizer families. A 1000-round repeated-cycle experiment shows threshold behavior: at 0.5% physical error rate, larger code distance lowers logical error rate, while above the ~1% threshold, larger codes perform worse. The post also notes real-machine constraints: cycles must complete in microseconds with dedicated real-time decoding hardware. Decoding is inference from traces, not direct observation, and cleanliness is a dynamic balance where patrol speed exceeds contamination rate.

Running a Surface Code Cycle on a Simulator

> Prerequisites: posts 055 (surface code board and threshold), 054 (stabilizers — checking for damage, not content), 051 (error rates), 091 (simulator workflow). > Next up: 096, "Measurement Also Lies: Readout Error Mitigation."

A robot vacuum patrols every day: sweep → spot dirt → clean → return to dock → repeat. The surface code's error-correction cycle is the same patrol routine: read the sentinels → compare for anomalies → infer the error → apply the fix — then start over immediately, forever.

Post 055 drew the board, post 054 explained the sentinel principle — this post assembles both into a patrol machine you can run yourself: on a simulator, the minimal d=3 board (9 data qubits + 8 stabilizer sentinels) runs one complete cycle, followed by three experiments.

The Four Steps of a Cycle

Step 1: Run the business. The logical qubit does its job (in these experiments, simply "quietly holding a memory state" — the plainest workload).

Step 2: Read the sentinels. Each of the 8 stabilizers is measured via an ancilla qubit (post 054's "check for injury, not content" — parity is measured, logical information is never touched). This reads out an 8-bit string of 0/1s — the syndrome: the board's anomaly report.

Step 3: Decode. Syndrome → error locations. Post 055 said errors form "chains" and stabilizers alarm at the chain's two ends. The decoder's plain-language job: find the shortest chain that explains all the alarms (like locating a sound by ear: both ears ring, so the source is in the middle). A minimum-weight matching decoder does exactly this.

Step 4: Apply the fix. Apply a correction at the inferred error locations — in practice this is often software bookkeeping (a note in the "frame," cancelled out at later readout), without physically touching the qubits.

The four steps run back-to-back, then start over from the top — the patrol is continuous; a single round would miss paired errors spanning rounds.

Experiment 1: A Clean Board

No noise, one cycle: all-zero syndrome — all 8 sentinel lights green. Baseline established.

Experiment 2: Inject One Error

Manually inject an X error on one data qubit (post 020's switch), then run one round: exactly two adjacent stabilizers alarm (two 1s in the syndrome string) — post 055's "one error lights two lamps" live: a chain has two endpoints, and each sentinel sees half. Move the injected error to the center of the board, and the two lit lamps shift accordingly — the pattern of lit sentinels is the location information, and that's precisely what the decoder consumes.

(The same experiment with a Z error: a different set of sentinels alarms — X-type and Z-type stabilizers each mind their own turf, post 055's "two patrols" in action.)

Experiment 3: Continuous Patrol and the Threshold, Live

The final experiment puts the whole series' promise on the table:

Setup: run 1000 cycles, injecting random errors each round at some physical error rate (simulating a real machine); measure the logical error rate (fraction of rounds where the logical qubit is still wrong after the patrol).

Result 1 (benefit below threshold): at a 0.5% physical error rate, the d=3 logical error rate is below the physical value — the patrol pays off; raising d to 5 drops the logical error rate by another order of magnitude — post 055's "bigger code gets better," live.

Result 2 (worsening above threshold): push the physical error rate past threshold (~1%), and larger d makes things worse — the sentinels themselves generate errors, and the bigger the board, the more overwhelmed the patrol — post 055's "threshold theorem" turned from formula into a visible curve kink.

Result 3 (the speed requirement): on real hardware each cycle must finish in microseconds (post 051: errors arise on microsecond timescales) — the patrol must outrun contamination for the board to stay clean (the same logic as post 083's "drainage must exceed inflow"). In a simulator, decoding can take its time; on real hardware the decoder is dedicated real-time hardware — one of the limits of "simulator first."

Tearing Down the Analogy

Where the robot vacuum analogy breaks:

  • Disanalogy 1: a vacuum "sees" the dirt itself (optical imaging); a surface code sees only traces of the dirt (parity anomalies) — sentinels never report "which qubit is wrong," only "which two lamps are lit." Decoding is inference, not observation — position is inferred from traces, always mediated by the decoder's judgment (which can also guess wrong).
  • Disanalogy 2: one vacuum pass means one pass of cleanliness; a surface code's "clean" holds only while patrol speed > contamination speed — cleanliness is not a state but a dynamically enforced equilibrium.

What to Take Away

1. The four-step cycle: read sentinels → compare anomalies (syndrome) → infer (shortest-chain decoding) → fix (often software bookkeeping) — then loop forever; clean is a dynamic equilibrium, not a one-shot state. 2. Two-lamp localization: one error lights adjacent sentinels — the syndrome's "lighting pattern" is all the decoder's raw material; X and Z each have their own sentinel groups. 3. The threshold, live (experiment-class perspective, Nov 2026): below threshold, bigger codes win; above, they lose — post 055's formulas can be plotted by hand in a simulator overnight; real-machine patrols need microsecond cycles with dedicated decoding hardware.

Hook for the next stop: the patrol is done, but there's a subtler lie — measurement itself lies: what fraction of read-out 0s are actually 1s? Measuring, modeling, and mitigating readout error in 096, "Measurement Also Lies: Readout Error Mitigation."

*(Hashtags in original: quantum computing / from coins to error correction / surface code / error correction in practice.)*

Tags

#quantum-computing#surface-code#error-correction#syndrome-decoding#quantum-simulation#threshold#stabilizer-codes#minimum-weight-matching

This page is an English static mirror generated for search and AI citation. It may be a full translation or structured summary of the Chinese original. Canonical interactive discussion lives on the Chinese page: https://zhichai.net/topic/178636929