← Lecture notes · QEC + Deltakit primer

QEC + Deltakit field map

Every concept of the primer on one page, with the Deltakit call that implements it. Click a card for its chapter.

Read the map by territory: Foundations (what a code is), Simulation (how noisy circuits become detector error models), Decoding (turning syndromes into corrections), Performance (what the numbers mean) and Toolchain (how Deltakit’s packages fit together). Each card’s chapter has an In Deltakit section with the exact import and a snippet that runs. Filter by territory, or search for a call name such as StimDecoderManager.

M1 Stabilizer foundations

A code is an abelian Pauli group; an error shows up as the set of generators it anticommutes with.

The Pauli group and commutation

qubit0123410101011010011111001clash101002 clashes: evencommute1001010100

Pauli strings either commute or anticommute. In bits, and anticommute exactly when is odd, which counts the sites where both are non-identity and different. Overlap alone decides nothing.

details ›

Stabilizer groups and the code space

dimension of the code space3216842each independentgenerator halves itredundant: the product of the four

A stabilizer group is an abelian subgroup of that does not contain . With independent generators, its code space has dimension and projector . Count independent generators, not rows.

details ›

Syndromes and logical operators

weight 2weight 2weight 3

Syndrome bit is 1 when error anticommutes with generator . Zero-syndrome Paulis are stabilizers (harmless) or logicals, . Errors with one syndrome form cosets: decode the coset.

details ›

Code distance and ⟦n, k, d⟧

1234nonzero syndrome: all detected12341234123tie: detected, not corrected

The distance is the smallest weight of a logical operator. An code detects any errors and corrects any . CSS codes have two distances, , and Deltakit’s planar codes set them apart.

details ›

CSS codes and the binary picture

110011repetition code6 rows6 rows

A CSS code takes checks and checks from classical codes with . Then , with ranks over , not row counts. Hypergraph-product and bivariate bicycle codes are CSS.

details ›

Clifford tableaux and Gottesman–Knill

destabilizersstabilizersreads as100000100000101000100010001000100010001000100010001100100110

A Clifford maps Paulis to Paulis, so the images of and fix it: a tableau of signed rows. Gates update it in , measurements in : Gottesman–Knill. Stim’s sampler goes further and tracks Pauli frames only.

details ›

Sources: Lectures 1–2; Gottesman 1997

M2 Codes

From the repetition code to bivariate bicycle codes: geometry sets the checks, and the checks set the decoder.

The repetition code

Copy a bit onto qubits and measure neighbour parities . Majority vote fixes up to bit flips, and failures shrink with whenever . Phase flips pass unseen: as a quantum code its distance is 1.

details ›

The toric code

dashed lines = the opposite sidesclosed around the torus: no defects,

Qubits on the edges of an torus. Stars ( at a vertex) and plaquettes ( around a face) are the checks. Errors are strings whose ends light up; loops around the torus are logicals, so .

details ›

The rotated surface code and its boundaries

in a checkerboard8 weight-2 checks on the edges:

A grid of data qubits with weight-4 checks and weight-2 edge checks: on qubits. The edge types decide where logical strings may end, so width and height are two separate distances.

details ›

Syndrome extraction schedules and hook errors

A weight-4 check takes four CNOTs, and their order matters. An ancilla fault halfway through leaves a weight-2 hook error. If it lies along the logical, the circuit distance drops to about . Deltakit’s built-in orders all avoid this.

details ›

Hypergraph product codes

repetition code, used twiceeach acts on its grid neighbours⟦13, 1, 3⟧: the planar codeHamming × Hamming:⟦58, 16, 3⟧, not distance 9

Two classical codes in, one CSS code out, with commuting checks by construction. can grow in proportion to , but the distance is the smallest input distance, so . The toric code is one.

details ›

Bivariate bicycle codes and the gross code

0123456789101101234512 × 6 torus; each site holds an L and an R qubitoppositeedgeswrap

Two commuting sums of shifts on an torus give and . Weight-6 checks with a few long-range links make ⟦144, 12, 12⟧, the gross code: 12 logical qubits on 288 physical qubits.

details ›

Sources: Lectures 3, 7; Dennis et al. 2002; Bravyi et al. 2024

M3 Noise and simulation

A noisy Clifford circuit with detectors compiles to a detector error model: the only input a decoder needs.

Circuit noise models: SD6, SI1000, phenomenological

one round, left to rightreset1q gate2q gatereadoutidleidle at M, RSD6SI1000Toyphen.gates are perfect

A noise model places the faults of a syndrome round, relative to one number . SD6 puts on every operation; SI1000 makes readout , reset and one-qubit gates ; phenomenological noise keeps only data and readout flips.

