Lecture 3 ended with noiseless circuits. A decoder needs two more things. It needs to know what can go wrong, and how often. And it needs to know which detectors each fault lights up. This lecture follows the chain that supplies both: a noise model turns a circuit into a noisy circuit, detectors turn each fault into a symptom, Stim lists every fault with its symptom in a detector error model, and the decoder works on a decoding graph built from that list.
Each link in the chain is a modelling choice, and the decoder inherits every one of them. The weights a matching decoder uses come from the noise model’s probabilities. If the model misjudges how often measurements fail, the decoder makes worse choices. The lecture ends with leakage, a kind of error that the model cannot express at all. You will see what it does to a decoder that does not know about it.
Notebook and field map
Notebook 4: Noise and detector error models compares the noise models at equal
, plots detection events round by round, measures how the DEM grows with distance, checks a decoding graph against sampled data, switches leakage on and off, and runs true phenomenological noise. Field map: Circuit noise models, Leakage, Detectors and observables, Detector error models, From DEM to decoding graph.
Three levels of noise
Studies of QEC use three levels of noise, each more realistic and more pessimistic than the last.
- Code capacity. Only the data qubits suffer errors, once, and the syndrome is read perfectly. This tests the code alone. It is what the playground of Lecture 3 simulates.
- Phenomenological. Before each round of checks the data qubits suffer errors, and each check outcome is flipped with some probability. Measurements can now lie, so the decoder must reason over space and time. It still knows nothing about the circuit.
- Circuit-level. Every operation of the actual extraction circuit can fail. This is the only level that sees hook errors (Lecture 3) and the correlated symptoms that gate faults create, such as the diagonal edges of the decoding graph below.
Definition 4.1 (Circuit-level noise model).A circuit-level noise model is a rule that inserts a noise channel after (or before) each operation of a circuit, depending on the operation’s kind, its qubits and how long they sit idle. The channels are Pauli channels such as depolarizing noise, plus classical flips of measurement outcomes, so the noisy circuit can still be simulated by Stim.
Each level lowers the threshold of the surface code. With minimum-weight matching it is about
10.3% at code capacity (independent
Circuit noise models in Deltakit
A QPU holds a noise model. qpu.compile_and_add_noise_to_circuit(circ) first compiles the
circuit into the QPU’s native gates (by default H, CX, R and M) and then inserts noise.
Deltakit ships three one-parameter circuit models. SD6Noise puts the same SI1000Noise, “superconducting-inspired”, weights the locations by how they fail in
superconducting devices: measurements are bad, single-qubit gates are good. Both come from
Gidney et al. (2021). ToyNoise is a gentler model for quick studies. Rather than trust the
docstrings, read the rates off the compiled circuits. The
from collections import Counter
import numpy as np
from deltakit.circuit.gates import PauliBasis
from deltakit.explorer.codes import RotatedPlanarCode, css_code_memory_circuit
from deltakit.explorer.qpu import QPU, SD6Noise, SI1000Noise, ToyNoise
SEED = 2026
code = RotatedPlanarCode(3, 3)
circ = css_code_memory_circuit(
code, num_rounds=3, logical_basis=PauliBasis.Z
)
NOISY = ("DEPOLARIZE1", "DEPOLARIZE2", "X_ERROR", "M", "MX")
def noise_table(noisy):
"""(instruction, probability) -> number of qubits or pairs hit."""
table = Counter()
for inst in noisy.as_stim_circuit().flattened():
args = inst.gate_args_copy()
if inst.name in NOISY and args:
per = 2 if inst.name == "DEPOLARIZE2" else 1
table[inst.name, args[0]] += len(inst.targets_copy()) // per
return dict(sorted(table.items()))
models = {
"SD6": SD6Noise(p=1e-3),
"SI1000": SI1000Noise(p=1e-3),
"Toy": ToyNoise(p=1e-3),
}
for name, model in models.items():
qpu = QPU(code.qubits, noise_model=model)
noisy = qpu.compile_and_add_noise_to_circuit(circ)
print(name)
for (gate, p), n in noise_table(noisy).items():
print(f" {gate:12s} p={p:<7g} x{n}")SD6
DEPOLARIZE1 p=0.001 x215
DEPOLARIZE2 p=0.001 x72
M p=0.001 x33
X_ERROR p=0.001 x33
SI1000
DEPOLARIZE1 p=0.0001 x215
DEPOLARIZE1 p=0.002 x36
DEPOLARIZE2 p=0.001 x72
M p=0.005 x33
X_ERROR p=0.002 x33
Toy
DEPOLARIZE1 p=0.0001 x281
DEPOLARIZE2 p=0.001 x72
M p=0.001 x33Read with the source, the three models put errors here:
| location | SD6Noise(p) | SI1000Noise(p) | ToyNoise(p) |
|---|---|---|---|
| after a two-qubit gate | DEPOLARIZE2(p) | DEPOLARIZE2(p) | DEPOLARIZE2(p) |
| after a one-qubit gate, or idle | DEPOLARIZE1(p) | DEPOLARIZE1(p/10) | DEPOLARIZE1(p/10) |
| idle while others are measured or reset | DEPOLARIZE1(p) | DEPOLARIZE1(2p), on top of the idle DEPOLARIZE1(p/10) | DEPOLARIZE1(p/10) |
| after a reset | X_ERROR(p) | X_ERROR(2p) | DEPOLARIZE1(p/10), also after a measurement |
| measurement result flipped | p_measurement_flip) |
The 215 single-qubit channels at ToyNoise, with no reset flips and cheap
single-qubit noise, gives 96.
PhenomenologicalNoise is the odd one out. It takes a function from a qubit to a noise channel
and applies it at every explicit idle (I) gate. The memory circuit has exactly one such layer
per round, on the data qubits (Lecture 3). Add a measurement flip and you have the
phenomenological model, with one catch. The compiler removes I gates, even when I is a
native gate and even with remove_paulis=False. So compile_and_add_noise_to_circuit silently
drops the data noise and keeps only the measurement flips. The workaround is to skip
compilation. A QPU with ExhaustiveGateSet() accepts the circuit’s own gates, and
add_noise_to_circuit adds noise without compiling:
from deltakit.circuit import measurement_noise_profile
from deltakit.circuit.noise_channels import Depolarise1
from deltakit.explorer.qpu import ExhaustiveGateSet, PhenomenologicalNoise
phen = PhenomenologicalNoise(
phenomenological_noise=lambda q: Depolarise1(q, 1e-3),
measurement_flip=measurement_noise_profile(1e-3),
)
compiled = QPU(code.qubits, noise_model=phen)
compiled = compiled.compile_and_add_noise_to_circuit(circ)
direct = QPU(code.qubits, ExhaustiveGateSet(), noise_model=phen)
direct = direct.add_noise_to_circuit(circ)
print("compiled:", noise_table(compiled))
print("direct: ", noise_table(direct))compiled: {('M', 0.001): 33}
direct: {('DEPOLARIZE1', 0.001): 27, ('M', 0.001): 9, ('MX', 0.001): 24}The compiled circuit has no DEPOLARIZE1 at all. The direct one has 27, one per data qubit per
round. Its symptoms are what the textbook phenomenological model promises.
Detectors turn faults into symptoms
A detector (Lecture 0) is a parity of measurements that is fixed without noise. Deltakit gives
each detector the coordinates
Definition 4.2 (Symptom).The symptom of a fault is the set of detectors it flips together with the set of logical observables it flips. Two faults with the same symptom look the same to every decoder.
In a surface-code memory, the symptoms (Definition 4.2) come in a few shapes. A data error between
two rounds flips the two neighbouring checks of the matching type, in the same round. On the
boundary there may be only one such check. A measurement error flips one outcome, so the
detectors of that check in two consecutive rounds fire. A fault partway through a round, on a
two-qubit gate, is caught by some checks in this round and others in the next. A
The rate at which detectors fire is the first thing to look at in any experiment, simulated or
real. Here it is round by round for a five-round,
code5 = RotatedPlanarCode(5, 5)
circ5 = css_code_memory_circuit(
code5, num_rounds=5, logical_basis=PauliBasis.Z
)
qpu5 = QPU(code5.qubits, noise_model=SI1000Noise(p=1e-3))
sc5 = qpu5.compile_and_add_noise_to_circuit(circ5).as_stim_circuit()
dets = sc5.compile_detector_sampler(seed=SEED).sample(100_000)
coords = sc5.get_detector_coordinates()
t = np.array([coords[i][2] for i in range(sc5.num_detectors)])
for r in np.unique(t):
print(f"t={r:.0f}: {np.sum(t == r):2d} detectors,"
f" fire rate {dets[:, t == r].mean():.4f}")t=0: 12 detectors, fire rate 0.0180
t=1: 24 detectors, fire rate 0.0316
t=2: 24 detectors, fire rate 0.0320
t=3: 24 detectors, fire rate 0.0319
t=4: 24 detectors, fire rate 0.0322
t=5: 12 detectors, fire rate 0.0280The first and last rows have half as many detectors: only the
Detector error models and the decoding graph
Stim condenses a noisy circuit into a detector error model (DEM): one row per independent error
mechanism, with its probability and its symptom. Faults with the same symptom merge into one row.
For two independent mechanisms, the merged probability is decompose_errors=True asks Stim to split each larger symptom into graphlike
pieces, and the DEM grows to 290 rows.
Definition 4.3 (Decoding graph).The decoding graph of a DEM whose rows flip at most two detectors has one node per detector plus a boundary node. Each row becomes an edge between the detectors it flips, or between its one detector and the boundary. Rows with the same endpoints merge into one edge. An edge with probability
gets the weight , and it records which observables it flips.
With the weights of the decoding graph (Definition 4.3), the probability of a set of
independent edges is proportional to deltakit.core.decoding_graphs builds the graph from a DEM:
import math
from deltakit.core.decoding_graphs import dem_to_decoding_graph_and_logicals
qpu = QPU(code.qubits, noise_model=SI1000Noise(p=1e-3))
sc = qpu.compile_and_add_noise_to_circuit(circ).as_stim_circuit()
raw = sc.detector_error_model()
dem = sc.detector_error_model(decompose_errors=True)
print("DEM rows: raw", raw.num_errors, " decomposed", dem.num_errors)
graph, logicals = dem_to_decoding_graph_and_logicals(dem)
print("nodes", len(graph.nodes), " edges", len(graph.edges),
" boundary", sorted(graph.boundaries))
recs = graph.detector_records
kinds = {"space": [], "time": [], "diagonal": [], "boundary": []}
for edge in graph.edges:
u, v = tuple(edge)
if graph.boundaries & {u, v}:
kind = "boundary"
elif recs[u].time == recs[v].time:
kind = "space"
elif recs[u].spatial_coord == recs[v].spatial_coord:
kind = "time"
else:
kind = "diagonal"
kinds[kind].append(graph.edge_records[edge].p_err)
for kind, ps in kinds.items():
w = [math.log((1 - p) / p) for p in ps]
print(f"{kind:8s} {len(ps):2d} edges p {min(ps):.1e}..{max(ps):.1e}"
f" weight {min(w):.2f}..{max(w):.2f}")
print("edges that flip the observable:", len(logicals[0]))DEM rows: raw 221 decomposed 290
nodes 25 edges 78 boundary [24]
space 18 edges p 2.3e-03..6.1e-03 weight 5.09..6.06
time 16 edges p 7.5e-03..7.6e-03 weight 4.87..4.88
diagonal 20 edges p 2.7e-04..1.1e-03 weight 6.84..8.23
boundary 24 edges p 2.7e-03..2.0e-02 weight 3.90..5.93
edges that flip the observable: 8Every class of the figure is there. Among the bulk edges the time-like ones are the most
likely, because a measurement flips with probability
dem_to_decoding_graph_and_logicals(raw)It raises ValueError: Edge of degree 3 cannot be converted to decoding edge.. Decoders that use
hyperedges directly, such as belief propagation, appear in Lectures 5 and 7. The graph also grows
fast with distance:
print(" d detectors DEM rows graph edges")
for d in (3, 5, 7):
c = css_code_memory_circuit(
RotatedPlanarCode(d, d), num_rounds=d, logical_basis=PauliBasis.Z
)
q = QPU(c.qubits, noise_model=SI1000Noise(p=1e-3))
s = q.compile_and_add_noise_to_circuit(c).as_stim_circuit()
m = s.detector_error_model(decompose_errors=True)
g, _ = dem_to_decoding_graph_and_logicals(m)
print(f"{d:2d} {s.num_detectors:10d} {m.num_errors:9d}"
f" {len(g.edges):12d}") d detectors DEM rows graph edges
3 24 290 78
5 120 2233 502
7 336 6920 1558All three columns grow like
Leakage: an error the model cannot see
Physical qubits are not two-level systems. A transmon has a third level,
Definition 4.4 (Leakage).A qubit has leaked when its state has left the computational subspace spanned by
and . A leaked qubit no longer responds to gates as a qubit. It corrupts the qubits it interacts with, and it reads out as a random bit, until it relaxes back or is reset.
Leakage (Definition 4.4) is not a Pauli error, so an ordinary Stim circuit cannot describe it.
The deltakit_stim fork adds instructions for it, and SI1000Noise(p=…, pL=…) uses them. With
LEAKAGE(pL) after every two-qubit gate and every reset. It also adds RELAX
channels, which bring a leaked qubit back, at rates
qpu_l = QPU(code.qubits, noise_model=SI1000Noise(p=1e-3, pL=1e-4))
leaky = qpu_l.compile_and_add_noise_to_circuit(circ).as_stim_circuit()
names = {i.name for i in leaky.flattened()}
print("new instructions:", sorted(names - {i.name for i in sc.flattened()}))
print("DEM rows:", leaky.detector_error_model(decompose_errors=True).num_errors)
for pL in (0.0, 1e-3):
q = QPU(code5.qubits, noise_model=SI1000Noise(p=1e-3, pL=pL))
c10 = css_code_memory_circuit(
code5, num_rounds=10, logical_basis=PauliBasis.Z
)
s = q.compile_and_add_noise_to_circuit(c10).as_stim_circuit()
dets = s.compile_detector_sampler(seed=SEED).sample(50_000)
co = s.get_detector_coordinates()
t = np.array([co[i][2] for i in range(s.num_detectors)])
rates = [dets[:, t == r].mean() for r in np.unique(t)]
print(f"pL={pL:g}:", " ".join(f"{x:.3f}" for x in rates))new instructions: ['LEAKAGE', 'RELAX']
DEM rows: 290
pL=0: 0.018 0.032 0.032 0.032 0.032 0.032 0.032 0.032 0.032 0.032 0.028
pL=0.001: 0.027 0.053 0.060 0.067 0.073 0.079 0.085 0.091 0.097 0.103 0.090The DEM has the same 290 rows with leakage on as without it. The decoder built from it does not
know that leakage exists. Yet the detectors know. Without leakage the bulk fire rate is flat.
With SI1000Noise (PUBLISHED; Nat. Commun. 16, 11048 (2025),
arXiv 2411.10343).
In Deltakit
| step | call | returns |
|---|---|---|
| choose a model | SD6Noise(p=…), SI1000Noise(p=…, pL=…), ToyNoise(p=…, p_measurement_flip=…), PhenomenologicalNoise(phenomenological_noise=…, measurement_flip=…) | a NoiseParameters dataclass (keyword-only) |
| compile and add noise | QPU(qubits, noise_model=…).compile_and_add_noise_to_circuit(circ) | a noisy deltakit.circuit.Circuit |
| add noise only | QPU(qubits, ExhaustiveGateSet(), noise_model=…).add_noise_to_circuit(circ) | the same, with the circuit’s own gates and I layers kept |
| detector coordinates | stim_circ.get_detector_coordinates() | {index: [x, y, t]} |
| DEM | stim_circ.detector_error_model(decompose_errors=True) | a deltakit_stim.DetectorErrorModel |
| decoding graph | dem_to_decoding_graph_and_logicals(dem) | (NXDecodingGraph, [set of edges per observable]) |
| edge data | graph.edge_records[edge].p_err, .weight; graph.detector_records[i].time, .spatial_coord | floats and tuples; the boundary node has coordinates |
Three traps:
PhenomenologicalNoisethroughcompile_and_add_noise_to_circuitkeeps only the measurement flips (above). Useadd_noise_to_circuitwithExhaustiveGateSet().- Constructing a
QPUwithPhenomenologicalNoiseaddsIto the default native gate set that every laterQPU()shares (a mutable default argument). In our tests later SD6, SI1000 and Toy circuits came out identical anyway, but passNativeGateSetAndTimes()explicitly if you mix models in one process. DecodingEdgeobjects cannot be sorted. Sorttuple(edge)instead.
Try this
- Replace
SI1000NoisebySD6Noisein the decoding-graph block. Which edge class changes its weight the most, and why? - Raise
p_measurement_flipinToyNoisefromto and watch the time-like weights fall. Predict their new value from the merge rule first. - In the leakage block, raise
pLto. How many rounds until the bulk fire rate doubles? - Run the phenomenological circuit (the
directone) atfor with StimDecoderManager. Isabove or below the phenomenological threshold?
Readings
- C. Gidney, M. Newman, A. Fowler and M. Broughton, A fault-tolerant honeycomb memory, Quantum 5, 605 (2021). Defines the SD6 and SI1000 models (their Tables 1 and 2).
- C. Wang, J. Harrington and J. Preskill, Confinement-Higgs transition in a disordered gauge theory and the accuracy threshold for quantum memory, Annals of Physics 303, 31 (2003). Code-capacity and phenomenological thresholds.
- C. Gidney, Stim: a fast stabilizer circuit simulator, Quantum 5, 497 (2021), and the DEM file format.
- M. McEwen et al., Removing leakage-induced correlated errors in superconducting quantum error correction, Nat. Commun. 12, 1761 (2021). Leakage in a real device, and leakage-reduction units.
- A. B. Ziad et al., Local Clustering Decoder as a fast and adaptive hardware decoder for the
surface code, Nat. Commun. 16, 11048 (2025).
The leakage model behind
SI1000Noise(pL=…).