Skip to documentation
← Algorithm guides

Algorithm guide · qec

QEC: Steane Seven-Qubit Code

Correct any one-qubit X, Z, or Y error with the [[7,1,3]] CSS code and six stabilizer checks.

Circuit size: 7 data + 1 recycled syndrome ancilla

Before you begin

Repetition-code syndromes · Commuting stabilizers · Binary parity-check columns

Review quantum fundamentals →
Notation used in this lesson
|ψ⟩ and ⟨ψ|
A state vector (ket) and its conjugate transpose (bra). ⟨a|b⟩ is their inner product.
α, β and i
α and β are complex amplitudes; i²=−1. A probability is the squared magnitude |α|².
XOR, · and ⊗
XOR adds bits modulo two. In s·x, multiply corresponding bits and XOR them. ⊗ combines registers or operations on different wires.
U†, Σ and Tr
U† is the adjoint (inverse for a unitary). Σ sums terms. Tr is the matrix trace, the sum of diagonal entries.
Probability, shots and angles
Ideal probabilities describe the model; measured shot frequencies fluctuate. Angles inside trigonometric expressions are in radians unless explicitly labeled turns.

1. The problem

Encode one logical qubit into seven data qubits and correct any single-qubit Pauli X, Z or Y error. Distinguish logical information from the six stabilizer signs used to diagnose the error.

2. How it works

Three Z-type checks locate an X component, and three X-type checks locate a Z component. Each data wire has a distinct three-bit syndrome column. A Y error has both components and activates both check groups.

  1. Encode

    Prepare the seven-qubit CSS codeword from the chosen logical state.

  2. Inject

    Apply one selected Pauli error on a data qubit.

  3. Extract six checks

    Reuse one resettable ancilla sequentially, preserving each result in a distinct classical bit.

  4. Recover and verify

    Use syndrome columns for X/Z corrections, decode and undo logical preparation.

3. The mathematics, one idea at a time

g|ψ_L⟩=|ψ_L⟩ for each stabilizer g

Code states have stabilizer eigenvalue +1. If an error anticommutes with g, its check sign changes to −1.

X_j anticommutes with Z checks containing j; Z_j anticommutes with X checks containing j

Y_j behaves as both components, up to phase.

This circuit’s wire columns q0…q6: 111,011,101,001,110,010,100

These are displayed three-bit integers in its chosen check order; other textbooks may permute the columns.

Work this through by hand

4. Single X error on q0

Seven data plus one recycled ancilla: eight physical qubits. This code has fixed width.

Choose logical |0⟩, error X on q0 and correction on.

StageCalculation or stateWhat it means
Which Z checks contain q0?Z0, Z1 and Z2All three anticommute with the injected X.
Which X checks flip?NoneX commutes with the X-type checks.
Syndromec5c4c3 | c2c1c0 = 000|111The low check group selects q0 for X recovery.
VerificationSeven decoded data-check bits are all zeroThe syndrome remains in the six low classical bits.

Expected outcomes for this example

These are ideal predictions for the stated configuration, not a result already measured by your browser. Rows describing alternative modes or combined events are labeled explicitly.

Outcome or eventIdeal probabilityInterpretation
0000000|000|111100% ideal for this configurationSeven verification bits, three X-check results, three Z-check results.

5. Load the worked example in Composer

The worked example can use smaller or simpler inputs than the gallery defaults. The button below loads the exact circuit used in this lesson.

Logical input state
0
Introduce a single-qubit error
On
Error type
X
Data qubit receiving the error
0
Enable correction
On
  1. Save any current circuit you want to keep, then open the worked example. Loading it does not execute a paid hardware job.
  2. Trace the preparation, main operations and measurements against the worked table. Check the gate editor for controls, targets and angles.
  3. Start with an ideal noiseless simulator compatible with the circuit. Mid-circuit measurement, reset and feed-forward require support from the chosen backend.
  4. Inspect the live preview. For a recorded experiment, open Execute, set the available backend options and shots, and Run. Sign in when prompted to retain it in My Jobs.
  5. Read the output as described below before changing one setting and repeating. The guide describes the original example; edits can change the answer.

6. Read the output correctly

The full output contains 13 classical bits, despite only eight physical qubits, because the ancilla is reused.

Do not compare syndrome bit order with a textbook table until the check convention is matched.

For arbitrary noise, a clean-looking syndrome does not rule out a logical error; single-error correction is the guaranteed setting here.

A bit label is a register value; its bar height is a probability or count. For S shots and observed count k, the sampled frequency is k/S. A typical sampling scale for probability p is √[p(1−p)/S]; this is not a strict error bound. Finite samples do not have to match the ideal percentages exactly.

7. Common mistakes & limits

  • [[7,1,3]] means seven physical data qubits, one encoded logical qubit, distance three; it does not mean three-error correction.
  • Reset the recycled ancilla between checks. Reusing its old state would change the measurement circuit.

8. Check your understanding

What are the two three-bit syndrome groups for Y on q0?

Reveal the reasoning

Both are 111: the X and Z components each flip their corresponding group.

9. Further study

The lesson’s register mappings, supported inputs and loadable example follow Quantket’s implemented circuit. A reference may use different wire names, bit order or resource conventions.

Gallery reference: defaults, definitions & implementation notes

Inputs & default settings

Choose the logical state |0⟩, |1⟩, |+⟩, |−⟩, |+i⟩ or |−i⟩; whether to introduce an error; its X, Z, Y or seeded-random type; and a data-qubit target or seeded-random target. A seed makes random choices repeatable.

Switch syndrome-conditioned correction on or off.

logicalState
Gallery default: +
protection
Gallery default: bit
introduceError
Gallery default: true
errorType
Gallery default: X
targetQubit
Gallery default: 0
correctionEnabled
Gallery default: true
seed
Gallery default: 417
rounds
Gallery default: 5
shots
Gallery default: 256
recoveryMode
Gallery default: pauli-frame
physicalErrorRate
Gallery default: 0.002
readoutErrorRate
Gallery default: 0.005

Implementation notes

The six checks are measured sequentially with one resettable physical ancilla. The ghost map previews which check outcomes become −1 before the circuit is generated.

Read your saved result

Check the submitted circuit, measured register and execution settings in Run details. Exact results give computed probabilities; sampled results show frequencies from the recorded shots. Edited circuits and noise can change the expected outcome. The algorithm label records the circuit's origin; it does not certify an edited circuit or a measured result.