Skip to documentation
← Algorithm guides

Algorithm guide · qec

QEC: Bacon-Shor 3x3 Repeated Cycles

Run bounded, repeated syndrome extraction with a recycled ancilla and compare physical correction with Pauli-frame recovery.

Circuit size: 9 data + 1 recycled syndrome ancilla

Before you begin

Stabilizer signs · Gauge subsystems · Repeated measurements and Pauli frames

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

Explore repeated error-detection cycles on a 3×3 Bacon–Shor subsystem code. Compare physically applied recovery with tracking the same Pauli correction in a classical frame, while accounting for data and readout errors.

2. How it works

Measure small two-qubit gauge operators rather than each larger stabilizer directly. Products of compatible gauge outcomes give stabilizer signs. Individual gauge signs can vary without changing the logical information, so random gauge bits are not automatically failures.

  1. Prepare logical state

    Encode the selected state into nine data wires.

  2. Extract one cycle

    Reuse a tenth wire to measure six vertical XX gauges and six horizontal ZZ gauges.

  3. Decode products

    Combine gauge signs into the four stabilizer signs and choose a bounded recovery.

  4. Repeat and verify

    Apply physical correction or update the Pauli frame after each round; interpret final logical verification in the chosen basis.

3. The mathematics, one idea at a time

Xbar=X0X1X2; Zbar=Z0Z3Z6

These are this implementation’s chosen logical operators: top row and left column.

SZ0=(Z0Z1)(Z3Z4)(Z6Z7); SZ1=(Z1Z2)(Z4Z5)(Z7Z8)

Products of three horizontal gauge checks form the Z stabilizers. Analogous products of vertical XX gauges form the X stabilizers.

Frame recovery: keep a classical Pauli F and interpret later observables using F

Physical recovery applies correction gates; a Pauli frame tracks their logical effect without necessarily changing raw state bits immediately.

Work this through by hand

4. One clean cycle with one injected X

Nine data plus one recycled ancilla: ten physical qubits. One round is the smallest cycle count.

Choose logical |0⟩, one round, physical recovery, data/readout error rates zero, and an injected X on q0.

StageCalculation or stateWhat it means
Error commutationX0 anticommutes with SZ0, but not SZ1Only the first Z stabilizer changes sign.
Gauge productsSX0=+1, SX1=+1, SZ0=−1, SZ1=+1Individual XX gauge outcomes can still vary.
RecoverThe decoder selects an equivalent single-X recoveryCorrections that differ by gauge operations can have the same logical effect.
VerifyLogical |0⟩ is recovered in the ideal single-fault settingIncreasing noise or changing decoder assumptions can produce failures.

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
Correct logical verification100% ideal under this noiseless single injected errorA logical pass; not one fixed 12-bit gauge record.

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
Syndrome rounds
1
Shots
256
Recovery strategy
physical
Data Pauli error rate
0
Readout flip rate
0
Introduce a single-qubit error
On
Error type
X
Data qubit receiving the error
0
  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

Use the QEC cycle results: inspect round histories, gauge-derived stabilizers, recovery decisions and logical verification separately.

The Composer shows Syndrome Cycle × N as a collapsed macro; the execution worker performs the repeated bounded trajectory experiment. Do not interpret one visible template as only one executed round when N>1.

In Pauli-frame mode, read frame-adjusted verification rather than treating uncorrected raw bits as the logical answer. Noisy readout can change decoder decisions; repeated rounds alone do not establish fault tolerance.

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

  • A random gauge bit is not the same as a logical error.
  • This bounded educational decoder is not a proof of a fault-tolerant memory threshold under arbitrary noise.

8. Check your understanding

Why can two recovery operators that differ by a gauge operator be acceptable?

Reveal the reasoning

Gauge operators act on the gauge subsystem while preserving encoded logical information; equivalent logical recovery need not reproduce the same gauge state.

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.

Select 1–100 syndrome rounds, 1–100000 trajectory shots, a data Pauli rate and readout flip rate from 0 to 0.3, and Pauli-frame or physical recovery.

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 Composer stores one explicit gauge-extraction template and renders Syndrome Cycle × N as a collapsed macro. A dedicated worker executes bounded Pauli trajectories without expanding the DOM or blocking React.

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.