# Surface Code
The **surface code** is the most widely pursued [[Quantum Error Correction|error-correcting code]] for near-term hardware. It is the [[Toric Code|toric code]] flattened onto a patch with edges — a 2D sheet of qubits — so it needs only nearest-neighbour interactions on an ordinary chip.
## First principles
Arrange qubits on a 2D grid in two roles:
- **Data qubits** hold the encoded information.
- **Measure (ancilla) qubits** sit between them and repeatedly perform local [[Syndrome Extraction|parity checks]] on their neighbours.
Each round, every measure qubit reports whether its local neighbourhood is consistent. Errors show up as flipped checks; a classical decoder pairs up the flips and infers the correction. Because all checks are **local and identical across the sheet**, the scheme is uniform and scalable.
The protection is set by the **distance** $d$ — roughly the width of the patch. A larger patch corrects more errors:
$
\text{logical error rate} \;\sim\; \Big(\frac{p}{p_\text{th}}\Big)^{d/2}
$
As long as the physical error rate $p$ is below the [[Code Distance and Threshold Theorem|threshold]] $p_\text{th}$, enlarging $d$ drives the logical error rate down exponentially. Demonstrating that "bigger patch ⇒ fewer logical errors" is the milestone called going **below threshold**.
> [!intuition] Trading qubits for reliability
> Want a thousand-fold safer logical qubit? Make the patch a few rows bigger. The surface code turns reliability into a knob you turn by spending more physical qubits.
## Why it matters
- Its **high threshold** (around $1\%$) and **2D-local** checks make it forgiving of realistic hardware, which is why many roadmaps build on it.
- The cost is **overhead**: high distance means many physical qubits per [[Physical vs Logical Qubits|logical qubit]]. Reducing that overhead motivates alternatives like [[qLDPC Codes]].
## Related
- [[Toric Code]]
- [[Stabilizer Codes]]
- [[Code Distance and Threshold Theorem]]
- [[qLDPC Codes]]
- [[Mid-Circuit Measurement]]