A small, notebook-first set of tutorials for surface-code quantum error correction (QEC) using Loom (Entropica Labs’ Python library for building and running QEC experiments), with simulations executed in Stim and decoding via PyMatching.
These materials are designed to be run directly on qBraid (recommended) and are intended as part of the teaching content hosted there.
Across two core notebooks, you will:
- Define and inspect the rotated surface code (stabilizers, logical operators, boundaries).
- Prepare logical basis states via syndrome measurement and understand Pauli frame tracking.
- Run a logical memory experiment under circuit-level noise, build a detector error model, and decode with minimum-weight perfect matching.
- Reproduce (numerically) the surface-code threshold behavior in a memory setting.
- Understand the core ideas behind lattice surgery and how it enables multi-patch logical operations.
- Build intuition for a logical CNOT using lattice surgery, and verify Loom’s
AuxCNOTimplementation end-to-end.
The core of the repo are the two notebooks below:
-
1_memory_exp.ipynb— Memory Experiment with the Rotated Surface Code- Introduces stabilizer formalism (light recap) and operator measurements
- Defines the rotated surface code and its stabilizers/logicals
- Shows logical state initialization (Z/X eigenstates) via syndrome measurement
- Runs noisy memory experiments in Stim and decodes using PyMatching
- Demonstrates threshold-style scaling by sweeping physical error rates and code distances
-
2_auxcnot_op.ipynb— AuxCNOT operation on the Rotated Surface Code- Introduces lattice surgery (merge/split) as a tool for logical operations
- Develops the logical-CNOT construction step-by-step
- Uses Loom’s
AuxCNOTand verifies the resulting logical action by Stim sampling
Supporting files:
pyproject.toml/uv.lock— minimal Python dependencies and reproducible environment lock_static_1/,_static_2/— images/diagrams used by the notebooks