Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
791 changes: 408 additions & 383 deletions docs/tutorials/calibrating_armonk.ipynb

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions qiskit_experiments/calibration_management/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
BackendCalibrations
Calibrations
Frequency
Drag

Managing Calibration Data
=========================
Expand Down Expand Up @@ -149,4 +148,4 @@
from .backend_calibrations import BackendCalibrations
from .base_calibration_experiment import BaseCalibrationExperiment

from .update_library import Frequency, Drag, FineDragUpdater
from .update_library import Frequency, FineDragUpdater
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,23 @@ def calibrations(self) -> Calibrations:
"""Return the calibrations."""
return self._cals

@classmethod
def _default_experiment_options(cls):
"""Default values for the fine amplitude calibration experiment.

Experiment Options:
result_index (int): The index of the result from which to update the calibrations.
group (str): The calibration group to which the parameter belongs. This will default
to the value "default".

"""
options = super()._default_experiment_options()

options.result_index = -1
options.group = "default"

return options

def update_calibrations(self, experiment_data: ExperimentData):
"""Update parameter values in the :class:`Calibrations` instance.

Expand Down
6 changes: 0 additions & 6 deletions qiskit_experiments/calibration_management/update_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,6 @@ def update(
)


class Drag(BaseUpdater):
"""Update drag parameters."""

__fit_parameter__ = "beta"


class FineDragUpdater(BaseUpdater):
"""Updater for the fine drag calibration."""

Expand Down
6 changes: 4 additions & 2 deletions qiskit_experiments/library/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
~characterization.EFSpectroscopy
~characterization.CrossResonanceHamiltonian
~characterization.EchoedCrossResonanceHamiltonian
~characterization.RoughDrag
~characterization.HalfAngle
~characterization.FineAmplitude
~characterization.FineXAmplitude
Expand All @@ -85,7 +86,7 @@ class instance to manage parameters and pulse schedules.
:template: autosummary/experiment.rst

~calibration.RoughFrequencyCal
~calibration.DragCal
~calibration.RoughDragCal
~calibration.FineDrag
~calibration.FineXDrag
~calibration.FineSXDrag
Expand All @@ -99,7 +100,7 @@ class instance to manage parameters and pulse schedules.

"""
from .calibration import (
DragCal,
RoughDragCal,
FineDrag,
FineXDrag,
FineSXDrag,
Expand All @@ -119,6 +120,7 @@ class instance to manage parameters and pulse schedules.
EFSpectroscopy,
CrossResonanceHamiltonian,
EchoedCrossResonanceHamiltonian,
RoughDrag,
Rabi,
EFRabi,
HalfAngle,
Expand Down
4 changes: 2 additions & 2 deletions qiskit_experiments/library/calibration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
:template: autosummary/experiment.rst

RoughFrequencyCal
DragCal
RoughDragCal
FineDrag
FineXDrag
FineSXDrag
Expand Down Expand Up @@ -70,7 +70,7 @@
"""

from .rough_frequency import RoughFrequencyCal
from .drag import DragCal
from .rough_drag_cal import RoughDragCal
from .fine_drag import FineDrag, FineXDrag, FineSXDrag
from .rough_amplitude_cal import RoughAmplitudeCal, RoughXSXAmplitudeCal, EFRoughXSXAmplitudeCal
from .fine_amplitude import FineAmplitudeCal, FineXAmplitudeCal, FineSXAmplitudeCal
Expand Down
4 changes: 0 additions & 4 deletions qiskit_experiments/library/calibration/fine_amplitude.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ def _default_experiment_options(cls):

"""
options = super()._default_experiment_options()

options.result_index = -1
options.target_angle = np.pi
options.group = "default"

return options

def _add_cal_metadata(self, circuits: List[QuantumCircuit]):
Expand Down
17 changes: 0 additions & 17 deletions qiskit_experiments/library/calibration/half_angle_cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,6 @@ def __init__(

self.set_transpile_options(inst_map=calibrations.default_inst_map)

@classmethod
def _default_experiment_options(cls):
"""Default values for the half angle calibration experiment.

Experiment Options:
result_index (int): The index of the result from which to update the calibrations.
group (str): The calibration group to which the parameter belongs. This will default
to the value "default".

"""
options = super()._default_experiment_options()

options.result_index = -1
options.group = "default"

return options

def _add_cal_metadata(self, circuits: List[QuantumCircuit]):
"""Add metadata to the circuit to make the experiment data more self contained.

Expand Down
2 changes: 0 additions & 2 deletions qiskit_experiments/library/calibration/rough_amplitude_cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,9 @@ def _default_experiment_options(cls):
"""
options = super()._default_experiment_options()

options.result_index = -1
options.angles_schedules = [
AnglesSchedules(target_angle=np.pi, parameter="amp", schedule="x", previous_value=None)
]
options.group = "default"

return options

Expand Down
116 changes: 116 additions & 0 deletions qiskit_experiments/library/calibration/rough_drag_cal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""Rough drag calibration experiment."""

from typing import Iterable, List, Optional

from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
from qiskit.providers.backend import Backend

from qiskit_experiments.framework import ExperimentData, fix_class_docs
from qiskit_experiments.calibration_management import (
BaseCalibrationExperiment,
BackendCalibrations,
)
from qiskit_experiments.calibration_management.update_library import BaseUpdater
from qiskit_experiments.library.characterization.drag import RoughDrag


@fix_class_docs
class RoughDragCal(BaseCalibrationExperiment, RoughDrag):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this RoughDragXSXCal as per convention of rough amp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, Drag only ever updates one pulse. To update both X and SX you should run two separate experiments with the corresponding pulses.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we can integrate them in future since rough drag doesn't have enough resolution of beta.

"""A calibration version of the Drag experiment.

# section: see_also
qiskit_experiments.library.characterization.rough_drag.RoughDrag
"""

def __init__(
self,
qubit: int,
calibrations: BackendCalibrations,
backend: Optional[Backend] = None,
schedule_name: str = "x",
betas: Iterable[float] = None,
cal_parameter_name: Optional[str] = "β",
auto_update: bool = True,
group: str = "default",
):
r"""see class :class:`RoughDrag` for details.

Args:
qubit: The qubit for which to run the rough drag calibration.
calibrations: The calibrations instance with the schedules.
backend: Optional, the backend to run the experiment on.
schedule_name: The name of the schedule to calibrate. Defaults to "x".
betas: A list of drag parameter values to scan. If None is given 51 betas ranging
from -5 to 5 will be scanned.
cal_parameter_name: The name of the parameter in the schedule to update.
Defaults to "β".
auto_update: Whether or not to automatically update the calibrations. By
default this variable is set to True.
group: The group of calibration parameters to use. The default value is "default".
"""
schedule = calibrations.get_schedule(
schedule_name, qubit, assign_params={cal_parameter_name: Parameter("β")}, group=group
)

super().__init__(
calibrations,
qubit,
schedule=schedule,
betas=betas,
backend=backend,
schedule_name=schedule_name,
cal_parameter_name=cal_parameter_name,
auto_update=auto_update,
)

def _add_cal_metadata(self, circuits: List[QuantumCircuit]):
"""Add metadata to the circuit to make the experiment data more self contained.

The following keys are added to each circuit's metadata:
cal_param_value: The value of the previous calibrated beta.
cal_param_name: The name of the parameter in the calibrations.
cal_schedule: The name of the schedule in the calibrations.
cal_group: The calibration group to which the parameter belongs.
"""

prev_beta = self._cals.get_parameter_value(
self._param_name, self.physical_qubits, self._sched_name, self.experiment_options.group
)

for circuit in circuits:
circuit.metadata["cal_param_value"] = prev_beta
circuit.metadata["cal_param_name"] = self._param_name
circuit.metadata["cal_schedule"] = self._sched_name
circuit.metadata["cal_group"] = self.experiment_options.group

def update_calibrations(self, experiment_data: ExperimentData):
"""Update the beta using the value directly reported from the fit.

See :class:`DragCalAnalysis` for details on the fit.
"""

new_beta = BaseUpdater.get_value(
experiment_data, "beta", self.experiment_options.result_index
)

BaseUpdater.add_parameter_value(
self._cals,
experiment_data,
new_beta,
self._param_name,
self._sched_name,
self.experiment_options.group,
)
2 changes: 2 additions & 0 deletions qiskit_experiments/library/characterization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
FineAmplitude
FineXAmplitude
FineSXAmplitude
RoughDrag


Analysis
Expand All @@ -60,3 +61,4 @@
from .rabi import Rabi, EFRabi
from .half_angle import HalfAngle
from .fine_amplitude import FineAmplitude, FineXAmplitude, FineSXAmplitude
from .drag import RoughDrag
Loading