uniqc.calibration.xeb.parallel_cz module¶
Parallel-CZ XEB calibration: chip-pre-flight 2-qubit gate fidelity.
This module implements a generic parallel cross-entropy benchmarking protocol useful as a pre-flight chip characterization step (i.e. before running any larger experiment that depends on per-pair CZ fidelity).
Protocol¶
For a fixed CZ pattern (a matching of disjoint qubit pairs):
cycle = U3(haar) on every region qubit, then CZ on every pair in the pattern
Repeat for depth cycles, then measure all region qubits. Sample
shots bitstrings per circuit and K random circuit instances per
(pattern, depth) combination.
For each pair in the matching, the full N-qubit circuit factorises as
a tensor product over pairs (1q ops are local; CZs are between
disjoint pairs). The 2-qubit marginal distribution on each pair is
exactly the 2-qubit pure-state distribution of that pair’s
sub-circuit, so we can score every pair independently using its
2-qubit F_XEB(d). Fitting F(d) = beta · alpha^d per pair
yields the per-cycle CZ fidelity alpha.
Public API¶
Schedule— replayable per-cycle U3 angles + CZ patternbuild_parallel_cz_xeb_circuit()— single circuit + Schedulebuild_parallel_cz_xeb_corpus()— full corpuspair_marginal_counts()— 2-qubit marginal of N-qubit countspair_ideal_probs()— 2-qubit ideal probabilities for a pairper_pair_F_XEB()— per-(record, pair) F_XEBfit_pair_decays()— weighted log-LS fitF(d) = beta·alpha^dParallelCZBenchmarker— end-to-end runner
- class uniqc.calibration.xeb.parallel_cz.PairCircuitFit(record_id, pair, pattern_idx, depth, instance, F_XEB, F_XEB_sigma, shots)[source]¶
Bases:
objectPer-(record, pair) F_XEB computed on the 2-qubit marginal.
- Parameters:
- class uniqc.calibration.xeb.parallel_cz.PairDecay(pair, n_points, alpha, beta, log_alpha, log_beta, sigma_log_alpha, sigma_log_beta, log_residual_std)[source]¶
Bases:
objectPer-pair weighted log-LS fit
F(d) = beta · alpha^d.- Parameters:
- class uniqc.calibration.xeb.parallel_cz.ParallelCZBenchmarker(adapter, shots=5000, cache_dir=None, seed=None, query_timeout=600.0, query_interval=2.0)[source]¶
Bases:
objectEnd-to-end parallel-CZ XEB runner.
- Parameters:
adapter (QuantumAdapter) – A
QuantumAdaptersupportingsubmit/query(and optionallysubmit_batch/query_batch). DummyAdapter is also supported via itssimulate_pmeasurefast path.shots (int) – Number of shots per circuit.
cache_dir (str | None) – If supplied, per-pair
XEBResultobjects are saved here under the standard naming convention.seed (int | None) – Master seed for the corpus RNG.
query_timeout (float) – Per-circuit / per-batch poll timeout (seconds).
query_interval (float) – Poll interval (seconds).
- run(region_qubits, patterns, depths, instances=20)[source]¶
Build a corpus, execute it, fit per-pair decays.
- Returns a dict with keys:
corpus: list[ProbeCircuit]counts_by_record: dict[record_id, counts]per_pair_fits: list[PairCircuitFit]per_pair_decays: dict[pair, PairDecay]per_pair_results: dict[pair, XEBResult]
- class uniqc.calibration.xeb.parallel_cz.ProbeCircuit(circuit, schedule, pattern_idx, pattern, depth, instance, record_id)[source]¶
Bases:
objectOne built circuit + its replayable schedule and metadata.
- Parameters:
- class uniqc.calibration.xeb.parallel_cz.Schedule(region_qubits, measured_qubits, cycles, seed)[source]¶
Bases:
objectPer-cycle U3 angles and CZ pattern for a single XEB instance.
cyclesis a tuple of(angles_per_qubit, pattern)pairs.angles_per_qubitis ordered the same asregion_qubits.- Parameters:
- uniqc.calibration.xeb.parallel_cz.build_parallel_cz_xeb_circuit(region_qubits, pattern, depth, *, seed=0, instance=0)[source]¶
Build one parallel-CZ XEB probe circuit.
Each cycle is
U3(haar) on every region qubit, then CZ on every pair in pattern. Single-qubit angles are drawn from a deterministic RNG seeded by(seed, depth, instance, pattern_id)so different patterns get statistically independent fillings.
- uniqc.calibration.xeb.parallel_cz.build_parallel_cz_xeb_corpus(region_qubits, patterns, depths, instances, *, seed=2026)[source]¶
Build the full XEB corpus.
Returns
len(patterns) * len(depths) * instancesprobes. Within a single(pattern, depth)slot,instancesindependent random U3 fillings are emitted.
- uniqc.calibration.xeb.parallel_cz.fit_pair_decays(fits, *, log_floor=0.0001)[source]¶
Per-pair weighted log-LS fit of
F(d) = beta · alpha^d.Drops circuits where
F <= log_floor(cannot take log). Weights are1/sigma_logF^2withsigma_logF = sigma_F / F.
- uniqc.calibration.xeb.parallel_cz.pair_ideal_probs(schedule, pair)[source]¶
Build and simulate the 2-qubit subcircuit on
pair.Only the cycle’s 1q ops on the pair’s two qubits and the CZ on that pair (when present in the cycle’s pattern) are kept. Returns a length-4 probability vector indexed as
(bb << 1) | bawherebaispair[0]’s outcome andbbispair[1]’s — i.e. the index has bit 0 = pair[0], bit 1 = pair[1], matching the layout produced bypair_marginal_counts().
- uniqc.calibration.xeb.parallel_cz.pair_marginal_counts(counts, measured_qubits, pair)[source]¶
Marginalise full N-qubit counts to a 2-qubit pair.
measured_qubitsdefines the bit positions of the count keys: the integer index of an outcome has bit ``k`` (LSB+k) = state of the ``k``-th measured qubit. This matchesSimulator’ssimulate_pmeasureordering whenformat(idx, f'0{n}b')is used to render the count key as a binary string.Returns counts indexed by
(bb << 1) | bawhereba(bit 0, LSB) is the measured outcome onpair[0]andbb(bit 1) is the outcome onpair[1]. This matches the layout produced by the 2-qubit reference simulation inpair_ideal_probs().
- uniqc.calibration.xeb.parallel_cz.per_pair_F_XEB(records, pairs, *, counts_by_record=None)[source]¶
Compute per-pair F_XEB for every (record, pair) combination.
Each
recordmust carry aSchedule(under key"schedule") plusrecord_id,pattern_idx,depth,instance. Counts may be embedded under"counts"or supplied viacounts_by_record(keyed byrecord_id).Uses the normalised (un-biased at small N) linear XEB estimator
F = (<P_id>_meas - 1/D) / (Σ P_id² - 1/D)
which equals
1for the noiseless circuit and0for a fully depolarised pair, regardless of depth-dependent deviations from Porter–Thomas. Returns onePairCircuitFitper (record, pair) where the pair is in the record’smeasured_qubits.