Skip to content

laboneq_applications.analysis.drag_q_scaling

This module defines the analysis for a DRAG calibration experiment.

The experiment is defined in laboneq_applications.experiments. See the docstring of this module for more details about the experiment and its parameters.

In this analysis, we first interpret the raw data into qubit populations using principle-component analysis or rotation and projection on the measured calibration states. Then we fit the measured qubit population as a function of the beta parameter and determine the optimal beta parameter. Finally, we plot the data and the fit.

analysis_workflow(result, qubits, q_scalings, options=None)

The analysis Workflow for the DRAG quadrature-scaling calibration.

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 Qubits

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
q_scalings QubitSweepPoints

The quadrature scaling factors that were swept over in the experiment for each qubit. If qubits is a single qubit, q_scalings must be a list of numbers or an array. Otherwise, it must be a list of lists of numbers or arrays.

required
options TuneUpAnalysisWorkflowOptions | None

The options for building the workflow, passed as an instance of [TuneUpAnalysisWorkflowOptions]. In addition to options from [WorkflowOptions], the following custom options are supported: do_fitting, do_plotting, and the options of the [TuneupAnalysisOptions] class. See the docstring of [TuneUpAnalysisWorkflowOptions] for more details.

None

Returns:

Name Type Description
WorkflowBuilder None

The builder for the analysis workflow.

Example
options = analysis_workflow.options()
options.close_figures(False)
result = analysis_workflow(
    results=results
    qubits=[q0, q1],
    q_scalings=[
        np.linspace(-0.05, 0.05, 11),
        np.linspace(-0.05, 0.05, 11),
    ],
    options=options,
).run()

calculate_qubit_population_for_pulse_ids(qubits, result, q_scalings, options=None)

Processes the raw data from the experiment result.

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 Qubits

The qubits on which the 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
q_scalings QubitSweepPoints

The quadrature scaling factors that were swept over in the experiment for each qubit. If qubits is a single qubit, q_scalings must be a list of numbers or an array. Otherwise, it must be a list of lists of numbers or arrays.

required
options TuneupAnalysisOptions | None

The options for processing the raw data. See [TuneupAnalysisOptions], [TuneupExperimentOptions] and [BaseExperimentOptions] for accepted options. Overwrites the options from [TuneupAnalysisOptions], [TuneupExperimentOptions] and [BaseExperimentOptions].

None

Returns:

Type Description
dict[str, dict[str, dict[str, ArrayLike]]]

dict with qubit UIDs as keys. The dictionary of processed data for each qubit

dict[str, dict[str, dict[str, ArrayLike]]]

further has "y180" and "my180" as keys.

dict[str, dict[str, dict[str, ArrayLike]]]

See [calibration_traces_rotation.py/calculate_population_1d] for what this

dict[str, dict[str, dict[str, ArrayLike]]]

dictionary looks like.

Raises:

Type Description
TypeError

If result is not an instance of RunExperimentResults.

extract_qubit_parameters(qubits, fit_results, options=None)

Extract the qubit parameters from the fit results.

Parameters:

Name Type Description Default
qubits Qubits

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.

required
fit_results dict[str, dict[str, ModelResult]]

the fit-results dictionary returned by fit_data

required
options TuneupAnalysisOptions | None

The options for extracting the qubit parameters. See [TuneupAnalysisOptions], [TuneupExperimentOptions] and [BaseExperimentOptions] for accepted options.

None

Returns:

Type Description
dict[str, dict[str, dict[str, int | float | Variable | None]]]

dict with extracted qubit parameters and the previous values for those qubit

dict[str, dict[str, dict[str, int | float | Variable | None]]]

parameters. The dictionary has the following form:

dict[str, dict[str, dict[str, int | float | Variable | None]]]

```python

dict[str, dict[str, dict[str, int | float | Variable | None]]]

{ "new_parameter_values": { q.uid: { qb_param_name: qb_param_value }, } "old_parameter_values": { q.uid: { qb_param_name: qb_param_value }, }

dict[str, dict[str, dict[str, int | float | Variable | None]]]

}

dict[str, dict[str, dict[str, int | float | Variable | None]]]

```

dict[str, dict[str, dict[str, int | float | Variable | None]]]

If the do_fitting option is False, the new_parameter_values are not extracted

dict[str, dict[str, dict[str, int | float | Variable | None]]]

and the function only returns the old_parameter_values.

dict[str, dict[str, dict[str, int | float | Variable | None]]]

If a qubit uid is not found in fit_results, the new_parameter_values entry for

dict[str, dict[str, dict[str, int | float | Variable | None]]]

that qubit is left empty.

fit_data(qubits, processed_data_dict, options=None)

Perform a fit of a linear model to the data.

Parameters:

Name Type Description Default
qubits Qubits

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.

required
processed_data_dict dict[str, dict[str, dict[str, ArrayLike]]]

the processed data dictionary returned by process_raw_data

required
options TuneupAnalysisOptions | None

The options for processing the raw data. See [TuneupAnalysisOptions], [TuneupExperimentOptions] and [BaseExperimentOptions] for accepted options.

None

Returns:

Type Description
dict[str, dict[str, ModelResult]]

dict with qubit UIDs as keys, "y180"/"my180" as subkeys and the fit results

dict[str, dict[str, ModelResult]]

for each qubit as values.

plot_population(qubits, processed_data_dict, fit_results, qubit_parameters, options=None)

Create the DRAG quadrature-scaling calibration plots.

Parameters:

Name Type Description Default
qubits Qubits

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 and qubit_parameters.

required
processed_data_dict dict[str, dict[str, dict[str, ArrayLike]]]

the processed data dictionary returned by process_raw_data

required
fit_results dict[str, dict[str, ModelResult]] | None

the fit-results dictionary returned by fit_data

required
qubit_parameters dict[str, dict[str, dict[str, int | float | Variable | None]]] | None

the qubit-parameters dictionary returned by extract_qubit_parameters

required
options TuneupAnalysisOptions | None

The options for processing the raw data. See [TuneupAnalysisOptions], [TuneupExperimentOptions] and [BaseExperimentOptions] for accepted options.

None

Returns:

Type Description
dict[str, Figure]

dict with qubit UIDs as keys and the figures for each qubit as values.

dict[str, Figure]

If a qubit uid is not found in fit_results, the fit and the textbox with the

dict[str, Figure]

extracted qubit parameters are not plotted.