Chapter 25 — Key Takeaways (Quantum Error Correction in Code)

Part IV closes here. Error correction is the assumption under Chapters 21–23, and §25.9 is the condition it fails.

Entangle, don't copy

No-cloning forbids $|\psi\rangle \to |\psi\rangle|\psi\rangle|\psi\rangle$, and measuring to compare would collapse the state. Both problems have one resolution:

$$\alpha|0\rangle + \beta|1\rangle \;\longrightarrow\; \alpha|000\rangle + \beta|111\rangle$$

Not three copies. Each qubit alone is maximally mixed; the information is in the correlations. And the parity $Z_0Z_1$ is a different observable from $Z_0$ and $Z_1$ — it returns "same or different" and leaves $\alpha,\beta$ untouched.

⚛️ Redundancy without copying; comparison without inspection. Everything else is elaboration.

The three-qubit code, and the crossover

     p     unencoded    encoded   3p^2-2p^3
  0.05        0.0500     0.0075      0.0073
  0.20        0.2000     0.1011      0.1040
  0.45        0.4500     0.4254      0.4253
  0.50        0.5000     0.5003      0.5000   <-- crossover
  0.60        0.6000     0.6494      0.6480   <-- correcting ADDS error

$3p^2 - 2p^3 = p \Rightarrow 2p^2 - 3p + 1 = 0 \Rightarrow$ $p = \tfrac12$ exactly, and the measurement puts it there.

★ The blind spot

A phase-flip test storing $|+\rangle$ reported 0.0000 at every $p$, including 0.6 — where correction is impossible. Conjugating the error back through the decoder:

   physical ZII after encoding  ==  IIX  before it

The logical error is an $X$, and $X|+\rangle = |+\rangle$. The stored state was an eigenstate of the failure being measured.

⚠️ Test BOTH logical basis states, against X, Z and Y, and report the worst.

Two mechanisms make a test unable to fail: the state is an eigenstate of the physical error ($|000\rangle$ under $Z$), or the residual logical error stabilizes it ($X_L$ on $|+_L\rangle$).

Blindness depends on the CODE, not just the state — the phase-flip code is blind exactly where the bit-flip code sees. The first version of the project module's rule omitted the code argument and was wrong for half the table; a test comparing the rule against the simulator in all twelve cells caught it.

★ One code is never enough

Logical error rate at $p = 0.05$; unencoded baseline 0.0500:

   code        stored     X noise  Z noise  Y noise      WORST
   bit-flip    |0_L>       0.0079   0.0000   0.0079
   bit-flip    |+_L>       0.0000   0.1346   0.1345      0.1346  WORSE THAN NOTHING
   phase-flip  |0_L>       0.0000   0.0079   0.0079
   phase-flip  |+_L>       0.1346   0.0000   0.1345      0.1346  WORSE THAN NOTHING

The zeros are blind spots, not successes. And read the bit-flip / $|+_L\rangle$ / $Z$ cell: 0.1346 against 0.0500 — 2.7× worse. Three qubits, three chances at a phase error: $1-(1-p)^3 = 0.1426$.

🔬 A code that fixes one error type AMPLIFIES the other. Encoding is not a neutral act.

The Shor code: two true statements that sound contradictory

It corrects any single-qubit error. Exactly checkable, and exactly true:

   54 injections (X, Y, Z on all 9 qubits, both logical states) -> 0 failures

And its breakeven is far worse than the three-qubit code's:

   Z noise:  breakeven 1/27 = 0.037    (block flips if ANY of 3 qubits gets a Z:
                                        q ~ 3p, then 3q^2 -> 27p^2)
   X noise:  breakeven 1/9  = 0.111    (inner fails at 3p^2, three blocks -> 9p^2)
   3-qubit:  breakeven 1/2  = 0.500

🔬 "Corrects any single-qubit error" is a DISTANCE claim, not a performance claim. It says the distance is 3. It does not say the code helps at your noise rate, and it does not say the protection is symmetric — Shor's is 3× weaker against $Z$ than against $X$.

More qubits does not monotonically improve anything.

Stabilizers

   code                 n  generators  k   commute?
   3-qubit bit-flip     3      2       1     True     ZZI, IZZ
   3-qubit phase-flip   3      2       1     True     XXI, IXX
   Shor   [[9,1,3]]     9      8       1     True
   Steane [[7,1,3]]     7      6       1     True     <-- distance 3 for 7 qubits

$S_i|\psi\rangle = +|\psi\rangle$ for every generator; $n-k$ generators leave a $2^k$-dimensional codespace.

⚛️ Commuting is the requirement that makes it work. Generators commute → measurable simultaneously. Each acts trivially on the codespace → the syndrome carries $n-k$ bits, every one about the ERROR and none about $\alpha,\beta$. That is why measuring a syndrome is safe.

