A quantum computer must detect and correct errors without directly reading the information it is trying to protect. A surface code does this by arranging checks on a grid. The pattern of checks that signal a possible error is called a syndrome. Errors in the stored data, or in the checks themselves, can change this pattern. Given the syndrome over several rounds of checks, a decoder guesses which errors happened and how to correct them.
This program asks: How often does the decoder’s correction leave a logical error? It estimates that rate by simulating many independent trials (called shots). It is a simulation of the error-correction algorithm, not a program that runs on a quantum computer.
The code first builds a grid of possible errors and checks. It includes errors in the data and in measurements made during successive rounds of checks. In each shot:
p; a measurement error flips a check result. The code
records the resulting syndrome and whether the simulated errors change
the protected logical information.The reported logical_error_rate is the number of
mismatches divided by the number of shots. The program also reports time
spent sampling errors and decoding. --d sets the grid’s
code distance, --rounds the number of check rounds,
--p the error probability, --shots the number
of trials, and --seed the random seed. For example,
./qec_baseline --d 5 --shots 100000. To check the result,
./qec_baseline --selftest tries individual errors and
reports how many are decoded incorrectly. With --p 0, there
should be no logical errors.