Note

This is the documentation for the current state of the development branch of Qiskit Experiments. The documentation or APIs here can change prior to being released.

BaseCalibrationExperiment

class BaseCalibrationExperiment(calibrations, *args, schedule_name=None, cal_parameter_name=None, updater=None, auto_update=True, **kwargs)[source]

A mixin class to create calibration experiments.

This abstract class extends a characterization experiment by turning it into a calibration experiment. Such experiments allow schedule management and updating of an instance of Calibrations. Furthermore, calibration experiments also specify an auto_update variable which, by default, is set to True. If this variable, is True then the run method of the experiment will call block_for_results() and update the calibrations instance once the backend has returned the data.

This mixin class inherits from the BaseExperiment class since calibration experiments by default call block_for_results(). This ensures that the next calibration experiment cannot proceed before the calibration parameters have been updated. Developers that wish to create a calibration experiment must subclass this base class and the characterization experiment. Therefore, developers that use this mixin class must pay special attention to their class definition. Indeed, the first class should be this mixin and the second class should be the characterization experiment since the run method from the mixin must be used. For example, the rough frequency calibration experiment is defined as

RoughFrequencyCal(BaseCalibrationExperiment, QubitSpectroscopy)

This ensures that the run method of RoughFrequencyCal will be the run method of the BaseCalibrationExperiment class. Furthermore, developers must explicitly call the __init__() methods of both parent classes.

Developers should strive to follow the convention that the first two arguments of a calibration experiment are the qubit(s) and the Calibrations instance.

If the experiment uses custom schedules, which is typically the case, then developers may chose to use the get_schedules() method when creating the circuits for the experiment. If get_schedules() is used then the developer must override at least one of the following methods used by get_schedules() to set the schedules:

  1. _get_schedules_from_options()

  2. _get_schedules_from_calibrations()

  3. _get_schedules_from_defaults()

These methods are called by get_schedules().

The update_calibrations() method is responsible for updating the values of the parameters stored in the instance of Calibrations. Here, BaseCalibrationExperiment provides a default update methodology that subclasses can override if a more elaborate behaviour is needed. At the minimum the developer must set the variable _updater which should have an update method and can be chosen from the library qiskit_experiments.calibration_management.update_library. See also qiskit_experiments.calibration_management.update_library.BaseUpdater. If no updater is specified the experiment will still run but no update of the calibrations will be performed.

Setup the calibration experiment object.

Parameters:
  • calibrations (Calibrations) – The calibrations instance with which to initialize the experiment.

  • args – Arguments for the characterization class.

  • schedule_name (Optional[str]) – An optional string which specifies the name of the schedule in the calibrations that will be updated.

  • cal_parameter_name (Optional[str]) – An optional string which specifies the name of the parameter in the calibrations that will be updated. If None is given then no parameter will be updated. Subclasses may assign default values in their init.

  • updater (Optional[Type[BaseUpdater]]) – The updater class that updates the Calibrations instance. Different calibration experiments will use different updaters.

  • auto_update (bool) – If set to True (the default) then the calibrations will automatically be updated once the experiment has run and block_for_results() will be called.

  • kwargs – Keyword arguments for the characterization class.

Attributes

BaseCalibrationExperiment.analysis

Return the analysis instance for the experiment.

BaseCalibrationExperiment.backend

Return the backend for the experiment

BaseCalibrationExperiment.calibrations

Return the calibrations.

BaseCalibrationExperiment.experiment_options

Return the options for the experiment.

BaseCalibrationExperiment.experiment_type

Return experiment type.

BaseCalibrationExperiment.num_qubits

Return the number of qubits for the experiment.

BaseCalibrationExperiment.physical_qubits

Return the device qubits for the experiment.

BaseCalibrationExperiment.run_options

Return options values for the experiment run() method.

BaseCalibrationExperiment.transpile_options

Return the transpiler options for the run() method.

Methods

BaseCalibrationExperiment.circuits()

Return a list of experiment circuits.

BaseCalibrationExperiment.config()

Return the config dataclass for this experiment

BaseCalibrationExperiment.copy()

Return a copy of the experiment

BaseCalibrationExperiment.from_config(config)

Initialize an experiment from experiment config

BaseCalibrationExperiment.run([backend, ...])

Run an experiment and perform analysis.

BaseCalibrationExperiment.set_experiment_options(...)

Set the experiment options.

BaseCalibrationExperiment.set_run_options(...)

Set options values for the experiment run() method.

BaseCalibrationExperiment.set_transpile_options(...)

Add a warning message.

BaseCalibrationExperiment.update_calibrations(...)

Update parameter values in the Calibrations instance.