details ›

The deltakit-stim fork

deltakitCircuitCircuitDetectorErrorModelTypeError+ its own circuit

Deltakit ships its own Stim build, imported as deltakit_stim. It adds leakage gates and is the only Stim installed, so tools that check for upstream stim classes, such as PyMatching’s constructors, reject its objects.

details ›

Detectors and observables

measurement record, oldest to newestMR 2MR 2M 0M 1recordrec[-1]rec[-2]rec[-1]rec[-3]rec[-2]rec[-1]rec[-2]

A detector is a parity of measurement outcomes that is fixed when nothing goes wrong; it fires when a fault flips it. rec[-k] counts back from the newest measurement. An observable is the parity that carries the logical value.

details ›

Detector error models

mechanisms in the circuitD0 D1 : 0.01D0 D2 : 0.005D2 L0 : 0.0296detector error modelall the decoder sees

A detector error model (DEM) lists every independent error mechanism by its symptoms: the detectors and observables it flips, plus its probability. Mechanisms with identical symptoms merge. The decoder sees only this table.

details ›

From DEM to decoding graph

Matching needs every DEM row to flip at most two detectors. Each graphlike piece becomes an edge, a one-detector piece an edge to a boundary node, weighted . Pieces with the same endpoints merge into one edge.

details ›

Sampling with Stim

D00D10D20D30D40D50D60D71D81D90000000byte 0byte 1padding12481632641281248163264128unpackbits(..., bitorder="little") gives D7, D8 backnumpy's default (big) reads D0 (and a padding bit)

Stim runs the noiseless circuit once, then tracks each shot as a Pauli frame, many shots per machine word. compile_detector_sampler(seed=…) returns booleans, shots × detectors; bit_packed=True packs eight per byte, little-endian.

details ›

Leakage

qubit subspaceRELAX, R, RLwhile leakedM does not return itM: random bitCX partner: randomherald reads 1DEM: no rowdropped

Leakage takes a qubit out of . It is not a Pauli fault, so a DEM ignores it: with SI1000Noise(pL=0.01) the DEM keeps 21 rows while the detection rate quadruples. Leakage removal and heralds are the remedies.

details ›

Sources: Lectures 2, 4; Gidney 2021

M4 Decoding

A decoder guesses the logical class from detection events; speed, accuracy and the code family decide which one to use.

Maximum likelihood vs minimum weight

readML: 2 against 1, class 0

An optimal decoder returns the most likely class of errors, not the most likely error. Minimum weight agrees with it only when one lightest error dominates; ties, and how many equally light errors a class holds, are invisible to it.

details ›

Matching and PyMatching

PyMatching finds a minimum-weight perfect matching on the decoding graph, with weights . Deltakit wraps it as PyMatchingDecoder, which rewrites your circuit: sample from the circuit it returns. Errors must be graphlike.

details ›

Union–Find decoding

unit growth: every edge is 2 half-steps6.914.604.606.91round 1: each odd cluster grows half an edge each way149914

Union–Find grows clusters around defects until each holds an even number of them or touches the boundary, then peels each cluster’s spanning tree into a correction. Almost-linear time, a little less accurate than matching.

details ›

Belief propagation and BP-OSD

-10-50510151102030BP iterationprior 4.6iterate 30 → OSD-0weight 11: logicalfailureiterate 29:weight 3, correctmean of 30: 1.94→ weight 3, correct

Belief propagation passes likelihood messages between errors and checks; it is exact on trees. On a degenerate code it splits its belief between equivalent corrections and stalls. OSD then solves for the likeliest columns by elimination.

details ›

Correlated matching and BeliefMatching

detectorsdetectorsone mechanism,four detectors3.373.370

Matching splits a error, or any fault that trips detectors of both types, into independent edges and overcharges it. Correlated matching and belief-matching restore the link by reweighting edges before matching.

details ›

Tensor-network maximum-likelihood decoding

012345678spins on checks, factors on qubits81, 26, 7054334

ML decoding needs class probabilities: sums over every error in a class. For a planar code with independent flips, each sum is a 2D Ising partition function. A sweep contracts it exactly in time ; a boundary MPS approximates it.

details ›

Windowed and real-time decoding

05001000one global matching: 7450138919312820376857498747

Syndrome rounds keep arriving. A decoder slower than the hardware builds a backlog that grows exponentially across gates. Windows decode a few rounds at a time: commit the oldest, keep about buffer rounds for chains that continue.

details ›

Sources: Lectures 5, 7; Higgott & Gidney 2023

M5 Performance analysis

