Calibration routines#

Introduction#

The calibration routines are techniques used to reduce execution errors in quantum circuits. To perform calibrations, the expected theoretical results of an experiment are compared with readouts obtained by running that same experiment using quantum devices. There are at least two objectives in calibration:

  • To derive the exact values of the signals to be supplied to the hardware in order to obtain the best possible implementation of a theoretical operation;

  • Derive the system relaxation time, which is the threshold time interval beyond which executions of operations on the hardware are no longer reliable due to machine overload.

Current and future qibocal routines are listed in the following table:

Methods

Code

Tested on device

Automated

Resonator Punchout

Yes

Yes

In progress

Resonator-Flux

Yes

Yes

In progress

Qubit spectroscopy

Yes

Yes

In progress

Qubit Flux

Yes

Yes

In progress

Rabi (T1)

Yes

Yes

No

Ramsey (T2)

Yes

Yes

No

Single shot readouts

Yes

Yes

No

All-XY (drag)

Yes

Yes

No

RB & co (1 qubit)

Yes

No

No

Cryoscope

In progress

In progress

No

CZ gate

No

No

No

RB & co (multi qubits)

No

No

No

Circuit transpilation

Yes

No

No

Resonator#

qibocal.calibrations.characterization.resonator_spectroscopy.resonator_spectroscopy(platform: qibolab.platforms.abstract.AbstractPlatform, qubits: dict, fast_width, fast_step, precision_width, precision_step, software_averages=1, points=10)#

Perform spectroscopies on the qubits’ readout resonators. This routine executes an initial scan around the expected resonator frequency indicated in the platform runcard. After that, a final sweep with more precision is executed centered in the new resonator frequency found.

Parameters
  • platform (AbstractPlatform) – Qibolab platform object

  • qubits (dict) – List of target qubits to perform the action

  • fast_width (int) – Width frequency in HZ to perform the high resolution sweep

  • fast_step (int) – Step frequency in HZ for the high resolution sweep

  • precision_width (int) – Width frequency in HZ to perform the precision resolution sweep

  • precision_step (int) – Step frequency in HZ for the precission resolution sweep

  • software_averages (int) – Number of executions of the routine for averaging results

  • points (int) – Save data results in a file every number of points

Returns

  • Two DataUnits objects with the raw data obtained for the fast and precision sweeps with the following keys

    • MSR[V]: Resonator signal voltage mesurement in volts

    • i[V]: Resonator signal voltage mesurement for the component I in volts

    • q[V]: Resonator signal voltage mesurement for the component Q in volts

    • phase[rad]: Resonator signal phase mesurement in radians

    • frequency[Hz]: Resonator frequency value in Hz

    • qubit: The qubit being tested

    • iteration: The iteration number of the many determined by software_averages

  • A DataUnits object with the fitted data obtained with the following keys

    • readout_frequency: frequency

    • peak_voltage: peak voltage

    • popt0: Lorentzian’s amplitude

    • popt1: Lorentzian’s center

    • popt2: Lorentzian’s sigma

    • popt3: Lorentzian’s offset

    • qubit: The qubit being tested

qibocal.calibrations.characterization.resonator_spectroscopy.resonator_punchout(platform: qibolab.platforms.abstract.AbstractPlatform, qubits: dict, freq_width, freq_step, min_att, max_att, step_att, software_averages=1, points=10)#

Perform spectroscopies on the qubits’ readout resonators, decreasing the attenuation applied to the read-out pulse, producing an increment of the power sent to the resonator. That shows the two regimes of a given resonator, low and high-power regimes.

Parameters
  • platform (AbstractPlatform) – Qibolab platform object

  • qubits (dict) – List of target qubits to perform the action

  • freq_width (int) – Width frequency in HZ to perform the spectroscopy sweep

  • freq_step (int) – Step frequency in HZ for the spectroscopy sweep

  • min_att (int) – Minimum value in db for the attenuation sweep

  • max_att (int) – Minimum value in db for the attenuation sweep

  • step_att (int) – Step attenuation in db for the attenuation sweep

  • software_averages (int) – Number of executions of the routine for averaging results

  • points (int) – Save data results in a file every number of points

Returns

A DataUnits object with the raw data obtained with the following keys

  • MSR[V]: Resonator signal voltage mesurement in volts

  • i[V]: Resonator signal voltage mesurement for the component I in volts

  • q[V]: Resonator signal voltage mesurement for the component Q in volts

  • phase[rad]: Resonator signal phase mesurement in radians

  • frequency[Hz]: Resonator frequency value in Hz

  • attenuation[dB]: attenuation value in db applied to the flux line

  • qubit: The qubit being tested

  • iteration: The iteration number of the many determined by software_averages

qibocal.calibrations.characterization.resonator_spectroscopy.resonator_spectroscopy_flux(platform: qibolab.platforms.abstract.AbstractPlatform, qubits: dict, freq_width, freq_step, bias_width, bias_step, fluxlines, software_averages=1, points=10)#

Perform spectroscopy on the readout resonator modifying the bias applied in the flux control line. This routine works for quantum devices flux controlled.

Parameters
  • platform (AbstractPlatform) – Qibolab platform object

  • qubits (dict) – List of target qubits to perform the action

  • freq_width (int) – Width frequency in HZ to perform the spectroscopy sweep

  • freq_step (int) – Step frequency in HZ for the spectroscopy sweep

  • bias_width (float) – Width bias in A for the flux bias sweep

  • bias_step (float) – Step bias in A for the flux bias sweep

  • fluxlines (list) – List of flux lines to use to perform the experiment. If it is set to “qubits”, it uses each of flux lines associated with the target qubits.

  • software_averages (int) – Number of executions of the routine for averaging results

  • points (int) – Save data results in a file every number of points

Returns

A DataUnits object with the raw data obtained with the following keys

  • MSR[V]: Resonator signal voltage mesurement in volts

  • i[V]: Resonator signal voltage mesurement for the component I in volts

  • q[V]: Resonator signal voltage mesurement for the component Q in volts

  • phase[rad]: Resonator signal phase mesurement in radians

  • frequency[Hz]: Resonator frequency value in Hz

  • bias[V]: Current value in A applied to the flux line

  • qubit: The qubit being tested

  • fluxline: The fluxline being tested

  • iteration: The iteration number of the many determined by software_averages

qibocal.calibrations.characterization.resonator_spectroscopy.dispersive_shift(platform: qibolab.platforms.abstract.AbstractPlatform, qubits: dict, freq_width, freq_step, software_averages=1, points=10)#

Perform spectroscopy on the readout resonator, with the qubit in ground and excited state, showing the resonator shift produced by the coupling between the resonator and the qubit.

Parameters
  • platform (AbstractPlatform) – Qibolab platform object

  • qubits (dict) – List of target qubits to perform the action

  • freq_width (int) – Width frequency in HZ to perform the spectroscopy sweep

  • freq_step (int) – Step frequency in HZ for the spectroscopy sweep

  • software_averages (int) – Number of executions of the routine for averaging results

  • points (int) – Save data results in a file every number of points

Returns

A DataUnits object with the raw data obtained for the normal and shifted sweeps with the following keys

  • MSR[V]: Resonator signal voltage mesurement in volts

  • i[V]: Resonator signal voltage mesurement for the component I in volts

  • q[V]: Resonator signal voltage mesurement for the component Q in volts

  • phase[rad]: Resonator signal phase mesurement in radians

  • frequency[Hz]: Resonator frequency value in Hz

  • qubit: The qubit being tested

  • iteration: The iteration number of the many determined by software_averages

Single Qubit#

