|q⟩ Bad Qubits

advanced · Programming · Implementing Error-Correcting Codes

Measuring Code Performance

A code is only as good as its logical error rate — the probability that, after a full encode–error–correct cycle, the logical qubit comes out wrong. Designing a code is one thing; measuring whether it actually helps on a given noise level is another. The standard tool is Monte Carlo sampling: run the cycle many times and count logical failures.

Defining the logical error rate

Let pLp_L be the probability that one QEC cycle leaves the logical qubit in the wrong state. We estimate it empirically. Run NN independent shots, each consisting of: prepare a known logical state, subject it to noise, run syndrome extraction and correction, then measure the logical value. If ff shots come out wrong,

p^L=fN,\hat{p}_L = \frac{f}{N},

with a binomial standard error of p^L(1p^L)/N\sqrt{\hat{p}_L(1-\hat{p}_L)/N}. To resolve a logical rate of 10410^{-4} you need on the order of 10610^{6} shots — sampling cost grows as the code improves, which is itself a sign the code is working.

The pseudo-threshold

The point of QEC is that the encoded qubit should fail less often than a bare one. Compare:

The crossover where pL(p)=pp_L(p) = p is the pseudo-threshold. Below it, encoding wins; above it, the extra qubits and gates make things worse. Plotting pLp_L versus pp and finding the crossover is the canonical benchmark of a code (Fowler et al., arXiv:1208.0928, for the surface code).

A single clean trial

To see the mechanism without statistics, the exercise runs one cycle with exactly one (correctable) error and reads out the result. Because a single bit flip is always inside the correctable set, this trial never produces a logical error — the data qubit comes out as logical 0 with certainty. In a real benchmark you would instead inject errors randomly with probability pp per qubit and tally the fraction of trials where the data qubit flips, building up p^L\hat p_L shot by shot.

Reading the histogram

After the cycle, measuring all three qubits gives a deterministic outcome: qubit 0 (the recovered logical bit) reads 0, while qubits 1 and 2 carry the syndrome of the error that was fixed. A logical failure would instead show qubit 0 reading 1. Counting how often that happens, over many randomized trials, is precisely how the logical error rate is estimated on hardware.

Try it

Run the full single-error cycle and measure. The grader checks the measurement distribution: the logical qubit must survive, so all the weight sits on a single outcome with qubit 0 equal to 0.

Run your code to see the quantum state.

Open the Probabilities tab: one bar at 010 carries everything. Its qubit-0 bit is 0 — the logical zero survived the error, a logical error rate of exactly zero for this correctable case.

Sign in on the full site to ask questions and join the discussion.