Count failures, put error bars on them, convert to error per round, then fit Λ to see whether bigger codes help.

Logical error probability and its uncertainty

051015ValueError

Estimate by . The plug-in bar breaks at small : it crosses zero, and at it vanishes. Use likelihood intervals instead. Zero failures give only a bound, .

details ›

Logical error per round

0.91.01.12010532

A run of rounds fails with , where . Fit against : the slope gives and the intercept gives the SPAM term . One run with adds to .

details ›

Thresholds

The threshold is where the curves for different cross: below it, larger codes fail less. It depends on the noise model, the decoder and per-shot or per-round counting. Being below it is necessary, not sufficient.

details ›

The error-suppression factor Λ

357911

is the factor by which the logical error per round falls when : . means below threshold. Fit it on per-round errors, never on total LEP.

details ›

Error budgets

0.00.10.2gate 0.1810.247direct 0.210readout 0.066budget predicts0.1200.132 ± 0.0070.1770.191 ± 0.0050.1440.195 ± 0.0070.0290.087 ± 0.012

An error budget splits among noise sources: at , so . It ranks which error to reduce a little, not what removing a source buys.

details ›

QuOps and resource prediction

91521273339252333same fit, lambda0 not inverted

A QuOp is one -round block of a distance- patch, and QuOps of that block. Deltakit’s helpers turn into QuOps or into a distance; a patch costs qubits. Pass them 1/ld.lambda0.

details ›

Sources: Lecture 6; Google Quantum AI 2024

M6 The Deltakit toolchain

Several packages, one pipeline: code → circuit → noise → sample → decode → analyse; deltakit-compile builds logical programs.

The Deltakit package map

deltakit_stim: Stim fork (+ leakage)deltakit.circuitdeltakit.coredeltakit.decode+ PyMatchingdeltakit.explorerdeltakit_compile+ xDSLdeltakit_visualisedeltakit.* names: aliasesRiverlane cloud6 decoder classesclient=uv pip install deltakit pulls in all seven

One install, seven packages. Four have deltakit.* names (circuit, core, decode, explorer); the Stim fork, compiler and visualiser import as deltakit_stim, deltakit_compile, deltakit_visualise. Only six cloud decoders leave your machine.

details ›

The memory-experiment pipeline

RotatedPlanarCode(3, 3)css_code_memory_circuitRotatedPlanarCodePYTHONHASHSEED=0fixes target orderqpu.compile_and_add_noise_to_circuitCircuit (deltakit_circuit)construct_decoder_and_stim_circuitCircuit + noise, 24 detectors24 → 16 detectorscompile_detector_sampler(seed).samplestim Circuit (16 det.) + decoderseed=2026fixes the random bitsdecode_batch_to_logical_flipdets 100000×16, obs 100000×1344 fails → LEP 3.44e-3pred: uint8, 100000×1loop over d = 3, 5, 7 → Λ

Code → circuit → noisy circuit → (decoder, trimmed circuit) → seeded samples → predicted flips → failures. Each arrow passes one object; sample from the decoder’s circuit, seed the sampler and fix PYTHONHASHSEED, or counts drift.

details ›

deltakit-compile and logical assembly

Write a program on logical patches with LogAsmBuilder, compile it with LogicalAssembler and StimExportPipelineConfig, get Stim text. The compiler finds every detector itself. Version 0.1.0 compiles memory-style programs only.

details ›

Lattice surgery

patch 1patch 2merged patchZZZZ× d roundsXXX

Merge two patches along a seam, measure the merged patch for about rounds, split. The product of the new seam checks is . Two-qubit logical measurements with only nearest-neighbour gates, paid for in rounds.

details ›

xDSL dialects in deltakit-compile

built programLogAsmBuilder.build_program()log_asm 6 · qstruct 11. logical assembly7 passes: inline calls, csepatch ops are already log_asm2. patch lowering12 passes; peak plaquette 195qref 122 · qstruct 149 · qec 23. stabiliser flows13 passes; peak stab 40qec 27 · qref 32 · qstruct 394. Stim export9 passes (+ 4 canonicalize = 45)stim 111 → Stim text

deltakit-compile is an xDSL compiler. A program is one IR module mixing dialects (log_asm, plaquette, qref, stab, qec, stim, …); 45 passes lower it stage by stage until only stim operations remain.

details ›

Contributing to Deltakit and the community fund

One guide governs every Deltakit repo: file in the right tracker, ask before starting, use Conventional Commits, sign the CLA, disclose substantial AI use. The community fund pays up to 4k USD; the next round closes 2 Dec 2026.

details ›

Sources: Lectures 0, 8, 9; Deltakit docs