Qubit spectroscopy#

qibocal.calibrations.characterization.qubit_spectroscopy.qubit_spectroscopy(platform: qibolab.platforms.abstract.AbstractPlatform, qubits: dict, fast_width, fast_step, precision_width, precision_step, software_averages=1, points=10)#

Perform spectroscopy on the qubit. This routine executes a fast scan around the expected qubit frequency indicated in the platform runcard. Afterthat, a final sweep with more precision is executed centered in the new qubit frequency found.

Parameters
  • platform (AbstractPlatform) – Qibolab platform object

  • qubits (dict) – Dict of target Qubit objects to perform the action

  • fast_start (int) – Initial frequency in HZ to perform the qubit fast sweep

  • fast_width (int) – Width frequency in HZ to perform the high resolution sweep

  • fast_step (int) – Step frequency in HZ for the high resolution sweep

  • precision_width (int) – Width frequency in HZ to perform the precision resolution sweep

  • precision_step (int) – Step frequency in HZ for the precission resolution sweep

  • software_averages (int) – Number of executions of the routine for averaging results

  • points (int) – Save data results in a file every number of points

Returns

  • Two DataUnits objects with the raw data obtained for the fast and precision sweeps with the following keys

    • MSR[V]: Resonator signal voltage mesurement in volts

    • i[V]: Resonator signal voltage mesurement for the component I in volts

    • q[V]: Resonator signal voltage mesurement for the component Q in volts

    • phase[rad]: Resonator signal phase mesurement in radians

    • frequency[Hz]: Qubit drive frequency value in Hz

    • qubit: The qubit being tested

    • iteration: The iteration number of the many determined by software_averages

  • A DataUnits object with the fitted data obtained with the following keys

    • qubit: The qubit being tested

    • drive_frequency: frequency

    • peak_voltage: peak voltage

    • popt0: Lorentzian’s amplitude

    • popt1: Lorentzian’s center

    • popt2: Lorentzian’s sigma

    • popt3: Lorentzian’s offset

qibocal.calibrations.characterization.qubit_spectroscopy.qubit_spectroscopy_flux(platform: qibolab.platforms.abstract.AbstractPlatform, qubits: dict, freq_width, freq_step, bias_width, bias_step, fluxlines, software_averages=1, points=10)#

Perform spectroscopy on the qubit modifying the bias applied in the flux control line. This routine works for multiqubit devices flux controlled.

Parameters
  • platform (AbstractPlatform) – Qibolab platform object

  • qubits (dict) – Dict of target Qubit objects to perform the action

  • freq_width (int) – Width frequency in HZ to perform the spectroscopy sweep

  • freq_step (int) – Step frequency in HZ for the spectroscopy sweep

  • bias_width (float) – Width bias in A for the flux bias sweep

  • bias_step (float) – Step bias in A for the flux bias sweep

  • fluxlines (list) – List of flux lines to use to perform the experiment. If it is set to “qubits”, it uses each of flux lines associated with the target qubits.

  • software_averages (int) – Number of executions of the routine for averaging results

  • points (int) – Save data results in a file every number of points

Returns

  • A DataUnits object with the raw data obtained for the fast and precision sweeps with the following keys

    • MSR[V]: Resonator signal voltage mesurement in volts

    • i[V]: Resonator signal voltage mesurement for the component I in volts

    • q[V]: Resonator signal voltage mesurement for the component Q in volts

    • phase[rad]: Resonator signal phase mesurement in radians

    • frequency[Hz]: Qubit drive frequency value in Hz

    • bias[V]: Current value in A applied to the flux line

    • qubit: The qubit being tested

    • fluxline: The fluxline being tested

    • iteration: The iteration number of the many determined by software_averages

  • A DataUnits object with the fitted data obtained with the following keys

    • drive_frequency: frequency

    • peak_voltage: peak voltage

    • popt0: Lorentzian’s amplitude

    • popt1: Lorentzian’s center

    • popt2: Lorentzian’s sigma

    • popt3: Lorentzian’s offset

    • qubit: The qubit being tested

Rabi oscillations#

Ramsey#

qibocal.calibrations.characterization.ramsey.ramsey_frequency_detuned(platform: qibolab.platforms.abstract.AbstractPlatform, qubits: dict, delay_between_pulses_start, delay_between_pulses_end, delay_between_pulses_step, n_osc, software_averages=1, points=10)#

We introduce an artificial detune over the drive pulse frequency to be off-resonance and, after fitting, determine two of the qubit’s properties: Ramsey or detuning frequency and T2. If our drive pulse is well calibrated, the Ramsey experiment without artificial detuning results in an exponential that describes T2, but we can not refine the detuning frequency.

In this method we iterate over diferent maximum time delays between the drive pulses of the ramsey sequence in order to refine the fitted detuning frequency and T2.

Ramsey sequence: Rx(pi/2) - wait time - Rx(pi/2) - ReadOut

Parameters
  • platform (AbstractPlatform) – Qibolab platform object

  • qubits (dict) – Dict of target Qubit objects to perform the action

  • delay_between_pulses_start (int) – Initial time delay between drive pulses in the Ramsey sequence

  • delay_between_pulses_end (list) – List of maximum time delays between drive pulses in the Ramsey sequence

  • delay_between_pulses_step (int) – Scan range step for the time delay between drive pulses in the Ramsey sequence

  • software_averages (int) – Number of executions of the routine for averaging results

  • points (int) – Save data results in a file every number of points

Returns

  • A DataUnits object with the raw data obtained for the fast and precision sweeps with the following keys

    • MSR[V]: Resonator signal voltage mesurement in volts

    • i[V]: Resonator signal voltage mesurement for the component I in volts

    • q[V]: Resonator signal voltage mesurement for the component Q in volts

    • phase[rad]: Resonator signal phase mesurement in radians

    • wait[ns]: Wait time used in the current Ramsey execution

    • t_max[ns]: Maximum time delay between drive pulses in the Ramsey sequence

    • qubit: The qubit being tested

    • iteration: The iteration number of the many determined by software_averages

  • A DataUnits object with the fitted data obtained with the following keys

    • delta_frequency: Physical detunning of the actual qubit frequency

    • drive_frequency:

    • T2: New qubit frequency after correcting the actual qubit frequency with the detunning calculated

    • popt0: offset

    • popt1: oscillation amplitude

    • popt2: frequency

    • popt3: phase

    • popt4: T2

    • qubit: The qubit being tested

qibocal.calibrations.characterization.ramsey.ramsey(platform: qibolab.platforms.abstract.AbstractPlatform, qubits: dict, delay_between_pulses_start, delay_between_pulses_end, delay_between_pulses_step, software_averages=1, points=10)#

The purpose of the Ramsey experiment is to determine two of the qubit’s properties: Ramsey or detuning frequency and T2.

Ramsey sequence: Rx(pi/2) - wait time - Rx(pi/2) - ReadOut

Parameters
  • platform (AbstractPlatform) – Qibolab platform object

  • qubits (dict) – Dict of target Qubit objects to perform the action

  • delay_between_pulses_start (int) – Initial time delay between drive pulses in the Ramsey sequence

  • delay_between_pulses_end (list) – Maximum time delay between drive pulses in the Ramsey sequence

  • delay_between_pulses_step (int) – Scan range step for the time delay between drive pulses in the Ramsey sequence

  • software_averages (int) – Number of executions of the routine for averaging results

  • points (int) – Save data results in a file every number of points

