laboneq_applications.contrib.analysis.single_qubit_randomized_benchmarking
¶
This module defines the analysis for single qubit randomized benchmarking experiment.
The experiment is defined in laboneq_applications.experiments.
In this analysis, we first interpret the raw data into qubit populations using principal component analysis or rotation and projection on the measured calibration states. Then we fit a exponential decay to the qubit population and extract the gate fidelity from the fit. Finally, we plot the data and the fit.
PlotPopulationRBOptions
¶
Options for the plot_population
task of the RB analysis.
Attributes:
Name | Type | Description |
---|---|---|
do_fitting |
bool
|
Whether to perform the fit.
Default: |
do_rotation |
bool
|
Whether to rotate the raw data based on calibration traces or principal
component analysis.
Default: |
do_pca |
bool
|
Whether to perform principal component analysis on the raw data independent
of whether there were calibration traces in the experiment.
Default: |
cal_states |
str | tuple
|
The states to prepare in the calibration traces. Can be any string or tuple made from combining the characters 'g', 'e', 'f'. Default: same as transition |
Additional attributes from BasePlottingOptions
:
save_figures:
Whether to save the figures.
Default: True
.
close_figures:
Whether to close the figures.
Default: True
.
cal_states: str | tuple = option_field('ge', description='The states to prepare in the calibration traces.')
class-attribute
instance-attribute
¶
do_fitting: bool = option_field(True, description='Whether to perform the fit.')
class-attribute
instance-attribute
¶
do_pca: bool = option_field(False, description='Whether to perform principal component analysis on the raw data independent of whether there were calibration traces in the experiment.')
class-attribute
instance-attribute
¶
do_rotation: bool = option_field(True, description='Whether to rotate the raw data based on calibration traces or principal component analysis.')
class-attribute
instance-attribute
¶
analysis_workflow(result, qubits, length_cliffords, variations, options=None)
¶
The Time Rabi analysis Workflow.
The workflow consists of the following steps:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result |
RunExperimentResults
|
The experiment results returned by the run_experiment task. |
required |
qubits |
QuantumElements
|
The qubits on which to run the analysis. May be either a single qubit or a list of qubits. The UIDs of these qubits must exist in the result. |
required |
length_cliffords |
list
|
list of numbers of Clifford gates to sweep |
required |
variations |
int
|
Number of random seeds for RB. |
required |
options |
TuneUpAnalysisWorkflowOptions | None
|
The options for building the workflow, passed as an instance of [TuneUpAnalysisWorkflowOptions]. See the docstring of this class for more details. |
None
|
Returns:
Name | Type | Description |
---|---|---|
WorkflowBuilder |
None
|
The builder for the analysis workflow. |
calculate_qubit_population_rb(qubits, result, length_cliffords, variations, options=None)
¶
Processes the raw data.
The data is processed in the following way:
- If calibration traces were used in the experiment, the raw data is rotated based on the calibration traces. See calibration_traces_rotation.py/rotate_data_to_cal_trace_results for more details.
- If no calibration traces were used in the experiment, or do_pca = True is passed in options, principal component analysis is performed on the data. See calibration_traces_rotation.py/principal_component_analysis for more details.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qubits |
QuantumElements
|
The qubits on which the amplitude-Rabi experiments was run. May be either a single qubit or a list of qubits. |
required |
result |
RunExperimentResults
|
the result of the experiment, returned by the run_experiment task. |
required |
length_cliffords |
list
|
list of numbers of Clifford gates to sweep |
required |
variations |
int
|
Number of random seeds for RB. |
required |
options |
CalculateQubitPopulationOptions | None
|
The options for building the workflow as an instance of [CalculateQubitPopulationOptions]. See the docstrings of this class for more details. |
None
|
Returns:
Type | Description |
---|---|
dict[str, dict[str, ArrayLike]]
|
dict with qubit UIDs as keys and the dictionary of processed data for each qubit |
dict[str, dict[str, ArrayLike]]
|
as values. See [calibration_traces_rotation.py/calculate_population_1d] for what |
dict[str, dict[str, ArrayLike]]
|
this dictionary looks like. |
Raises:
Type | Description |
---|---|
TypeError
|
If result is not an instance of RunExperimentResults. |
exponential_decay_fit(x, data, param_hints=None)
¶
Performs a fit of an exponential-decay model to data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
ArrayLike
|
the data to be fitted |
required |
x |
ArrayLike
|
the independent variable |
required |
param_hints |
dict | None
|
dictionary of guesses for the fit parameters. See the lmfit docstring for details on the form of the parameter hints dictionary: https://lmfit.github.io/lmfit-py/model.html#lmfit.model.Model.set_param_hint |
None
|
Returns:
Type | Description |
---|---|
ModelResult
|
The lmfit result |
fit_data(qubits, processed_data_dict, options=None)
¶
Perform a fit of an exponential-decay model to the qubit e-state population.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qubits |
QuantumElements
|
The qubits on which to run the analysis. May be either a single qubit or a list of qubits. The UIDs of these qubits must exist in processed_data_dict |
required |
processed_data_dict |
dict[str, dict[str, ArrayLike]]
|
the processed data dictionary returned by process_raw_data |
required |
options |
FitDataOptions | None
|
The options class for this task as an instance of [FitDataOptions]. See the docstring of this class for accepted options. |
None
|
Returns:
Type | Description |
---|---|
dict[str, ModelResult]
|
dict with qubit UIDs as keys and the fit results for each qubit as keys. |
plot_population(qubits, processed_data_dict, fit_results, options=None)
¶
Create the time-Rabi plots.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qubits |
QuantumElements
|
The qubits on which to run the analysis. May be either a single qubit or a list of qubits. The UIDs of these qubits must exist in the processed_data_dict and fit_results parameters. |
required |
processed_data_dict |
dict[str, dict[str, ArrayLike]]
|
The processed data dictionary returned by process_raw_data. |
required |
fit_results |
dict[str, ModelResult] | None
|
The fit-results dictionary returned by fit_data. |
required |
options |
PlotPopulationRBOptions | None
|
The options class for this task as an instance of [PlotPopulationRBOptions]. See the docstring of this class for accepted options. |
None
|
Returns:
Type | Description |
---|---|
dict[str, Figure]
|
dict with qubit UIDs as keys and the figures for each qubit as values. |