Randomized Benchmarking with Single-Shot Readout (SSRO)#
Randomized benchmarking (RB) assesses the average performance of single-qubit gates by applying sequences of random Clifford gates of increasing length, each followed by the inverse (“recovery”) Clifford that should return the qubit to \(|0\rangle\), and fitting how quickly the sequence’s success probability decays with length. This implementation uses single-shot readout (SSRO) classified into three states — \(|0\rangle\), \(|1\rangle\), \(|2\rangle\) — so that ordinary computational error and leakage to the second excited state can be separated cleanly from each other.
Code structure#
Class: RandomizedBenchmarking#
The RandomizedBenchmarking class sets up the RB experiment for all active qubits. Unlike
T1/T2/T2 echo (which sweep a hardware Variable over one
fixed compiled schedule), each of the n_seeds random-Clifford realizations needs its own freshly compiled
schedule — the random sequence is baked directly into the pulses — so RandomizedBenchmarking is a
ScheduleQubitNode that drives seeds as the outer sample-space dimension (recompiled fresh per seed),
with clifford_sequence_lengths inner. Each qubit runs its own independently seeded random Clifford
sequence.
Class: RandomizedBenchmarkingMeasurement#
The measurement class responsible for executing the Clifford sequences.
Method: point_schedule / schedule_function#
For each qubit and each sequence length, a random sequence of Clifford indices is drawn (seeded by
seeds[qubit]), each Clifford decomposed into its constituent Rxy pulses via the two-qubit-free single-
qubit Clifford group S4GroupPTM, followed by the recovery Clifford that inverts the whole sequence. The
qubit is then read out with Measure_RO_3state_Opt (three-state SSRO), bin_mode="append" (every single
shot kept, not hardware-averaged), wrapped in an explicit shot-loop register so the schedule’s top-level
repetitions stays at 1 — required by the automatic calibration-points block BaseNode.precompile appends.
Class: RBAnalysis#
The analysis class that classifies every single shot into states 0/1/2 and fits the resulting population decays.
Method: _classify_shots#
Classification is nearest-centroid (Voronoi) via three pairwise calibration-axis projections (0-1, 1-2, 0-2):
under the shared-covariance bivariate-Gaussian assumption, each pairwise axis’s 0.5 threshold is exactly
that pair’s Bayes decision boundary, so the state that wins both of its relevant pairwise comparisons is the
globally nearest centroid. All three axes are needed — \(|2\rangle\) is not generally collinear with the \(|0\rangle\)–\(|1\rangle\) axis,
so a sequential two-axis check would silently misclassify. If the qubit’s 1→2 pulse isn’t calibrated (no
CAL=2 calibration point), classification falls back to 0-vs-1 only and leakage/seepage are left unmeasured
(NaN).
Method: compute_qoi#
Every one of the n_seeds independent realizations carries its own calibration points (never averaged
across seeds), so each seed’s shots are classified against calibration measured in that same compiled
schedule; state populations are then averaged across seeds, with the seed-to-seed standard deviation used as
the fit weight.
Initial-fidelity guard: if the mean P(\(|0\rangle\)) at zero Cliffords is below
MINIMUM_INITIAL_GROUND_STATE_POPULATION(0.88), the analysis fails immediately — RB should start near P(\(|0\rangle\))=1, and well below that the classification/calibration itself is untrustworthy.Fidelity fit:
RBDecayModelis fit to the mean P(\(|0\rangle\)) decay, givingfidelity = (1 + p) / 2wherepis the fitted depolarizing parameter, andreduced_chi2from this same fit.Leakage/seepage fit (only if a
CAL=2calibration point was available):RBDecayModelis fit again, this time to the mean computational populationP(0) + P(1)(i.e.1 - P(2)), seeded with an adjusted initial guess suited to that decay’s shape (small amplitude, near-1 asymptote, near-unityp). From its fit parametersA/B/p(Wood & Gambetta, “Quantification and characterization of leakage errors,” eqs. 10–11):leakage = (1-B)(1-p),seepage = B(1-p). Their errors are propagated from the fit’s parameter standard errors and their covariance (cov_B_p), not just combined independently.
Output: xarray.Dataset#
The dataset holds, per qubit, the classified-state counts (via the single-shot IQ data) indexed by seed, number of Cliffords, and shot index, plus the automatic calibration-points block appended per seed.
Class: RBParameters#
The RBParameters class encapsulates the parameters for single-qubit RB. All fields are currently
acquisition fields; see Parameter field categories.
Acquisition fields#
n_seeds: int = 8 — number of independent random-Clifford-sequence realizations (a fresh, differently seeded sequence per sequence length), recompiled and executed once per seed. Fidelity is fit against their seed-averaged state populations, weighted by the seed-to-seed spread at each sequence length.number_of_shots: int = 500 — single-shot repeats measured per (seed, sequence length) point.repetitions: int = 1024 — hardware-averaged shots for the automatic calibration-points block appended byBaseNode.precompile; independent ofnumber_of_shots, which drives the main single-shot RB loop.clifford_sequence_lengths: list[int] =[0, 9, 27, 81, 243, 729, 1800]— numbers of random Cliffords applied (then inverted) per sequence.
Class: RBQOI#
fidelity/fidelity_error: the average single-qubit gate fidelity,F = (1 + p) / 2.reduced_chi2: goodness-of-fit indicator from the fidelity fit.leakage/leakage_error: mean per-Clifford probability of leaking to \(|2\rangle\) (NaNif no leakage calibration point was available).seepage/seepage_error: mean per-Clifford probability of returning from \(|2\rangle\) into the computational subspace (NaNunder the same condition).
RB is a characterization quantity, not a calibration knob — to_dict() returns an empty mapping. Results
are written to Redis only, under rb_fidelity, rb_reduced_chi2, rb_leakage, and rb_seepage. The
rb_fidelity value is read back by purity benchmarking to decompose its own
error into coherent/incoherent parts — RandomizedBenchmarking should therefore run before purity
benchmarking for that decomposition to be available.