Returns

  • A DataUnits object with the raw data obtained for the fast and precision sweeps with the following keys

    • MSR[V]: Resonator signal voltage mesurement in volts

    • i[V]: Resonator signal voltage mesurement for the component I in volts

    • q[V]: Resonator signal voltage mesurement for the component Q in volts

    • phase[rad]: Resonator signal phase mesurement in radians

    • wait[ns]: Wait time used in the current Ramsey execution

    • t_max[ns]: Maximum time delay between drive pulses in the Ramsey sequence

    • qubit: The qubit being tested

    • iteration: The iteration number of the many determined by software_averages

  • A DataUnits object with the fitted data obtained with the following keys

    • delta_frequency: Physical detunning of the actual qubit frequency

    • drive_frequency:

    • T2: New qubit frequency after correcting the actual qubit frequency with the detunning calculated

    • popt0: offset

    • popt1: oscillation amplitude

    • popt2: frequency

    • popt3: phase

    • popt4: T2

    • qubit: The qubit being tested

T1#

qibocal.calibrations.characterization.t1.t1(platform: qibolab.platforms.abstract.AbstractPlatform, qubits: list, delay_before_readout_start, delay_before_readout_end, delay_before_readout_step, software_averages=1, points=10)#

In a T1 experiment, we measure an excited qubit after a delay. Due to decoherence processes (e.g. amplitude damping channel), it is possible that, at the time of measurement, after the delay, the qubit will not be excited anymore. The larger the delay time is, the more likely is the qubit to fall to the ground state. The goal of the experiment is to characterize the decay rate of the qubit towards the ground state.

Parameters
  • platform (AbstractPlatform) – Qibolab platform object

  • qubits (list) – List of target qubits to perform the action

  • delay_before_readout_start (int) – Initial time delay before ReadOut

  • delay_before_readout_end (list) – Maximum time delay before ReadOut

  • delay_before_readout_step (int) – Scan range step for the delay before ReadOut

  • software_averages (int) – Number of executions of the routine for averaging results

  • points (int) – Save data results in a file every number of points

Returns

  • A DataUnits object with the raw data obtained for the fast and precision sweeps with the following keys

    • MSR[V]: Resonator signal voltage mesurement in volts

    • i[V]: Resonator signal voltage mesurement for the component I in volts

    • q[V]: Resonator signal voltage mesurement for the component Q in volts

    • phase[rad]: Resonator signal phase mesurement in radians

    • wait[ns]: Delay before ReadOut used in the current execution

    • qubit: The qubit being tested

    • iteration: The iteration number of the many determined by software_averages

  • A DataUnits object with the fitted data obtained with the following keys

    • labels[0]: T1

    • popt0: p0

    • popt1: p1

    • popt2: p2

    • qubit: The qubit being tested

Flipping#

qibocal.calibrations.characterization.flipping.flipping(platform: qibolab.platforms.abstract.AbstractPlatform, qubits: dict, nflips_max, nflips_step, software_averages=1, points=10)#

The flipping experiment correct the delta amplitude in the qubit drive pulse. We measure a qubit after applying a Rx(pi/2) and N flips (Rx(pi) rotations). After fitting we can obtain the delta amplitude to refine pi pulses.

Parameters
  • platform (AbstractPlatform) – Qibolab platform object

  • qubits (dict) – Dict of target Qubit objects to perform the action

  • nflips_max (int) – Maximum number of flips introduced in each sequence

  • nflips_step (int) – Scan range step for the number of flippings

  • software_averages (int) – Number of executions of the routine for averaging results

  • points (int) – Save data results in a file every number of points

Returns

  • A DataUnits object with the raw data obtained for the fast and precision sweeps with the following keys

    • MSR[V]: Resonator signal voltage mesurement in volts

    • i[V]: Resonator signal voltage mesurement for the component I in volts

    • q[V]: Resonator signal voltage mesurement for the component Q in volts

    • phase[rad]: Resonator signal phase mesurement in radians

    • flips[dimensionless]: Number of flips applied in the current execution

    • qubit: The qubit being tested

    • iteration: The iteration number of the many determined by software_averages

  • A DataUnits object with the fitted data obtained with the following keys

    • amplitude_correction_factor: Pi pulse correction factor

    • corrected_amplitude: Corrected pi pulse amplitude

    • popt0: p0

    • popt1: p1

    • popt2: p2

    • popt3: p3

    • qubit: The qubit being tested

All-XY#

qibocal.calibrations.characterization.allXY.allXY(platform: qibolab.platforms.abstract.AbstractPlatform, qubits: dict, beta_param=None, software_averages=1, points=10)#

The AllXY experiment is a simple test of the calibration of single qubit gatesThe qubit (initialized in the |0> state) is subjected to two back-to-back single-qubit gates and measured. In each round, we run 21 different gate pairs: ideally, the first 5 return the qubit to |0>, the next 12 drive it to superposition state, and the last 4 put the qubit in |1> state.

Parameters
  • platform (AbstractPlatform) – Qibolab platform object

  • qubits (dict) – Dict of target Qubit objects to perform the action

  • beta_param (float) – Drag pi pulse coefficient. If none, teh default shape defined in the runcard will be used.

  • software_averages (int) – Number of executions of the routine for averaging results

  • points (int) – Save data results in a file every number of points

Returns

A DataUnits object with the raw data obtained for the fast and precision sweeps with the following keys

  • MSR[V]: Difference between resonator signal voltage mesurement in volts from sequence 1 and 2

  • i[V]: Difference between resonator signal voltage mesurement for the component I in volts from sequence 1 and 2

  • q[V]: Difference between resonator signal voltage mesurement for the component Q in volts from sequence 1 and 2

  • phase[rad]: Difference between resonator signal phase mesurement in radians from sequence 1 and 2

  • probability[dimensionless]: Probability of being in |0> state

  • gateNumber[dimensionless]: Gate number applied from the list of gates

  • qubit: The qubit being tested

  • iteration: The iteration number of the many determined by software_averages

qibocal.calibrations.characterization.allXY.allXY_drag_pulse_tuning(platform: qibolab.platforms.abstract.AbstractPlatform, qubits: dict, beta_start, beta_end, beta_step, software_averages=1, points=10)#

The AllXY experiment is a simple test of the calibration of single qubit gatesThe qubit (initialized in the |0> state) is subjected to two back-to-back single-qubit gates and measured. In each round, we run 21 different gate pairs: ideally, the first 5 return the qubit to |0>, the next 12 drive it to superposition state, and the last 4 put the qubit in |1> state.

The AllXY iteration method allows the user to execute iteratively the list of gates playing with the drag pulse shape in order to find the optimal drag pulse coefficient for pi pulses.

Parameters
  • platform (AbstractPlatform) – Qibolab platform object

  • qubits (dict) – Dict of target Qubit objects to perform the action

  • beta_start (float) – Initial drag pulse beta parameter

  • beta_end (float) – Maximum drag pulse beta parameter

  • beta_step (float) – Scan range step for the drag pulse beta parameter

  • software_averages (int) – Number of executions of the routine for averaging results

  • points (int) – Save data results in a file every number of points

Returns

A DataUnits object with the raw data obtained for the fast and precision sweeps with the following keys

  • MSR[V]: Difference between resonator signal voltage mesurement in volts from sequence 1 and 2

  • i[V]: Difference between resonator signal voltage mesurement for the component I in volts from sequence 1 and 2

  • q[V]: Difference between resonator signal voltage mesurement for the component Q in volts from sequence 1 and 2

  • phase[rad]: Difference between resonator signal phase mesurement in radians from sequence 1 and 2

  • probability[dimensionless]: Probability of being in |0> state

  • gateNumber[dimensionless]: Gate number applied from the list of gates

  • beta_param[dimensionless]: Beta paramter applied in the current execution

  • qubit: The qubit being tested

  • iteration: The iteration number of the many determined by software_averages

