|q⟩ Bad Qubits

advanced · Programming · Capstone Projects

Project: Benchmark a Device Model

You cannot trust a quantum processor you have not characterized. Randomized benchmarking (RB) is the field's standard answer: it measures an average gate error that is robust to state-preparation and measurement (SPAM) errors, by averaging over random Clifford sequences. This capstone builds the fundamental RB primitive — a random sequence plus its exact recovery — whose survival probability is the data point a full RB experiment fits.

The RB protocol

For each sequence length mm:

  1. Draw mm random Clifford gates C1,,CmC_1, \dots, C_m.
  2. Append the single recovery Clifford Cm+1=(CmC1)1C_{m+1} = (C_m \cdots C_1)^{-1}, so the ideal net operation is the identity.
  3. Run, measure, and record the survival probability P(0)P(|0\rangle).
  4. Repeat over many random sequences and average.

On a noiseless device every sequence returns the qubit to 0|0\rangle, giving survival 11 regardless of mm. On real hardware errors accumulate and the averaged survival decays.

The decay model

Averaging over the Clifford group depolarizes the errors, so the mean survival follows a clean exponential in the sequence length:

Pˉ(m)=Apm+B,\bar{P}(m) = A\,p^{\,m} + B,

where pp is the depolarizing parameter and A,BA, B absorb SPAM. Fitting pp yields the average error per Clifford

r=(d1)(1p)d,d=2n,r = \frac{(d - 1)(1 - p)}{d}, \qquad d = 2^n,

which is what gets quoted as a device's gate fidelity. Because the form of the decay is fixed and A,BA, B soak up state-prep and readout errors, the extracted rr isolates gate quality — RB's key advantage over naive process tomography.

A length-3 instance

Take the sequence H,S,HH, S, H. Its inverse, applied in reverse with each gate inverted, is H,S,HH, S^\dagger, H (since H1=HH^{-1} = H and S1=SS^{-1} = S^\dagger). Concatenated, the circuit is the identity, so a perfect simulator returns survival P(0)=1P(|0\rangle) = 1 — the noise-free reference against which a noisy device's decay is measured.

Try it

Build the length-3 sequence and its recovery, then measure. The grader checks the output distribution: all probability on outcome 00, the ideal survival of 11.

Run your code to see the quantum state.

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