QubitLab
IDELearnPlaygroundDocsCommunity
Log in
QubitLab
IDELearnPlaygroundDocsCommunity
Log in
QubitLab
IDELearnPlaygroundDocsCommunity
Log in
HomeLearnCatalogRanksPlaygroundDocs
04 · Error correction in one lesson0%

You are reading without signing in. Sign in or continue as guest to take quizzes and climb the ranks.

Learn/QC 301Noise and Errors·Lesson 4 of 4

Error correction in one lesson

The three-qubit repetition code, syndromes, and the road to a logical qubit.

Advanced14 min read4 sections · 2 questions+45
By the end you will be able to
  1. 01Encode one logical bit in three physical qubits and detect a bit flip without measuring the data.
  2. 02Explain what a syndrome is.
  3. 03Place the surface code and the threshold in context.

You cannot copy a qubit, and you cannot look at it without collapsing it. Error correction gets around both: spread the information over several qubits (entangle, do not copy) and measure only parities, which reveal where an error happened but nothing about the encoded value.

∣0ˉ⟩=∣000⟩,∣1ˉ⟩=∣111⟩,α∣0ˉ⟩+β∣1ˉ⟩=α∣000⟩+β∣111⟩
The bit-flip repetition code. Parities Z₀Z₁ and Z₁Z₂, measured into two ancillas, form the syndrome: 00 = no flip, 10 = qubit 0, 11 = qubit 1, 01 = qubit 2.
Hands-on

Detect and correct a flip with feed-forward

q0 is the data, encoded into q0 q1 q2; an X on q1 simulates an error; one helper qubit q3 reads both parities in turn (reset in between, so four qubits are enough); if-blocks apply the correction; the final measurement decodes. Simulate: the logical bit c[0] reads 1 every time despite the error. Move the X to q2 and watch the syndrome change.

OpenQASM 3
OPENQASM 3.0;
include "stdgates.inc";
qubit[4] q;
bit[3] c;
x q[0];
cx q[0], q[1];
cx q[0], q[2];
barrier q;
x q[1];
barrier q;
cx q[0], q[3];
cx q[1], q[3];
c[1] = measure q[3];
reset q[3];
cx q[1], q[3];
cx q[2], q[3];
c[2] = measure q[3];
if (c[1] && !c[2]) {
  x q[0];
}
if (c[1] && c[2]) {
  x q[1];
}
if (!c[1] && c[2]) {
  x q[2];
}
cx q[0], q[1];
cx q[0], q[2];
c[0] = measure q[0];
Sign in to run (nothing is saved)
Open in the IDE Open in the Playground

The repetition code only fixes bit flips. Real codes such as the surface code protect against phase flips too, use hundreds of physical qubits per logical qubit, and work only if physical error rates are below a threshold near 1%. Today's best devices sit just below it, which is why the first logical qubits with lower error than their parts appeared only in 2023–2024.

Knowledge check

2 questions · one try each counts

Question 1

Why measure Z₀Z₁ instead of Z₀ and Z₁ separately?

Sign in to answer and climb the ranks; you will come back to this lesson.

Question 2

What does the threshold theorem say?

Sign in to answer and climb the ranks; you will come back to this lesson.

Key takeaway

Error correction spreads one logical qubit over many physical ones and reads only parities. Below the threshold, bigger codes mean fewer logical errors; that regime is where the field is arriving now.

Finished reading?

Knowledge check: 2 questions waiting above. Questions are optional. Mark it complete, or press Next: moving on marks it complete too.

Up next
QC 302 · Cutting and Quantum ML · 14 min
Circuit cutting
Cut a gate, run the halves, recombine: the sampling overhead and when it pays off.
Further reading
  • Docs: Steane and Shor code benchmarks
More in Noise and Errors
  • NISQ reality
  • Noise models and fake backends
  • Error mitigation
Error mitigationCircuit cutting
In this lesson0%
  1. Introduction
  2. Try it: Detect and correct a flip with feed-forward
  3. Knowledge check
  4. Key takeaway
QubitLab
IDELearnPlaygroundDocsCommunity
Log in
QubitLab
IDELearnPlaygroundDocsCommunity
Log in