qibocal.calibrations.characterization.allXY.drag_pulse_tuning(platform: qibolab.platforms.abstract.AbstractPlatform, qubits: dict, beta_start, beta_end, beta_step, software_averages=1, points=10)#

In this experiment, we apply two sequences in a given qubit: Rx(pi/2) - Ry(pi) and Ry(pi) - Rx(pi/2) for a range of different beta parameter values. After fitting, we obtain the best coefficient value for a pi pulse with drag shape.

Parameters
  • platform (AbstractPlatform) – Qibolab platform object

  • qubits (dict) – Dict of target Qubit objects to perform the action

  • beta_start (float) – Initial drag pulse beta parameter

  • beta_end (float) – Maximum drag pulse beta parameter

  • beta_step (float) – Scan range step for the drag pulse beta parameter

  • software_averages (int) – Number of executions of the routine for averaging results

  • points (int) – Save data results in a file every number of points

Returns

  • A DataUnits object with the raw data obtained for the fast and precision sweeps with the following keys

    • MSR[V]: Difference between resonator signal voltage mesurement in volts from sequence 1 and 2

    • i[V]: Difference between resonator signal voltage mesurement for the component I in volts from sequence 1 and 2

    • q[V]: Difference between resonator signal voltage mesurement for the component Q in volts from sequence 1 and 2

    • phase[rad]: Difference between resonator signal phase mesurement in radians from sequence 1 and 2

    • beta_param[dimensionless]: Optimal drag coefficient

    • qubit: The qubit being tested

    • iteration: The iteration number of the many determined by software_averages

  • A DataUnits object with the fitted data obtained with the following keys

    • optimal_beta_param: Best drag pulse coefficent

    • popt0: offset

    • popt1: oscillation amplitude

    • popt2: period

    • popt3: phase

    • qubit: The qubit being tested

State calibration#

qibocal.calibrations.characterization.calibrate_qubit_states.calibrate_qubit_states(platform: qibolab.platforms.abstract.AbstractPlatform, qubits: dict, nshots, points=10)#

Method which implements the state’s calibration of a chosen qubit. Two analogous tests are performed for calibrate the ground state and the excited state of the oscillator. The subscripts exc and gnd will represent the excited state |1> and the ground state |0>.

Parameters
  • platform (qibolab.platforms.abstract.AbstractPlatform) – custom abstract platform on which we perform the calibration.

  • qubits (dict) – Dict of target Qubit objects to perform the action

  • nshots (int) – number of times the pulse sequence will be repeated.

  • software_averages (int) – Number of executions of the routine for averaging results

  • points (int) – Save data results in a file every number of points

Returns

A DataUnits object with the raw data obtained for the fast and precision sweeps with the following keys

  • MSR[V]: Resonator signal voltage mesurement in volts

  • i[V]: Resonator signal voltage mesurement for the component I in volts

  • q[V]: Resonator signal voltage mesurement for the component Q in volts

  • phase[rad]: Resonator signal phase mesurement in radians

  • iteration[dimensionless]: Execution number

  • qubit: The qubit being tested

  • iteration: The iteration number of the many determined by software_averages

Data structure#

In qibocal there are two different objects to manipulate data: qibocal.data.DataUnits and qibocal.data.Data.

qibocal.data.DataUnits is used to store physical related quantities, such as voltages and frequencies. It is a wrapper to a pandas.DataFrame where the units of measure for each quantity are implemented using pint.

qibocal.data.Data can be used manipulate non-physical quantities.

They provide different formats for storing data including pickle and csv.

class qibocal.data.DataUnits(name=None, quantities=None, options=None)#

Class to store the data measured during the calibration routines. It is a wrapper to a pandas DataFrame with units of measure from the Pint library.

Parameters
  • quantities (dict) – dictionary containing additional quantities that the user may save other than the pulse sequence output. The keys are the name of the quantities and the corresponding values are the units of measure.

  • options (list) – list containing additional values to be saved.

property df#

Dataframe attribute.

load_data_from_dict(data: dict)#

Load dataframe from dictionary.

Parameters

data (dict) – dictionary containing the data to be loaded. Every key should have the following form: <name>[<unit>].

add_data_from_dict(data: dict)#

Add the contents of a dictionary to the data of the dataframe. :param df: dictionary containing the data to be added. :type df: dict

add(data)#

Add a row to DataUnits.

Parameters

data (dict) – dictionary containing the data to be added. Every key should have the following form: <name>[<unit>].

get_values(key, unit=None)#

Get values of a quantity in specified units.

Parameters
  • quantity (str) – Quantity to get the values of.

  • unit (str) – Unit of the returned values.

Returns

pd.Series with the quantity values in the given units.

classmethod load_data(folder, subfolder, routine, data_format, name)#

Load data from specific format.

Parameters
  • folder (path) – path to the output folder from which the data will be loaded

  • subfolder (path) – subfolder name

  • routine (str) – calibration routine data to be loaded

  • data_format (str) – data format. Possible choices are ‘csv’ and ‘pickle’

  • name (str) – file’s name without extension

Returns

dataset object with the loaded data.

Return type

data (DataUnits)

Example

see the method load_data in class Data

to_csv(path)#

Save data in csv file.

Parameters

path (str) – Path containing output folder.

Example

import os
from qibocal.data import DataUnits
import numpy as np
data = DataUnits()
length = 3
folder = "foo"
# create directory
if not os.path.isdir(folder):
    os.mkdir(folder)
# generate random dataset
for l in range(length):
    msr, i, q, phase = np.random.rand(4)
    pulse_sequence_result = {
        "MSR[V]": msr,
        "i[V]": i,
        "q[V]": q,
        "phase[rad]]": phase,
    }
    data.add({**pulse_sequence_result})
data.to_csv(folder)
class qibocal.data.Data(name=None, quantities=None)#

Class to store the data obtained from calibration routines. It is a wrapper to a pandas DataFrame.

Parameters

quantities (list) – list of quantities to be saved.

property df#

Dataframe attribute.

load_data_from_dict(data: dict)#

Set df attribute.

Parameters

df (dict) – dictionary containing the data to be added.

Example

from qibocal.data import Data
data = Data()
test = {
    "int": [1, 2, 3],
    "float": [3.0, 4.0, 5.0],
    "string": ["one", "two", "three"],
    "bool": [True, False, True],
}
data.load_data_from_dict(test)
print(data.df)
  int float string   bool
0   1   3.0    one   True
1   2   4.0    two  False
2   3   5.0  three   True
add(data)#

Add a row to data.

Parameters

data (dict) – dictionary containing the data to be added. Every key should have the following form: <name>[<unit>].

get_values(quantity)#

Get values of a quantity.

Parameters

quantity (str) – Quantity to get the values of.

Returns

pd.Series with the quantity values in the given units.

classmethod load_data(folder, subfolder, routine, data_format, name)#

Load data from specific format.

Parameters
  • folder (path) – path to the output folder from which the data will be loaded

  • subfolder (path) – subfolder name

  • routine (str) – calibration routine data to be loaded

  • data_format (str) – data format. Possible choices are ‘csv’ and ‘pickle’

  • name (str) – file’s name without extension

Returns

data object with the loaded data.

Return type

data (Data)

Example

from qibocal.data import Data
import os
folder = "test_folder/test_subfolder/test_routine"
length = 3
if not os.path.isdir(folder):
    os.makedirs(folder)
