laboneq_applications.analysis.two_qubit_rb
¶
Analysis for the two-qubit randomized benchmarking experiment.
The experiment is defined in laboneq_applications.experiments.
Data is acquired in SINGLE_SHOT + DISCRIMINATION mode, so each shot yields a
binary 0/1 result per qubit. The per-shot bit outcomes of both qubits in a
pair are combined into a joint two-qubit state ("00", "01", "10",
"11"), and the probability of each joint state is computed by averaging
over shots for each circuit in the sweep.
The "00" state probability is fitted with an exponential decay and the
error-per-Clifford (EPC) is extracted using the two-qubit depolarising
formula::
EPC = (d - 1) / d * (1 - exp(-decay_rate))
where d = 2^2 = 4 for two qubits.
The analysis returns a dictionary of the form::
{"q0_uid-q1_uid": {"epc_avg": float}}
PlotPopulationTQRBOptions
¶
Options for the plot_population task of the two-qubit RB analysis.
Attributes:
| Name | Type | Description |
|---|---|---|
do_fitting |
bool
|
Whether to overlay the exponential fit on the P(00) data.
Default: |
analysis_workflow(result, qubit_pairs, length_cliffords, variations, options=None)
¶
Two-qubit RB analysis workflow.
The workflow consists of the following steps:
- calculate_qubit_population_tq_rb Combine per-shot qubit bits into joint two-qubit state populations.
- fit_data Fit an exponential decay to the P(00) population per pair.
- compute_pair_epc Compute pair EPC from the fit result.
- plot_population Optionally plot survival curves (one figure per pair).
Changed in version 27.1.0
The analysis moved out of contrib. It takes the qubit pairs as UIDs
instead of quantum elements, averages single-shot data over the shots of
each sequence, and plots the Clifford fidelity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
RunExperimentResults
|
The experiment results returned by the run_experiment task. |
required |
qubit_pairs
|
list[list[str]]
|
List of [q0, q1] pairs that were benchmarked, passed by UID. |
required |
length_cliffords
|
list[int]
|
List of numbers of 2-qubit Clifford gates swept. |
required |
variations
|
int
|
Number of random circuit samples per sequence length. |
required |
options
|
TuneUpAnalysisWorkflowOptions | None
|
Analysis workflow options. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
WorkflowBuilder |
None
|
The builder for the analysis workflow. |
calculate_qubit_population_tq_rb(qubit_pairs, result, length_cliffords, variations)
¶
Compute joint two-qubit state populations from single-shot data.
For each shot, the per-qubit discrimination bits (0 or 1) are combined
into a joint two-qubit state label ("00", "01", "10",
"11"). The probability of each joint state is then obtained by
averaging over shots for every circuit in the sweep.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qubit_pairs
|
list[list[str]]
|
List of [q0, q1] pairs, passed by UID. |
required |
result
|
RunExperimentResults
|
The experiment results: discriminated states 0 or 1, with one row per shot and one column per sequence. |
required |
length_cliffords
|
list
|
List of Clifford sequence lengths. |
required |
variations
|
int
|
Number of random circuit samples per sequence length. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, ArrayLike]]
|
Dictionary keyed by pair UID |
compute_pair_epc(qubit_pairs, fit_results)
¶
Compute the EPC for each qubit pair from the P(00) fit.
The error per two-qubit Clifford is extracted from the exponential decay
of the joint "00" state population::
EPC = (d - 1) / d * (1 - exp(-decay_rate))
with d = 4 (two-qubit Hilbert space dimension).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qubit_pairs
|
list[list[str]]
|
List of [q0, q1] pairs, passed by UID. |
required |
fit_results
|
dict[str, ModelResult]
|
Per-pair fit results as returned by fit_data. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, float]]
|
Dictionary |
exponential_decay_fit(x, data, param_hints=None)
¶
Fit an exponential decay model to RB data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ArrayLike
|
Sequence lengths (number of Cliffords). |
required |
data
|
ArrayLike
|
Joint state population values. |
required |
param_hints
|
dict | None
|
lmfit parameter hints dictionary. |
None
|
Returns:
| Type | Description |
|---|---|
ModelResult
|
The lmfit result. |
fit_data(qubit_pairs, processed_data_dict, options=None)
¶
Fit an exponential decay to P(00) for each qubit pair.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qubit_pairs
|
list[list[str]]
|
List of [q0, q1] pairs, passed by UID. |
required |
processed_data_dict
|
dict[str, dict[str, ArrayLike]]
|
Per-pair joint state populations as returned by calculate_qubit_population_tq_rb. |
required |
options
|
FitDataOptions | None
|
Fit options. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, ModelResult]
|
Dictionary keyed by pair UID with lmfit ModelResult values. |
plot_population(qubit_pairs, processed_data_dict, fit_results, options=None)
¶
Plot the joint two-qubit state populations for each pair.
One figure is produced per qubit pair, showing P(00) vs. number of Cliffords together with the exponential fit and extracted EPC.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qubit_pairs
|
list[list[str]]
|
List of [q0, q1] pairs, passed by UID. |
required |
processed_data_dict
|
dict[str, dict[str, ArrayLike]]
|
Per-pair joint state populations. |
required |
fit_results
|
dict[str, ModelResult] | None
|
Per-pair fit results (keyed by pair UID). |
required |
options
|
PlotPopulationTQRBOptions | None
|
Plot options. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Figure]
|
Dictionary keyed by pair UID ( |