Two-Qubit Gate Randomized Benchmarking in CZ Gate Characterization#
Two-qubit gate randomized benchmarking (TQG RB) characterizes the average performance of a coupler’s CZ
gate. The experiment applies sequences of random two-qubit Clifford gates of increasing length to the
coupled qubit pair, each sequence followed by a recovery Clifford that inverts the net operation so the ideal
outcome is always \(|00\rangle\), and fits how quickly the sequence’s return probability decays with length. Because
each two-qubit Clifford is built from 0–3 CZ gates plus single-qubit gates, the decay constant measures the
average error of the whole gate set. Readout is genuine single-shot 3-state (\(|0\rangle\)/\(|1\rangle\)/\(|2\rangle\) per qubit,
Measure_RO_3state_Opt, bin_mode="append"), so leakage out of the computational subspace can be tracked
alongside ordinary gate error.
Two registry variants share one measurement class and one parameters class:
tqg_randomized_benchmarking(Standard RB, SRB): random two-qubit Clifford sequences.tqg_randomized_benchmarking_interleaved(Interleaved RB, IRB): a bare CZ pulse is inserted after every random Clifford. Comparing the IRB and SRB decay constants isolates the CZ gate’s own fidelity from everything else in the gate set (the random single-qubit gates and the CZs each Clifford already contains).
SRB must be run on a coupler before IRB — the IRB analysis reads SRB’s decay parameters back from Redis to compute the CZ-specific quantities; without them it still succeeds, but reports the plain interleaved fidelity instead of the isolated CZ fidelity.
Code structure#
Class: TQGRandomizedBenchmarking / TQGRandomizedBenchmarkingInterleaved#
TQGRandomizedBenchmarking (a ScheduleCouplerNode) sets up the RB experiment for all active couplers.
TQGRandomizedBenchmarkingInterleaved subclasses it, overriding only analysis_cls. The coupler’s CZ
pulse settings (frequency, duration, amplitude, and the calibrated virtual-Z phase corrections) are resolved
directly from the device model — self.edges[coupler].cz.cz_freq/.square_duration/.square_amp/
.control_phase_correction/.target_phase_correction — the same convention as
CZ chevron/CZ phases, not read from Redis by the measurement
itself. The interleaved node additionally sets schedule_keywords["interleaving_clifford_id"] = CZ_INDEX
(see below).
Like purity benchmarking, each seed needs its own freshly compiled schedule
(the random sequence is baked into the pulses), so seeds is the outer sample-space dimension and
number_of_cliffords the inner one.
Class: TQGRandomizedBenchmarkingMeasurement#
The measurement class responsible for executing the Clifford sequences, shared unchanged by both variants.
Two-qubit Clifford decomposition#
Random Clifford indices are drawn uniformly from the two-qubit Clifford group (11,520 elements,
TwoQubitClifford), seeded per coupler. Each index decomposes into one of four circuit families depending on
its range — single-qubit-like (0 CZs, 576 elements), CNOT-like (1 CZ, 5184), iSWAP-like (2 CZs, 5184), or
SWAP-like (3 CZs, 576) — following Corcoles et al. (Phys. Rev. A 87, 030301) and Barends et al. (Nature,
2014). Single-qubit gates within a Clifford are Epstein-efficient-decomposition pulses (Epstein et al., Phys.
Rev. A 89, 062321). Gates on the two qubits within one Clifford are grouped to run in parallel
(align_cliffords), padded with leading identities so shorter gate strings finish together immediately
before any CZ in that Clifford.
Method: _add_shot#
For each sequence length and each coupler (couplers run as parallel branches within a shared shot):
Negative lengths are calibration points, not RB sequences:
n_cl=-1prepares \(|1\rangle\) (Reset+X),n_cl=-2prepares \(|2\rangle\) (Reset+X+Rxy_12), each immediately measured. These give the analysis a per-seed reference for correcting IQ drift between compiled schedules (see below).Otherwise, a random Clifford sequence of the requested length is drawn (optionally with the recovery Clifford appended,
apply_inverse_gate), and for the interleaved variant a bare CZ pulse is inserted after every element via theCZ_INDEXsentinel (a bare-CZ Clifford index offset by 100,000, so the sentinel check fires on the raw sequence while the recovery-Clifford math still resolves it back to the real Clifford it represents).Each element is either a
_apply_czcall (the coupler’s calibrated CZ pulse, followed by the control/ target virtual-Z phase corrections — folded into \((-360^\circ, 0^\circ]\) so they always rotate “backwards”, and applied to whichever qubitcz_transitiondesignates as control/target, matching CZ phases’s own role assignment) or a parallel block of single-qubit pulses.Measurement: both qubits are read out with
Measure_RO_3state_Opt,bin_mode="append"(every shot kept), tagged with{qubit}_number_of_cliffordsand{qubit}_shot_indexcoordinates.
Class: TQGRandomizedBenchmarkingAnalysis#
The analysis class for the standard (SRB) variant, element_kind = "coupler". Because the dataset’s data
variables are named after each qubit rather than the coupler, this class overrides analyse_element/
_process to group a coupler’s two qubit variables directly, matching the
CZ parametrization pattern.
Per-seed IQ drift correction#
Every seed is a separately compiled schedule, so its IQ can drift relative to the classification boundary
calibrated by ro_combined_optimization_3state (read from Redis: centroid_I/centroid_Q/omega_01/
omega_12/omega_20). If all three calibration points (\(|0\rangle\), \(|1\rangle\), \(|2\rangle\)) are present, the per-seed centroid is
compared against the Redis boundary for an absolute correction; with only the \(|0\rangle\) point (older datasets), the
correction is relative (removes seed-to-seed drift but not a long-term calibration offset). The correction is
subtracted from each seed’s raw IQ before classification; the calibration rows are then dropped before
fitting.
Method: compute_qoi#
Classification: every shot is assigned to state 0/1/2 by angular sector around the 3-state classification boundary (
assign_state), then the nine joint two-qubit outcomes are grouped:correct: \(P(00)\)
leakage: \(P(02)+P(20)+P(12)+P(21)+P(22)\)
computational error: \(P(01)+P(10)+P(11)\)
All three sum to 1 per (seed, sequence length); probabilities are averaged over seeds before fitting.
Primary fit — P(00) decay:
P(00) = A·pᵐ + B(m = number of Cliffords). The average two-qubit gate fidelity follows directly:F = (1 + 3p) / 4.pand its stderr are written to Redis astqg_rb_p_SRB/tqg_rb_p_A_SRB/tqg_rb_p_B_SRB(per-suffix) so a later IRB run can redraw this exact curve as a reference.Computational-subspace fit — leakage: the computational-subspace survival \(P_{comp} = P(00)+P(01)+P(10)+P(11)\) is fit to the same exponential-decay form, giving the per-Clifford leakage/seepage rates \(L_1 = (1-p_L)(1-a)\), \(L_2 = (1-p_L)\,a\) (Wood & Gambetta, “Quantification and characterization of leakage errors,” eqs. 10–11, with covariance-aware error propagation). Written to Redis as
L_1_SRB/L_2_SRB(+ their_errorfields).Corrected decay fit: a third fit on \(P(00) - P_{comp}/4\) extracts the leakage-corrected decay parameter \(p_r\), written to Redis as
p_r_SRB— this is what the IRB analysis needs to isolate the CZ gate.
The reported leakage/error_rate QOI fields are the raw mean of \(P_{leak}\)/\(P_{err}\) averaged over all seeds
and all sequence lengths — not a per-Clifford rate (the per-Clifford rates are the suffixed L_1/L_2 keys).
reduced_chi2 is currently a fixed placeholder value (1.0), not a real goodness-of-fit statistic.
Class: TQGRandomizedBenchmarkingInterleavedAnalysis#
Extends TQGRandomizedBenchmarkingAnalysis for the IRB variant (suffix = "IRB" instead of "SRB"). Runs
the identical SRB-style analysis on the interleaved dataset (writing its own _IRB-suffixed Redis values),
then reads back the coupler’s p_r_SRB/L_1_SRB (and their errors) to compute the CZ-gate-specific
quantities:
with errors propagated from each input’s stderr (see _propagate_cz_error). If no SRB reference is found in
Redis, the analysis still succeeds, logs a warning, and reports the plain interleaved fidelity
\((1 + 3p_{IRB})/4\) instead of \(F_{CZ}\) (is_successful stays True). An additional support figure overlays the
reconstructed SRB reference curve on the IRB fit.
Output: xarray.Dataset#
Each coupler’s dataset holds, per qubit, the classified-state counts (via single-shot IQ) indexed by seed, number of Cliffords (including the embedded negative calibration points), and shot index.
Class: TQGRandomizedBenchmarkingParameters#
The TQGRandomizedBenchmarkingParameters class is shared by both variants. All fields currently use plain
pydantic Field (no acquisition/analysis categorization yet); every field listed below is, physically,
an acquisition field — each is baked into the compiled schedule (which seeds run, how many shots, which
sequence lengths, whether the recovery gate is appended, which qubit plays which CZ role, and the flux-line
IF/LO scheme), so changing any of them requires a hardware re-run. See
Parameter field categories.
n_seeds: int = 10 — number of random Clifford sequences per length.number_of_shots: int = 500 — single-shot repetitions averaged per point.clifford_sequence_lengths: list[int] =[-2, -1, 0, 1, 2, 4, 8, 16, 32]— number of Cliffords per sequence. Negative values are the embedded calibration points described above:-1prepares \(|1\rangle\),-2prepares \(|2\rangle\).apply_inverse_gate: bool = True — append the recovery Clifford that inverts each sequence.cz_transition: str = “20” — targeted transition,"20"or"02": determines which qubit of the coupler plays Control vs Target for the CZ virtual-Z phase corrections. Same convention ascz_parametrization’s field of the same name.downconvert_frequency: float = 4.4e9 — flux-line downconversion offset (Hz); the CZ pulse clock is programmed at-frequency + downconvert_frequency. Same convention ascz_parametrization’s field of the same name.
QOI classes#
TQGRandomizedBenchmarkingQOI(SRB):tqg_fidelity/tqg_fidelity_error(\(F = (1+3p)/4\)),reduced_chi2(currently a fixed placeholder, not a real fit statistic),leakage,error_rate.TQGRandomizedBenchmarkingInterleavedQOI(IRB): the same fields, buttqg_fidelityhere is the CZ gate fidelity \(F_{CZ}\) derived by combining this run’s decay parameter with the standard run’s (read back from Redis) — or the plain interleaved fidelity if no SRB reference is available.leakage/error_rateare the IRB run’s own raw values.
Both QOIs also carry the fit outputs (tqg_rb_p/_A/_B, p_L, a, L_1, L_2, p_r, each with its
stderr). Every QOI value is written to Redis with the variant’s suffix (e.g. tqg_fidelity_SRB,
tqg_fidelity_IRB, p_r_SRB, p_r_SRB_error), so the two runs never overwrite each other. A fit that did
not converge is left out, so its previous Redis value is kept.
Neither QOI has a seepage field — the seepage quantity \(L_2\) is recorded only as the informational L_2
fit output, never derived into a CZ-specific \(L_{2,CZ}\). (The single-qubit randomized benchmarking node does have a
seepage QOI field — don’t confuse the two.) Neither QOI maps to a ParametricCZSubmodule device field: TQG
RB is a benchmarking metric, not a calibration knob, so results are recorded as informational Redis values
only, letting a later IRB run (or a reanalysis) read them back.