# create a dataset
data = Data()
for i in range(length):
    data.add(
        {
            "int": int(i),
            "float": float(i),
            "string": str(f"hello{i}"),
            "bool": bool(i),
        }
    )
# save the dataset in csv format
data.to_csv(folder)
# upload the dataset
data_upload = Data().load_data("test_folder", "test_subfolder", "test_routine", "csv", "data")
to_csv(path)#

Save data in csv file.

Parameters

path (str) – Path containing output folder.

Example

import shutil
from qibocal.data import Data
import numpy as np
import os
data = Data()
length = 3
folder = "foo"
# create directory
if not os.path.isdir(folder):
    os.mkdir(folder)
# generate a dataset
data = Data()
for i in range(length):
    data.add(
        {
            "int": int(i),
            "float": float(i),
            "string": str(f"hello{i}"),
            "bool": bool(i),
        }
    )
data.to_csv(folder)

Fitting functions#

Qibocal offers routine-specific method for post-processing analysis of the data generated by the different Calibration routines.

Routine-specific method for post-processing data acquired.

qibocal.fitting.methods.lorentzian_fit(data, x, y, qubits, resonator_type, labels, fit_file_name=None)#

Fitting routine for resonator/qubit spectroscopy. The used model is

\[y = \frac{A}{\pi} \Big[ \frac{\sigma}{(f-f_0)^2 + \sigma^2} \Big] + y_0.\]

Args:

Parameters
  • data (DataUnits) – dataset for the fit

  • x (str) – name of the input values for the Lorentzian model

  • y (str) – name of the output values for the Lorentzian model

  • qubits (list) – A list with the IDs of the qubits

  • resonator_type (str) – the type of readout resonator [‘3D’, ‘2D’]

  • labels (list of str) –

    list containing the lables of the quantities computed by this fitting method.

    • When using resonator_spectroscopy the expected labels are [readout_frequency, peak voltage], where readout_frequency is the estimated frequency of the resonator, and peak_voltage the peak of the Lorentzian

    • when using qubit_spectroscopy the expected labels are [drive_frequency, peak voltage], where drive_frequency is the estimated frequency of the qubit

  • fit_file_name (str) – file name, None is the default value.

Returns

A Data object with the following keys

  • labels[0]: peak voltage

  • labels[1]: frequency

  • popt0: Lorentzian’s amplitude

  • popt1: Lorentzian’s center

  • popt2: Lorentzian’s sigma

  • popt3: Lorentzian’s offset

  • qubit: The qubit being tested

Example

In the code below, a noisy Lorentzian dataset is implemented and then the lorentzian_fit method is applied.

import numpy as np
from qibocal.data import DataUnits
from qibocal.fitting.methods import lorentzian_fit
from qibocal.fitting.utils import lorenzian
import matplotlib.pyplot as plt

name = "test"
nqubits = 1
label = "drive_frequency"
amplitude = -1
center = 2
sigma = 3
offset = 4

# generate noisy Lorentzian

x = np.linspace(center - 10, center + 10, 100)
noisy_lorentzian = (
    lorenzian(x, amplitude, center, sigma, offset)
    + amplitude * np.random.randn(100) * 0.5e-2
)

# Initialize data and evaluate the fit

data = DataUnits(quantities={"frequency": "Hz"}, options=["qubit", "iteration"])

mydict = {"frequency[Hz]": x, "MSR[V]": noisy_lorentzian, "qubit": 0, "iteration" : 0}

data.load_data_from_dict(mydict)

fit = lorentzian_fit(
    data,
    "frequency[Hz]",
    "MSR[V]",
    qubits = [0],
    resonator_type='3D',
    labels=[label, "peak_voltage", "intermediate_freq"],
    fit_file_name=name,
)

fit_params = [fit.get_values(f"popt{i}") for i in range(4)]
fit_data = lorenzian(x,*fit_params)

# Plot

#fig = plt.figure(figsize = (10,5))
#plt.scatter(x,noisy_lorentzian,label="data",s=10,color = 'darkblue',alpha = 0.9)
#plt.plot(x,fit_data, label = "fit", color = 'violet', linewidth = 3, alpha = 0.4)
#plt.xlabel('frequency (Hz)')
#plt.ylabel('MSR (Volt)')
#plt.legend()
#plt.title("Data fit")
#plt.grid()
#plt.show()

The following plot shows the resulting output:

../_images/lorentzian_fit_result.png
qibocal.fitting.methods.rabi_fit(data, x, y, qubits, resonator_type, labels)#

Fitting routine for Rabi experiment. The used model is

\[y = p_0 + p_1 sin(2 \pi p_2 x + p_3) e^{-x p_4}.\]
Parameters
  • data (DataUnits) – dataset for the fit

  • x (str) – name of the input values for the Rabi model

  • y (str) – name of the output values for the Rabi model

  • qubits (list) – A list with the IDs of the qubits

  • resonator_type (str) – the type of readout resonator [‘3D’, ‘2D’]

  • labels (list of str) – list containing the lables of the quantities computed by this fitting method.

Returns

A Data object with the following keys

  • popt0: offset

  • popt1: oscillation amplitude

  • popt2: frequency

  • popt3: phase

  • popt4: T2

  • labels[0]: pulse parameter

  • labels[1]: pulse’s maximum voltage

  • qubit: The qubit being tested

qibocal.fitting.methods.ramsey_fit(data, x, y, qubits, resonator_type, qubit_freqs, sampling_rate, offset_freq, labels)#

Fitting routine for Ramsey experiment. The used model is

\[y = p_0 + p_1 sin \Big(p_2 x + p_3 \Big) e^{-x p_4}.\]
Parameters
  • data (DataUnits) – dataset for the fit

  • x (str) – name of the input values for the Ramsey model

  • y (str) – name of the output values for the Ramsey model

  • qubits (list) – A list with the IDs of the qubits

  • qubits_freq (float) – frequency of the qubit

  • sampling_rate (float) – Platform sampling rate

  • offset_freq (float) – Total qubit frequency offset. It contains the artificial detunning applied by the experimentalist + the inherent offset in the actual qubit frequency stored in the runcard.

  • labels (list of str) – list containing the lables of the quantities computed by this fitting method.

Returns

A Data object with the following keys

  • popt0: offset

  • popt1: oscillation amplitude

  • popt2: frequency

  • popt3: phase

  • popt4: T2

  • labels[0]: Physical detunning of the actual qubit frequency

  • labels[1]: New qubit frequency after correcting the actual qubit frequency with the detunning calculated (labels[0])

  • labels[2]: T2

  • qubit: The qubit being tested

qibocal.fitting.methods.t1_fit(data, x, y, qubits, resonator_type, labels)#

Fitting routine for T1 experiment. The used model is

\[y = p_0-p_1 e^{-x p_2}.\]
Parameters
  • data (DataUnits) – dataset for the fit

  • x (str) – name of the input values for the T1 model

  • y (str) – name of the output values for the T1 model

  • qubit (int) – ID qubit number

  • nqubits (int) – total number of qubits

  • labels (list of str) – list containing the lables of the quantities computed by this fitting method.

Returns

A Data object with the following keys

  • popt0: p0

  • popt1: p1

  • popt2: p2

  • labels[0]: T1.

qibocal.fitting.methods.flipping_fit(data, x, y, qubits, resonator_type, pi_pulse_amplitudes, labels)#

Fitting routine for T1 experiment. The used model is

