Curriculum / Noise & Error Correction / Syndrome Decoding
Syndrome Decoding
Implement a syndrome measurement and classical correction for a 3-qubit code.
Syndrome Decoding
Syndrome decoding is the classical algorithm that interprets the syndrome (the parity check outcomes; larger codes call these stabilizer measurements) and identifies the most likely error to correct. It is the "brain" of a quantum error correcting system, running on classical hardware adjacent to the quantum processor.
The syndrome and parity check matrix:
For a code with parity check matrix H, the syndrome s is computed as:
s = H · e (mod 2)
where e is the error vector (1 where an error occurred, 0 elsewhere). The syndrome doesn't tell you the exact error: only the equivalence class: any error e' with H·e' = s has the same syndrome as e.
Syndrome table (lookup decoding):
For small codes, the simplest decoder is a lookup table mapping each syndrome to the most likely error:
| Syndrome s | Most likely error e | Correction |
|---|---|---|
| 00 | No error | None |
| 10 | Error on qubit 0 | X on qubit 0 |
| 11 | Error on qubit 1 | X on qubit 1 |
| 01 | Error on qubit 2 | X on qubit 2 |
For small codes (distance 3, 5 qubits), this works perfectly. For large codes, the table has entries: exponential in n.
The optimal decoder (maximum likelihood) chooses the correction that maximizes the probability given the syndrome. For independent, identically distributed (i.i.d.) errors with rate p < 1/2, this is equivalent to minimum weight decoding: find the error with fewest affected qubits consistent with the syndrome. For correlated errors (like from two-qubit gates), minimum weight decoding can fail and maximum likelihood decoding is needed. For surface codes, minimum-weight perfect matching (MWPM) closely approximates maximum likelihood.
Minimum-weight perfect matching (MWPM):
For the surface code, a 2D code you will meet later in this track, syndrome measurements mark "defects" (stabilizers that measured -1). A Z error creates two X-defects; an X error creates two Z-defects. MWPM finds the minimum-weight set of error chains that connects all defect pairs:
This is the opening of the lesson. The full walkthrough, the interactive circuit, and the graded challenge continue inside myqubit.
How this lesson works
A hands-on coding challenge. You write Qiskit-compatible Python in the browser editor, run it instantly via WebAssembly, watch the circuit and Bloch sphere react, and pass automatic output checks. The AI tutor Qubitus gives Socratic hints if you get stuck.
Part of: Noise & Error Correction
Understand quantum noise and build error correction codes to protect quantum information.
This lesson is part of Pro
Unlock Noise & Error Correction and all 10 tracks with Pro: $12.99/month, $79/year, or $97 lifetime. Start with the free track first if you are new.