backlog Union-Find playground Code on GitHub

Flip some qubits. Watch the decoder find them.

A surface code stores one qubit in many. Tap a data qubit to give it a bit flip: the checks around it light up. Then decode, and watch Union-Find grow clusters around the lit checks until it can explain them.

What you are looking at

  • Z checks. Each one measures whether an odd number of its qubits flipped.
  • X checks, which watch for the other kind of error. Bit flips leave them alone.
  • A flipped qubit. A lit check, and what the decoder has grown.
  • The decoder's correction. The dashed sides are where a chain of flips can leave the code.

The algorithm

  1. Grow. Each round, every cluster holding an odd number of lit checks grows by half an edge in every direction.
  2. Merge. Clusters that meet become one. A cluster stops once it holds an even number of lit checks or reaches a side.
  3. Peel. The grown edges form a forest. Peeling it from the leaves picks a set of qubits that explains every lit check: the correction.

If the flips and the correction together reach from the left side to the right side, the stored qubit is flipped: a logical error.

Same decoder as backlog

This is backlog's reference decoder, ported line for line from C++ and checked against it edge for edge (tests/test_demo.py). The C++ decoder computes the same answer with events instead of rounds, and adds edge weights from the noise model, measurement errors over time, and correlated decoding.

pip install backlog-qec · how the C++ decoder works