\[y = p_0 sin\Big(\frac{2 \pi x}{p_2} + p_3\Big).\]
Parameters
  • data (DataUnits) – dataset for the fit

  • x (str) – name of the input values for the flipping model

  • y (str) – name of the output values for the flipping model

  • qubit (int) – ID qubit number

  • nqubits (int) – total number of qubits

  • niter (int) – Number of times of the flipping sequence applied to the qubit

  • pi_pulse_amplitudes (list) – list of corrected pi pulse amplitude

  • labels (list of str) – list containing the lables of the quantities computed by this fitting method.

Returns

A Data object with the following keys

  • popt0: p0

  • popt1: p1

  • popt2: p2

  • popt3: p3

  • labels[0]: delta amplitude

  • labels[1]: corrected amplitude

qibocal.fitting.methods.drag_tuning_fit(data: qibocal.data.Data, x, y, qubits, labels)#

Fitting routine for drag tunning. The used model is

\[y = p_1 cos \Big(\frac{2 \pi x}{p_2} + p_3 \Big) + p_0.\]
Parameters
  • data (DataUnits) – dataset for the fit

  • x (str) – name of the input values for the model

  • y (str) – name of the output values for the model

  • qubit (int) – ID qubit number

  • labels (list of str) – list containing the lables of the quantities computed by this fitting method.

Returns

A Data object with the following keys

  • popt0: offset

  • popt1: oscillation amplitude

  • popt2: period

  • popt3: phase

  • labels[0]: optimal beta.

qibocal.fitting.methods.res_spectroscopy_flux_fit(data, x, y, qubit, fluxline, params_fit)#
Fit frequency as a function of current for the flux resonator spectroscopy

Args: data (DataUnits): Data file with information on the feature response at each current point. x (str): Column of the data file associated to x-axis. y (str): Column of the data file associated to y-axis. qubit (int): qubit coupled to the resonator that we are probing. fluxline (int): id of the current line used for the experiment. params_fit (list): List of parameters for the fit. [freq_rh, g, Ec, Ej].

freq_rh is the resonator frequency at high power and g in the readout coupling. If Ec and Ej are missing, the fit is valid in the transmon limit and if they are indicated, contains the next-order correction.

Returns

Data file with labels and fit parameters.

Return type

data_fit (Data)

qibocal.fitting.methods.res_spectroscopy_flux_matrix(folder, fluxlines)#
Calculation of the resonator flux matrix, Mf.

curr = Mf*freq + offset_c. Mf = Mc^-1, offset_c = -Mc^-1 * offset_f freq = Mc*curr + offset_f

Args: folder (str): Folder where the data files with the experimental and fit data are. fluxlines (list): ids of the current line used for the experiment.

Returns

Data file with len(fluxlines)+1 columns that contains the flux matrix (Mf) and

offset (offset_c) in the last column.

Return type

data (Data)

qibocal.fitting.methods.spin_echo_fit(data, x, y, qubits, resonator_type, labels)#
qibocal.fitting.methods.calibrate_qubit_states_fit(data, x, y, nshots, qubits)#

Gate set characterization#

Abstract and Basic methods#

class qibocal.calibrations.niGSC.basics.experiment.Experiment(circuitfactory: Iterable | None, data: Iterable | None = None, nshots: int | None = 128, noise_model: NoiseModel | None = None)#

Bases: object

Experiment objects which holds an iterable circuit factory along with a simple data structure associated to each circuit.

Parameters
  • circuitfactory (Iterable) – Gives a certain amount of circuits when iterated over.

  • nshots (int) – For execution of circuit, indicates how many shots.

  • data (list) – If filled, data can be used to specifying parameters while executing a circuit or deciding how to process results. It is used to store all relevant data.

property noise_model#
property dataframe: pandas.core.frame.DataFrame#
classmethod load(path: str) qibocal.calibrations.niGSC.basics.experiment.Experiment#

Creates an experiment object with data and if possible with circuits.

Parameters

path (str) – The directory from where the object should be restored.

Returns

The object with data (and circuitfactory).

Return type

Experiment

save(path: str | None = None) str#

Creates a path if None given and pickles relevant data from self.data and if self.circuitfactory is a list that one too.

Returns

The path of stored experiment.

Return type

(str)

extract(output_key: str, groupby_key: str = '', agg_type: str | Callable = '') np.ndarray | tuple[np.ndarray, np.ndarray]#

Return wanted values from self.data via the dataframe property.

If groupby_key given, aggregate the dataframe, extract the data by which the frame was grouped, what was calculated given the agg_type parameter. Two arrays are returned then, the group values and the grouped (aggregated) data. If no agg_type given use a linear function. If groupby_key not given, only return the extracted data from given key.

Parameters
  • output_key (str) – Key name of the wanted output.

  • groupby_key (str) – If given, group with that key name.

  • agg_type (str) – If given, calcuted aggregation function on groups.

Returns

Either one or two np.ndarrays. If no grouping wanted, just the data. If grouping wanted, the values after which where grouped and the grouped data.

prebuild() None#

Converts the attribute circuitfactory which is in general an iterable into a list.

perform(sequential_task: Callable[[qibo.models.circuit.Circuit, dict], dict]) None#

Takes a given function, checks the status of attribute circuitfactory and data and executes the sequential function row by row altering the self.data attribute.

Either self.circuitfactory or self.data cannot be None and if not None they have to have the right length.

Parameters

sequential_task (callable[[Circuit, dict], dict]) – A function applied row by row alterting each datarow.

execute(circuit: qibo.models.circuit.Circuit, datarow: dict) dict#

Executes a circuit, returns the single shot results in a dict.

Parameters
  • circuit (Circuit) – Will be executed, has to return samples.

  • datarow (dict) – Dictionary with parameters for execution and immediate postprocessing information.

In this python script the fitting methods for the gate set protocols are defined. They consist mostly of exponential decay fitting.

qibocal.calibrations.niGSC.basics.fitting.exp1_func(x: numpy.ndarray, A: float, f: float) numpy.ndarray#

Return \(A\cdot f^x\) where x is an np.ndarray and A, f are floats

qibocal.calibrations.niGSC.basics.fitting.exp1B_func(x: numpy.ndarray, A: float, f: float, B: float) numpy.ndarray#

Return \(A\cdot f^x+B\) where x is an np.ndarray and A, f, B are floats

qibocal.calibrations.niGSC.basics.fitting.exp2_func(x: numpy.ndarray, A1: float, A2: float, f1: float, f2: float) numpy.ndarray#

Return \(A_1\cdot f_1^x+A_2\cdot f_2^x\) where x is an np.ndarray and A1, f1, A2, f2 are floats. There is no linear offsett B.

qibocal.calibrations.niGSC.basics.fitting.esprit(xdata: numpy.ndarray, ydata: numpy.ndarray, num_decays: int, hankel_dim: Optional[int] = None) numpy.ndarray#

Implements the ESPRIT algorithm for peak detection.

Parameters
  • xdata (np.ndarray) – Labels of data. Has to be equally spaced.

  • ydata (np.ndarray) – The data where multiple decays are fitted in.

  • num_decays (int) – How many decays should be fitted.

  • hankel_dim (int | None, optional) – The Hankel dimension. Defaults to None.

Returns

The decay parameters.

Return type

np.ndarray

Raises

ValueError – When the x-labels are not equally spaced the algorithm does not work.

qibocal.calibrations.niGSC.basics.fitting.fit_exp1B_func(xdata: Union[numpy.ndarray, list], ydata: Union[numpy.ndarray, list], **kwargs) Tuple[tuple, tuple]#

Calculate an single exponential A*p^m+B fit to the given ydata.

Parameters
  • xdata (Union[np.ndarray, list]) – The x-labels.

  • ydata (Union[np.ndarray, list]) – The data to be fitted.