Stabilizer circuits are Clifford, so Gottesman–Knill applies (Ch. 11) — which is why distance-9 simulations here are instant.

Feedforward

Mid-circuit measurement plus if_test agrees with unitary correction to four decimals. It is what hardware runs, and it needs classical control fast enough to close the loop inside the coherence time, repeatedly, forever.

★★ The threshold

        p        d=1        d=3        d=5        d=7        d=9
     0.10     0.0999     0.0279     0.0089     0.0027     0.0010
     0.30     0.3004     0.2191     0.1637     0.1265     0.0993
     0.50     0.4997     0.5046     0.5038     0.5018     0.5019   <-- THRESHOLD
     0.60     0.6005     0.6508     0.6867     0.7144     0.7377
     0.70     0.6986     0.7844     0.8408     0.8759     0.9033

Below: the curves fan DOWN. Above: they fan UP. They cross at the threshold.

$$\Lambda = \frac{P_L(d)}{P_L(d+2)}$$

   p=0.01  Lambda(3->5)=30.25  (5->7)=28.83  (7->9)=28.04
   p=0.05                6.26            5.98            5.83
   p=0.10                3.27            3.14            3.06
   p=0.20                1.80            1.74            1.70

$\Lambda$ is constant down each column — exponential suppression for linear qubit cost. That is the entire case for fault tolerance.

⚛️ It is a THRESHOLD, not a slope. Below it, any logical error rate is reachable by building a bigger code. Above it, no size of code helps — you are on the wrong side of a phase transition.

And $\Lambda$ collapses near threshold: 28× at $p=0.01$, 1.7× at $p=0.20$. Being barely below is nearly as bad as being above. Chapter 15's millions of physical qubits are the price of operating close to threshold.

★★ The threshold you actually face

All of the above assumes perfect syndrome extraction. Give those gates an error rate, with $p_{\text{data}} = 0.01$:

   syndrome gate error   logical error   verdict
              0.0030            0.0092    HELPS
              0.0035            ~0.010     breakeven
              0.0040            0.0122    HURTS
              0.0078            0.0238    HURTS   <-- Ch. 12's MEASURED median

🔬 At real measured gate quality this code makes things 2.4× WORSE, using three times the qubits.

The circuitry that fixes errors is made of the gates that cause them. This is why real thresholds (~$10^{-2}$ for the surface code) are so much more demanding than the naive 0.5, and it is why QEC is not deployed today.

Same shape as Ch. 13 (mitigation costs shots), Ch. 19 (a dirty ancilla looks like decoherence), Ch. 24 (mitigation at a fixed budget can lose). Every remedy is denominated in the currency of the disease.

The surface code

Chosen for practical reasons: nearest-neighbour on a 2D grid (Ch. 17's topologies), threshold ~$10^{-2}$, weight-4 local stabilizers so extraction is shallow and repeatable. Costs $\approx 2d^2$ physical qubits per logical qubit.

It supports Clifford gates but not $T$ — hence magic state distillation, hence Chapter 15's $T$-count-dominated estimates and Chapter 22's rotationCount/rotationDepth.

📌 Google reported below-threshold surface-code operation in 2024 — distance 7, $\Lambda \approx 2$.** A genuine landmark: the fan points downward on real hardware. **But $\Lambda \approx 2$, not 28 — that is close to threshold, where useful logical error rates need very large $d$. Below threshold is necessary, not sufficient. Check the current state of the art; this is the fastest-moving number in the field.

What Part IV adds up to

   NEEDS FAULT TOLERANCE                DOES NOT
   Shor, phase estimation, Grover       VQE, QAOA
   proven advantage (Shor)              no proven advantage
   blocked on THIS CHAPTER              blocked on the shot budget (Ch. 24)

Neither column has produced a useful computation a classical computer could not do. The left has the theory and waits on hardware; the right has the hardware and waits on theory.

Common pitfalls

  • Transpiling with the default optimization level, which deletes id noise slots.
  • Not verifying the noise is in the transpiled circuit.
  • Testing one logical basis state, and believing the zeros.
  • Reading a code's distance as a statement about its performance.
  • Simulating with noiseless syndrome extraction.
  • Reporting an improvement factor when the decision needs a breakeven.
  • Assuming more qubits monotonically helps.

Project piece added this chapter

vqelab/errorcorrection.pylogical_error_rate returning a CodeResult with a blind flag; worst_case_logical_error sweeping both basis states × X/Y/Z; code_helps, which has no state parameter at all because that is the question you must not ask; shor_single_error_sweep (54 injections); suppression_factor; syndrome_breakeven. 31 tests pass, including test_the_three_qubit_code_is_WORSE_THAN_NOTHING_for_arbitrary_states, test_the_fan_reverses_above_threshold, and test_at_chapter_12s_MEASURED_gate_error_the_code_makes_things_worse.