Skip to main content

Module surface_code

Module surface_code 

Source
Expand description

Rotated surface code with a minimum-weight perfect-matching (MWPM) decoder.

This module implements a distance-d rotated surface code (Fowler et al., “Surface codes: Towards practical large-scale quantum computation”, Phys. Rev. A 86, 032324, 2012) together with a syndrome decoder, in the classical Pauli-frame picture used by virtually every surface-code threshold study.

§Scope and conventions

Rather than carrying a 2^{d²}-amplitude state vector through the stabilizer measurement schedule (which is unnecessary for tracking how Pauli errors map to logical errors), we track an error as an independent pair of X/Z bit masks over the d² data qubits — a PauliError. This is exact for Pauli noise: a stabilizer’s syndrome bit is just the parity of the overlap between the stabilizer support and the offending error component, and a residual error commutes with every stabilizer iff it lies in the stabilizer group (no logical error). All correctness statements below are made in this frame.

  • Layout. d² data qubits sit on a d × d grid (index r·d + c). The d²−1 stabilizers form the rotated checkerboard: (d−1)² weight-4 bulk plaquettes plus 2(d−1) weight-2 boundary plaquettes. Z-type plaquettes detect X errors; X-type plaquettes detect Z errors. There are exactly (d²−1)/2 of each.
  • Decoder. For each error species we build the matching graph whose nodes are the stabilizers of the detecting type plus one virtual boundary node, and whose edges are data qubits. Decoding is an exact minimum-weight perfect matching solved by subset (bitmask) dynamic programming over the defect set — not the full stabilizer set — so the cost is O(2^{k}·k) in the number of fired stabilizers k, which is tiny for the low-weight errors a distance-d code is meant to handle. (A Blossom-V matching would be the drop-in replacement for high-weight syndromes at large d; the DP here is the same minimum-weight matching, just enumerated exactly.)

For a distance-d code this corrects every error of weight ≤ ⌊(d−1)/2⌋: the residual error ∘ correction is a cycle of weight below d, hence a product of stabilizers, hence logically trivial.

Structs§

PauliError
A Pauli error over the data qubits: independent X (bit-flip) and Z (phase-flip) components. y = x · z on a qubit is represented by both bits being set.
Stabilizer
A single stabilizer generator: its species and the data qubits it acts on.
SurfaceCode
A distance-d rotated surface code with an MWPM decoder.
SurfaceCodeConfig
Configuration for a SurfaceCode.
Syndrome
The measured syndrome: one bit per stabilizer (true = defect / fired).

Enums§

StabKind
Stabilizer species of a rotated-surface-code plaquette.