Returns

The fitting parameters (A, p, B) and the estimated error

(A_err, p_err, B_err)

Return type

Tuple[tuple, tuple]

qibocal.calibrations.niGSC.basics.fitting.fit_exp1_func(xdata: Union[numpy.ndarray, list], ydata: Union[numpy.ndarray, list], **kwargs) Tuple[tuple, tuple]#

Calculate an single exponential A*p^m fit to the given ydata, no linear offset.

Parameters
  • xdata (Union[np.ndarray, list]) – The x-labels.

  • ydata (Union[np.ndarray, list]) – The data to be fitted.

Returns

The fitting parameters (A, p) and the estimated error (A_err, p_err).

Return type

Tuple[tuple, tuple]

qibocal.calibrations.niGSC.basics.fitting.fit_exp2_func(xdata: Union[numpy.ndarray, list], ydata: Union[numpy.ndarray, list], **kwargs) Tuple[tuple, tuple]#

Calculate 2 exponentials on top of each other, fit to the given ydata.

No linear offset, the ESPRIT algorithm is used to identify the two exponential decays.

Parameters
  • xdata (Union[np.ndarray, list]) – The x-labels.

  • ydata (Union[np.ndarray, list]) – The data to be fitted

Returns

(A1, A2, f1, f2) with f* the decay parameters.

Return type

Tuple[tuple, tuple]

qibocal.calibrations.niGSC.basics.plot.plot_qq(folder: str, routine: str, qubit, format)#
class qibocal.calibrations.niGSC.basics.plot.Report#

Bases: object

Once initialized with the correct parameters an Report object can build reports to display results of a gate set characterization experiment.

build()#
qibocal.calibrations.niGSC.basics.plot.scatter_fit_fig(experiment: qibocal.calibrations.niGSC.basics.experiment.Experiment, df_aggr: pandas.core.frame.DataFrame, xlabel: str, index: str)#
qibocal.calibrations.niGSC.basics.utils.experiment_directory(name: str)#

Make the directory where the experiment will be stored.

qibocal.calibrations.niGSC.basics.utils.effective_depol(error_channel, **kwargs)#
qibocal.calibrations.niGSC.basics.utils.probabilities(allsamples: Union[list, numpy.ndarray]) numpy.ndarray#

Takes the given list/array (3-dimensional) of samples and returns probabilities for each possible state to occure.

The states for 4 qubits are order as follows: [(0, 0, 0, 0), (0, 0, 0, 1), (0, 0, 1, 0), (0, 0, 1, 1), (0, 1, 0, 0), (0, 1, 0, 1), (0, 1, 1, 0), (0, 1, 1, 1), (1, 0, 0, 0), (1, 0, 0, 1), (1, 0, 1, 0), (1, 0, 1, 1), (1, 1, 0, 0), (1, 1, 0, 1), (1, 1, 1, 0), (1, 1, 1, 1)]

Parameters

allsamples (Union[list, np.ndarray]) – The single shot samples, 3-dimensional.

Returns

Probability array of 2 dimension.

Return type

np.ndarray

qibocal.calibrations.niGSC.basics.utils.copy_circuit(circuit: qibo.models.circuit.Circuit)#
qibocal.calibrations.niGSC.basics.utils.gate_fidelity(eff_depol: float, primitive=False) float#

Returns the average gate fidelity given the effective depolarizing parameter for single qubits.

If primitive is True, divide by additional 1.875 as convetion in RB reporting. (The original reasoning was that Clifford gates are typically compiled with an average number of 1.875 Pi half pulses.)

Parameters
  • eff_depol (float) – The effective depolarizing parameter.

  • primitive (bool, optional) – If True, additionally divide by 1.875.

Returns

Average gate fidelity

Return type

float

Costum error models are build here for making it possible to pass strings describing the error model via runcards in qibocal. They inherit from the qibo noise NoiseModel module and are prebuild.

class qibocal.calibrations.niGSC.basics.noisemodels.PauliErrorOnUnitary(*args)#

Bases: qibo.noise.NoiseModel

Builds a noise model with pauli flips acting on unitaries.

If no initial parameters for px, py, pz are given, random values are drawn (in sum not bigger than 1).

build(*params)#
class qibocal.calibrations.niGSC.basics.noisemodels.PauliErrorOnX(*args)#

Bases: qibocal.calibrations.niGSC.basics.noisemodels.PauliErrorOnUnitary

Builds a noise model with pauli flips acting on X gates.

Inherited from PauliErrorOnUnitary but the build method is overwritten to act on X gates. If no initial parameters for px, py, pz are given, random values are drawn (in sum not bigger than 1).

build(*params)#

Standard RB#

Here the standard randomized benchmarking is implemented using the niGSC (non-interactive gate set characterization) architecture.

class qibocal.calibrations.niGSC.standardrb.ModuleFactory(nqubits: int, depths: list, qubits: list = [])#

Bases: qibocal.calibrations.niGSC.basics.circuitfactory.SingleCliffordsFactory

build_circuit(depth: int) qibo.models.circuit.Circuit#

Overwrites parent method. Add an inverse gate before the measurement.

Parameters

depth (int) – How many gate layers.

Returns

A circuit with single qubit Clifford gates with depth many layers and an inverse gate before the measurement gate.

Return type

(Circuit)

class qibocal.calibrations.niGSC.standardrb.ModuleExperiment(circuitfactory: Iterable, data: Iterable | None = None, nshots: int | None = None, noise_model: NoiseModel = None)#

Bases: qibocal.calibrations.niGSC.basics.experiment.Experiment

execute(circuit: qibo.models.circuit.Circuit, datarow: dict) dict#

Overwrites parent class method. Executes a circuit, adds the single shot results and depth of the circuit to the data row.

Parameters
  • circuit (Circuit) – Will be executed, has to return samples.

  • datarow (dict) – Dictionary with parameters for execution and immediate postprocessing information.

Return type

datarow (dict)

class qibocal.calibrations.niGSC.standardrb.moduleReport#

Bases: qibocal.calibrations.niGSC.basics.plot.Report

qibocal.calibrations.niGSC.standardrb.groundstate_probabilities(circuit: qibo.models.circuit.Circuit, datarow: dict) dict#

Calculates the ground state probability with data from single shot measurements.

Parameters
  • circuit (Circuit) – Not needed here.

  • datarow (dict) – The dictionary holding the samples.

Returns

The updated dictionary.

Return type

dict

qibocal.calibrations.niGSC.standardrb.post_processing_sequential(experiment: qibocal.calibrations.niGSC.basics.experiment.Experiment)#

Perform sequential tasks needed to analyze the experiment results.

The data is added/changed in the experiment, nothing has to be returned.

Parameters

experiment (Experiment) – Experiment object after execution of the experiment itself.

qibocal.calibrations.niGSC.standardrb.get_aggregational_data(experiment: qibocal.calibrations.niGSC.basics.experiment.Experiment) pandas.core.frame.DataFrame#

Computes aggregational tasks, fits data and stores the results in a data frame.

No data is manipulated in the experiment object.

Parameters

experiment (Experiment) – After sequential postprocessing of the experiment data.

Returns

The summarized data.

Return type

pd.DataFrame

qibocal.calibrations.niGSC.standardrb.build_report(experiment: qibocal.calibrations.niGSC.basics.experiment.Experiment, df_aggr: pandas.core.frame.DataFrame) plotly.graph_objs._figure.Figure#

Use data and information from experiment and the aggregated data data frame to build a report as plotly figure.

