Steane's 7-Qubit Code
Overview
Steane's code is a [[7,1,3]] CSS code — it encodes 1 logical qubit into 7 physical qubits with distance 3, correcting any single-qubit error. Built from the classical Hamming [7,4,3] code, it is more efficient than Shor's 9-qubit code (rate 1/7 vs 1/9) and has the remarkable property that H, CX, and S gates can be applied transversally (bitwise), making them automatically fault-tolerant.
CSS Code Construction
Steane's code is a Calderbank-Shor-Steane (CSS) code, meaning its X and Z stabilizers come from independent classical codes:
- Start with the Hamming [7,4,3] code (classical, corrects 1 bit error)
- The Hamming parity check matrix defines Z stabilizers (detect X errors)
- The same parity check matrix defines X stabilizers (detect Z errors)
- Because Hamming [7,4,3] is self-dual (C contains C-perp), this works!
This self-dual property is what makes transversal H possible — applying H to all 7 qubits simply swaps the X and Z stabilizers, which have the same structure.
Stabilizers
X Stabilizers (detect Z errors)
| Stabilizer | Qubits | Operator |
|---|---|---|
| g1 | 3, 4, 5, 6 | X_3 X_4 X_5 X_6 |
| g2 | 1, 2, 5, 6 | X_1 X_2 X_5 X_6 |
| g3 | 0, 2, 4, 6 | X_0 X_2 X_4 X_6 |
Z Stabilizers (detect X errors)
| Stabilizer | Qubits | Operator |
|---|---|---|
| g4 | 3, 4, 5, 6 | Z_3 Z_4 Z_5 Z_6 |
| g5 | 1, 2, 5, 6 | Z_1 Z_2 Z_5 Z_6 |
| g6 | 0, 2, 4, 6 | Z_0 Z_2 Z_4 Z_6 |
Logical Operators
- X_L = X_0 X_1 X_2 X_3 X_4 X_5 X_6 (X on all qubits)
- Z_L = Z_0 Z_1 Z_2 Z_3 Z_4 Z_5 Z_6 (Z on all qubits)
Syndrome Table
The syndrome is a 3-bit number equal to (qubit_index + 1) in binary:
| Syndrome | Error Location |
|---|---|
| 000 | No error |
| 001 | Qubit 0 |
| 010 | Qubit 1 |
| 011 | Qubit 2 |
| 100 | Qubit 3 |
| 101 | Qubit 4 |
| 110 | Qubit 5 |
| 111 | Qubit 6 |
The Z syndrome identifies X errors; the X syndrome identifies Z errors. For a Y error, both syndromes are non-trivial (same location).
The Encoding Circuit
CODE┌───┐ q_0: ┤ H ├──■──────■────────────■── ├───┤ │ │ │ q_1: ┤ H ├──┼──────┼────■───■──┼── ├───┤ │ │ │ │ │ q_2: ┤ H ├──┼──────┼────┼───┼──┼── └───┘┌─┴─┐ ┌─┴─┐ │ │ │ q_3: ─────┤ X ├──┤ X ├──┼───┼──┼── (from q0, q1) └───┘ └───┘┌─┴─┐ │ │ q_4: ──────────────────┤ X ├─┼──┼── (from q0, q2) └───┘┌┴──┴┐ q_5: ───────────────────────┤ X ├─ (from q1, q2) └────┘ q_6: ──── (from q0, q1, q2) ──────
Transversal Gates — The Key Advantage
Steane's code supports transversal (bitwise) application of several gates:
| Gate | Application | Fault-Tolerant? |
|---|---|---|
| H | Apply H to all 7 qubits | Yes (swaps X <-> Z stabilizers) |
| CX | Apply CX bitwise between two code blocks | Yes |
| S | Apply S to all 7 qubits | Yes |
| X, Y, Z | Apply bitwise | Yes |
| T | NOT transversal | No (needs magic state distillation) |
Why this matters: Transversal gates cannot spread errors between qubits within a code block. A single-qubit error stays a single-qubit error, so the code can still correct it. This is the simplest route to fault tolerance.
Running the Circuit
PYTHONfrom circuit import run_circuit, verify_steane_code # No error result = run_circuit() print(f"Success: {result['success_rate']:.2%}") # X error on qubit 3 result = run_circuit(error_type='X', error_qubit=3) print(f"After correction: {result['success_rate']:.2%}") # Z error on qubit 5 result = run_circuit(error_type='Z', error_qubit=5) print(f"After correction: {result['success_rate']:.2%}") # Full verification v = verify_steane_code() for check in v["checks"]: print(f"[{'PASS' if check['passed'] else 'FAIL'}] {check['name']}")
Code Properties
| Property | Value |
|---|---|
| Notation | [[7, 1, 3]] |
| Physical qubits | 7 |
| Logical qubits | 1 |
| Code distance | 3 |
| Correctable errors | t = 1 (any type) |
| Rate | 1/7 ~ 0.143 |
| Syndrome qubits | 6 (3 for X, 3 for Z) |
| Total qubits | 13 |
| Code family | CSS (self-dual Hamming) |
Comparison with Shor Code
| Feature | Shor [[9,1,3]] | Steane [[7,1,3]] |
|---|---|---|
| Physical qubits | 9 | 7 |
| Rate | 1/9 | 1/7 |
| Structure | Concatenated | CSS (algebraic) |
| Syndrome qubits | 8 | 6 |
| Transversal H | No | Yes |
| Transversal CX | No | Yes |
| Total qubits | 17 | 13 |