Parameters
  • experiment (Experiment) – After sequential postprocessing of the experiment data.

  • df_aggr (pd.DataFrame) – Normally build with get_aggregational_data function.

Returns

A plotly.graphical_object.Figure object.

Return type

(Figure)

Simultaneous Filtered RB#

class qibocal.calibrations.niGSC.simulfilteredrb.ModuleFactory(nqubits: int, depths: list, qubits: list = [])#

Bases: qibocal.calibrations.niGSC.basics.circuitfactory.SingleCliffordsFactory

class qibocal.calibrations.niGSC.simulfilteredrb.ModuleExperiment(circuitfactory: Iterable, data: Iterable | None = None, nshots: int | None = None, noise_model: NoiseModel = None)#

Bases: qibocal.calibrations.niGSC.basics.experiment.Experiment

Inherits from abstract Experiment class.

execute(circuit: qibo.models.circuit.Circuit, datarow: dict) dict#

Overwrited parents method. Executes a circuit, returns the single shot results and depth.

Parameters
  • circuit (Circuit) – Will be executed, has to return samples.

  • datarow (dict) – Dictionary with parameters for execution and immediate postprocessing information.

class qibocal.calibrations.niGSC.simulfilteredrb.moduleReport#

Bases: qibocal.calibrations.niGSC.basics.plot.Report

qibocal.calibrations.niGSC.simulfilteredrb.filter_function(circuit: qibo.models.circuit.Circuit, datarow: dict) dict#

Calculates the filtered signal for every crosstalk irrep.

Every irrep has a projector charactarized with a bit string \(\boldsymbol{\lambda}\in\mathbb{F}_2^N\) where \(N\) is the number of qubits. The experimental outcome for each qubit is denoted as \(\ket{i_k}\) with \(i_k=0, 1\) with \(d=2\).

\[f_{\boldsymbol{\lambda}}(i,g) = \frac{1}{2^{N-|\boldsymbol{\lambda}|}} \sum_{\mathbf b\in\mathbb F_2^N} (-1)^{|\boldsymbol{\lambda}\wedge\mathbf b|} \frac{1}{d^N}\left(\prod_{k=1}^N(d|\bra{i_k} U_{g_{(k)}} \ket{0}|^2)^{\lambda_k-\lambda_kb_k}\right)\]
Parameters
  • circuit (Circuit) – The circuit used to produce the samples in datarow.

  • datarow (dict) – Dictionary with samples produced by given circuit.

Returns

Filtered signals are stored additionally.

Return type

datarow (dict)

qibocal.calibrations.niGSC.simulfilteredrb.post_processing_sequential(experiment: qibocal.calibrations.niGSC.basics.experiment.Experiment)#

Perform sequential tasks needed to analyze the experiment results.

The data is added/changed in the experiment, nothign has to be returned.

Parameters

experiment (Experiment) – Experiment object after execution of the experiment itself.

qibocal.calibrations.niGSC.simulfilteredrb.get_aggregational_data(experiment: qibocal.calibrations.niGSC.basics.experiment.Experiment) pandas.core.frame.DataFrame#

Computes aggregational tasks, fits data and stores the results in a data frame.

No data is manipulated in the experiment object.

Parameters

experiment (Experiment) – After sequential postprocessing of the experiment data.

Returns

The summarized data.

Return type

pd.DataFrame

qibocal.calibrations.niGSC.simulfilteredrb.build_report(experiment: qibocal.calibrations.niGSC.basics.experiment.Experiment, df_aggr: pandas.core.frame.DataFrame) plotly.graph_objs._figure.Figure#

Use data and information from experiment and the aggregated data dataframe to build a reprot as plotly figure.

Parameters
  • experiment (Experiment) – After sequential postprocessing of the experiment data.

  • df_aggr (pd.DataFrame) – Normally build with get_aggregational_data function.

Returns

A plotly.graphical_object.Figure object.

Return type

(Figure)

X-ID RB#

This script implements an easy 1-qubit protocol with only X-gates and identities. It is a great example on how to write an own niGSC protocol. The single functions above have little descriptions for the purpose of that function and what is important to include.

  1. Step:

Define the two module specific classes which are used in defining and executing an experiment, the circuit factory and experiment class. They can also just inherit everything from another module.

  1. Step:

Write the sequential post processing functions.

  1. Step:

Write the aggregational post processing function.

  1. Step:

Write the function to build a report. When using the qq module, a plotly figure has to be returned.

class qibocal.calibrations.niGSC.XIdrb.ModuleFactory(nqubits: int, depths: list, qubits: list = [])#

Bases: qibocal.calibrations.niGSC.basics.circuitfactory.CircuitFactory

build_circuit(depth: int)#

Initiate a qibo.models.Circuit object and fill it with the wanted gates.

Which gates are wanted is encoded in self.gates_layer(). Add a measurement gate for every qubit.

Parameters

depth (int) – How many layers there are in the circuit.

Returns

the circuit with depth many layers.

Return type

Circuit

class qibocal.calibrations.niGSC.XIdrb.ModuleExperiment(circuitfactory: Iterable, data: Iterable | None = None, nshots: int | None = None, noise_model: NoiseModel = None)#

Bases: qibocal.calibrations.niGSC.basics.experiment.Experiment

execute(circuit: qibo.models.circuit.Circuit, datarow: dict) dict#

Executes a circuit, returns the single shot results in a dict.

Parameters
  • circuit (Circuit) – Will be executed, has to return samples.

  • datarow (dict) – Dictionary with parameters for execution and immediate postprocessing information.

class qibocal.calibrations.niGSC.XIdrb.moduleReport#

Bases: qibocal.calibrations.niGSC.basics.plot.Report

qibocal.calibrations.niGSC.XIdrb.filter_sign(circuit: qibo.models.circuit.Circuit, datarow: dict) dict#

Calculates the filtered signal for the XId.

\(n_X\) denotes the amount of \(X\) gates in the circuit with gates \(g\) and :math`i` the outcome which is either ground state \(0\) or exited state \(1\).

\[f_{\text{sign}}(i,g) = (-1)^{n_X\%2 + i}/2\]
Parameters
  • circuit (Circuit) – Not needed here.

  • datarow (dict) – The dictionary with the samples from executed circuits and amount of X gates in the executed circuit.

Returns

_description_

Return type

dict

qibocal.calibrations.niGSC.XIdrb.post_processing_sequential(experiment: qibocal.calibrations.niGSC.basics.experiment.Experiment)#

Perform sequential tasks needed to analyze the experiment results.

The data is added/changed in the experiment, nothing has to be returned.

Parameters

experiment (Experiment) – Experiment object after execution of the experiment itself.

qibocal.calibrations.niGSC.XIdrb.get_aggregational_data(experiment: qibocal.calibrations.niGSC.basics.experiment.Experiment) pandas.core.frame.DataFrame#

Computes aggregational tasks, fits data and stores the results in a data frame.

No data is manipulated in the experiment object.

Parameters

experiment (Experiment) – After sequential postprocessing of the experiment data.

Returns

The summarized data.

Return type

pd.DataFrame

qibocal.calibrations.niGSC.XIdrb.build_report(experiment: qibocal.calibrations.niGSC.basics.experiment.Experiment, df_aggr: pandas.core.frame.DataFrame) plotly.graph_objs._figure.Figure#

Use data and information from experiment and the aggregated data data frame to build a report as plotly figure.

Parameters
  • experiment (Experiment) – After sequential postprocessing of the experiment data.

  • df_aggr (pd.DataFrame) – Normally build with get_aggregational_data function.

Returns

A plotly.graphical_object.Figure object.

Return type

(Figure)