Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calibrations Definition #26

Merged
merged 185 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from 184 commits
Commits
Show all changes
185 commits
Select commit Hold shift + click to select a range
768599e
* Added initial draft of cal def.
eggerdj Apr 6, 2021
75214af
* Added exception and PArameterValue.
eggerdj Apr 7, 2021
40bf8bd
* Black and fstrings.
eggerdj Apr 7, 2021
2639b0d
* Removed unnecessary hashing.
eggerdj Apr 7, 2021
bd0529a
* Added init.
eggerdj Apr 7, 2021
c992ccc
* Renamed CalibrationsDefinition to Calibrations.
eggerdj Apr 7, 2021
9092094
* Fixed issue with parameters in the Schedule.
eggerdj Apr 7, 2021
8c4c21e
* Removed pnadas.
eggerdj Apr 13, 2021
fbc2dc7
* Cleaned up _get_Channel_index.
eggerdj Apr 13, 2021
47ab364
* Removed pandas import.
eggerdj Apr 13, 2021
a9bc280
* Added description to get_circuit.
eggerdj Apr 13, 2021
f952975
* Added type to backend in __init__.
eggerdj Apr 13, 2021
ec956ae
* Added raise error to get_parameter_value.
eggerdj Apr 13, 2021
ae24a11
* Added __init__ in tests for lint.
eggerdj Apr 13, 2021
f96ab98
Merge branch 'main' into calibrations_definition
eggerdj Apr 13, 2021
7dd1bed
* Removed erronous comment.
eggerdj Apr 14, 2021
edc402d
Update qiskit_experiments/calibration/calibrations.py
eggerdj Apr 14, 2021
ffe4d87
* implified CalibrationError.
eggerdj Apr 14, 2021
14cc378
Update qiskit_experiments/calibration/calibrations.py
eggerdj Apr 14, 2021
d70acce
Update qiskit_experiments/calibration/calibrations.py
eggerdj Apr 14, 2021
b919f67
* Simplified parameter assignment in the Calibrations.
eggerdj Apr 14, 2021
aa9b1ca
Merge branch 'calibrations_definition' of github.com:eggerdj/qiskit-e…
eggerdj Apr 14, 2021
b58d3cd
* Removed pandas from the docstrings.
eggerdj Apr 14, 2021
b08c481
Update qiskit_experiments/calibration/calibrations.py
eggerdj Apr 14, 2021
a73d9e3
* Fixed the keys in parameters_table.
eggerdj Apr 14, 2021
1d4923f
* Made parameter registration more transparent and added an error for…
eggerdj Apr 14, 2021
f74534e
* Improved docstring.
eggerdj Apr 14, 2021
72ce1c0
* Added check to ensure that all parameter names in a schedule are un…
eggerdj Apr 14, 2021
2e22059
* Removed properties from Calibrations.
eggerdj Apr 14, 2021
8053c5c
* Made self._params a defaultdict.
eggerdj Apr 14, 2021
75a5cfb
* Fixed order of raise in add_parameter_value.
eggerdj Apr 14, 2021
0862722
* Removed the deepcopy of schedule.
eggerdj Apr 14, 2021
d35b0ed
* Added qubits to keys in self._schedules and self._parameter_map, an…
eggerdj Apr 18, 2021
dfc2788
* Added test where default schedule is overridden.
eggerdj Apr 19, 2021
70f4616
* Updated parameter management to
eggerdj Apr 19, 2021
50af0e3
* Improved docstrings.
eggerdj Apr 19, 2021
800d1d0
* Improved methodology to get the values of parameters.
eggerdj Apr 20, 2021
2af8cb0
* Fixed lint.
eggerdj Apr 21, 2021
e75df84
* Removed the backend object and added a config for the controls.
eggerdj Apr 21, 2021
4461153
* Extended the functionality of the channel naming convention.
eggerdj Apr 21, 2021
f2d680e
* Added methodology to deal with Call schedule and cross-resonance sc…
eggerdj Apr 22, 2021
6019b78
* Added first stab of the method to export the calibrations to a csv.
eggerdj Apr 22, 2021
0a01a7a
* Added the class BackendCalibrations to manage configurations in the…
eggerdj Apr 23, 2021
509aa44
* Renamed file and added BackendCalibrations to __init__
eggerdj Apr 23, 2021
9085018
* Added test for BackendCalibrations.
eggerdj Apr 23, 2021
d014b17
* Added a check when adding parameter values to ensure that the sched…
eggerdj Apr 23, 2021
490ad63
* Fixed small issue with _get_frequencies.
eggerdj Apr 23, 2021
fa27ef5
* Made register_parameter private.
eggerdj Apr 23, 2021
b314294
* Made add_parameter_value accept Union[int, float, complex, Paramete…
eggerdj Apr 23, 2021
0f60d1f
* channel pattern is now a class variable.
eggerdj Apr 23, 2021
9de4086
* Made _get_circuit private.
eggerdj Apr 23, 2021
7bac467
* Added method calibration_parameter.
eggerdj Apr 26, 2021
619fea3
* Added the hash to Calibrations.parameters
eggerdj Apr 26, 2021
373cb38
* Imprved the docstrings.
eggerdj Apr 26, 2021
38deb52
* black
eggerdj Apr 26, 2021
602f001
* Black
eggerdj Apr 26, 2021
18ff956
* Lint
eggerdj Apr 26, 2021
fe07b6e
* Renamed qubit_ref_est -> qubit_lo_freq.
eggerdj Apr 27, 2021
09f1cc3
* _get_frequencies only returns valid frequencies.
eggerdj Apr 27, 2021
9344834
* Fixed regex.
eggerdj Apr 27, 2021
d8dff58
* Docstring fix.
eggerdj Apr 27, 2021
8f8a569
* Added ScheduleKey.
eggerdj Apr 28, 2021
174c4ec
* Fixed String trimming.
eggerdj Apr 28, 2021
1546e48
* Fixed channel checking length issue.
eggerdj Apr 28, 2021
f4bf40d
* Added the max function for efficiency.
eggerdj Apr 28, 2021
f9e42ed
* Added error message in get_parameter_keys.
eggerdj Apr 28, 2021
05d61eb
* Simplified get_parameter_keys.
eggerdj Apr 28, 2021
9194031
* Changed method schedules.
eggerdj Apr 28, 2021
afaba9b
* Improved to_csv docstring.
eggerdj Apr 28, 2021
5265030
* Added method to clean the mapping which is need when overwritting s…
eggerdj Apr 28, 2021
f817f5c
* Added an instance to make parameter hashes nice and counting up fro…
eggerdj Apr 28, 2021
290e2ef
* Do not register parameters in a call but recursively register the s…
eggerdj Apr 28, 2021
e56953f
* Removed regex from docstring and improved it.
eggerdj Apr 28, 2021
2646227
* Added code example in class docstring.
eggerdj Apr 28, 2021
3dfcb3d
* Raise error if a channel has more than one parameter.
eggerdj Apr 28, 2021
91aa4cd
* Amended class docstring.
eggerdj Apr 28, 2021
6833d1f
* Added remove_schedule method.
eggerdj Apr 28, 2021
0c1ede5
Update qiskit_experiments/calibration/calibrations.py
eggerdj Apr 28, 2021
5426c68
* Added the cutoff_date to schedule.
eggerdj Apr 28, 2021
54db71c
* Made get_parameter_keys private.
eggerdj Apr 28, 2021
c8f4fb5
* Added missing type hint.
eggerdj Apr 28, 2021
37a2eaf
* removed get circuit.
eggerdj Apr 28, 2021
113150a
* Fixed inconsistency with in parameters_table.
eggerdj Apr 28, 2021
3006695
* Switched to assigned_subroutine.
eggerdj Apr 29, 2021
5d40e8c
* Cahnged to BackendV1.
eggerdj Apr 29, 2021
91c239d
* Removed unused import.
eggerdj Apr 29, 2021
c4b7260
* Fixed lint
eggerdj Apr 29, 2021
6ebdc48
* Aligned docstring.
eggerdj Apr 29, 2021
b4a0f74
* Made schedules in test more concis.
eggerdj Apr 29, 2021
d06bb4f
* Improved the CR test. This passes but requires terra bug fix #6322.
eggerdj Apr 30, 2021
7c40368
* Improved docstrings.
eggerdj Apr 30, 2021
1b6bf14
* Renamed files.
eggerdj Apr 30, 2021
e9d38ab
* Lint
eggerdj Apr 30, 2021
9e4ea3b
Update qiskit_experiments/calibration/backend_calibrations.py
eggerdj Apr 30, 2021
0ab664a
Update qiskit_experiments/calibration/backend_calibrations.py
eggerdj May 1, 2021
1803285
Update qiskit_experiments/calibration/backend_calibrations.py
eggerdj May 1, 2021
f7ee6b9
Update qiskit_experiments/calibration/backend_calibrations.py
eggerdj May 1, 2021
32892d5
Update qiskit_experiments/calibration/calibrations_manager.py
eggerdj May 1, 2021
3d2a052
Update qiskit_experiments/calibration/calibrations_manager.py
eggerdj May 1, 2021
8148d0e
Update qiskit_experiments/calibration/calibrations_manager.py
eggerdj May 1, 2021
13ed686
Update qiskit_experiments/calibration/calibrations_manager.py
eggerdj May 1, 2021
83f82a7
Update qiskit_experiments/calibration/calibrations_manager.py
eggerdj May 1, 2021
b83adf3
Update qiskit_experiments/calibration/calibrations_manager.py
eggerdj May 1, 2021
1c6d1e3
* Reverted name to Calibrations.
eggerdj May 1, 2021
62d1728
* Improved docstring.
eggerdj May 1, 2021
d19dfe8
* Added functions get_qubit_frequencies and get_meas_frequencies.
eggerdj May 1, 2021
fa5edc1
* Added ScheduleBlock.
eggerdj May 1, 2021
5033b48
* Removed candidate_default_keys.
eggerdj May 1, 2021
f067c7d
* Improved the error message.
eggerdj May 1, 2021
23402a7
* Improved docstring.
eggerdj May 1, 2021
4160914
* Added measurement schedule tests.
eggerdj May 2, 2021
84b49c9
* Added double call test.
eggerdj May 2, 2021
4e9f266
* Added recursive assign to handle multiple Calls of the same schedul…
eggerdj May 3, 2021
d99c429
* Added support for parametric durations:
eggerdj May 4, 2021
a743a9a
* Added tests on the parameter filtering.
eggerdj May 5, 2021
b6d9dec
* Black.
eggerdj May 5, 2021
bc11c38
* Added test to check that a template is preserved after getting a sc…
eggerdj May 5, 2021
62b42b6
* Moved docstring to module level.
eggerdj May 5, 2021
f8132bb
* Removed if isinstance on Call in add_schedule.
eggerdj May 5, 2021
0d267c2
* Moved the Schedule and ScheduleBlock test to add_schedule.
eggerdj May 5, 2021
f6f4b8a
* Added reverse look-up to deal with pure control channel cases.
eggerdj May 5, 2021
f94b34e
* Added a pure Schedule test.
eggerdj May 5, 2021
a7f8a36
* Fixed test_backend_calibrations.
eggerdj May 5, 2021
980f2c2
* Refactored order of ParameterKey.
eggerdj May 5, 2021
98530d4
* Amended docstring for free_params in get_schedule.
eggerdj May 5, 2021
d85f5f6
* Improved consistency of argument ordering.
eggerdj May 5, 2021
3900b82
* Added a check on the number of free parameters and the assigned sch…
eggerdj May 5, 2021
0c519b5
* Black
eggerdj May 5, 2021
987bc81
Update qiskit_experiments/calibration/__init__.py
eggerdj May 7, 2021
129db5b
Update qiskit_experiments/calibration/__init__.py
eggerdj May 7, 2021
47c0a44
Update qiskit_experiments/calibration/__init__.py
eggerdj May 7, 2021
80bc820
Update qiskit_experiments/calibration/__init__.py
eggerdj May 7, 2021
f7747c6
Update qiskit_experiments/calibration/__init__.py
eggerdj May 7, 2021
aaf1479
* made docstring example consistent.
eggerdj May 7, 2021
0a49a3c
* Made error message clearer
eggerdj May 7, 2021
320b377
* Added more robustnes to user qubit input:
eggerdj May 7, 2021
f9c0490
* Amended docstring.
eggerdj May 7, 2021
3c56906
* Added a test for an acquire channel.
eggerdj May 7, 2021
07d5ee1
* Renamed _hash_map to _hash_to_counter_map.
eggerdj May 7, 2021
2009af4
* Removed Schedule from Calibrations.
eggerdj May 7, 2021
e9b44e7
* Added saving and loading to csv.
eggerdj May 8, 2021
75fadc7
* Improved docstring in __init__
eggerdj May 10, 2021
54c3e81
* Added warning in save.
eggerdj May 11, 2021
db33772
* Added development warning to the __init__
eggerdj May 11, 2021
4f04ae4
* Added check for unregistered subroutines and correspoinding test.
eggerdj May 11, 2021
61a0ba1
* Added method get_template and corresponding tests.
eggerdj May 11, 2021
fd09136
* Errors are now raised if a schedule is called.
eggerdj May 11, 2021
1b14366
* Simplified _assign.
eggerdj May 11, 2021
27af03c
* Refactored free_params methodology to assign_params.
eggerdj May 11, 2021
ced5333
* Improved error message.
eggerdj May 11, 2021
7031ec1
* Improved docstrings.
eggerdj May 11, 2021
6ada9ce
* Added utf-8 encoding.
eggerdj May 11, 2021
bb4fb81
* Added a missing utf-8 in loading.
eggerdj May 11, 2021
bab9b9a
* Improved docstrings.
eggerdj May 12, 2021
ba2bc1b
* Added example of parameter assignment.
eggerdj May 12, 2021
3166ae2
* refined the parameter management for coupled parameters.
eggerdj May 13, 2021
1dd07e8
* Removed break coupling.
eggerdj May 19, 2021
da84b8a
* Corrected docstring.
eggerdj May 19, 2021
7209231
Scope assign_params by qubits and calibration_parameter
wshanks May 19, 2021
8681523
* Added a test and changed test_assign_coupled_implicitly.
eggerdj May 20, 2021
860196a
* Changed order of tests for readability.
eggerdj May 20, 2021
6033672
Merge pull request #1 from eggerdj/calibrations_definition_wshanks
wshanks May 20, 2021
3e844bc
no error for default and specific qubit assign_params
wshanks May 20, 2021
dee2f58
Clean up conditional
wshanks May 20, 2021
0f3907c
Multiple assign_params keys for one param okay if assinging same value
wshanks May 20, 2021
dae34e1
Clarify assign_params comment
wshanks May 20, 2021
145c190
Test assign parameter in call
wshanks May 20, 2021
90b0dd8
Test assigning to same param name in two levels of subroutines
wshanks May 20, 2021
c597e52
* Made use of self.calibration_parameter.
eggerdj May 21, 2021
a15b6a9
* Docstring update.
eggerdj May 21, 2021
fd7db9d
* Added check on parameter consistency across subroutines.
eggerdj May 21, 2021
abbe216
* Renamed a Test.
eggerdj May 21, 2021
03f2d7b
* ParameterValueType refactor.
eggerdj May 21, 2021
4fe70a1
Test nested assignment to Parameter edge case
wshanks May 21, 2021
dd773a1
Remvoe unused import
wshanks May 21, 2021
7c43741
Fix test names
wshanks May 21, 2021
83aeb1b
Merge pull request #1 from wshanks/calibrations_definition
eggerdj May 21, 2021
05b9582
* Black and lint.
eggerdj May 21, 2021
e0c6b7f
* Added check for subroutine inconsistencies and corresponding tests.
eggerdj May 21, 2021
31a11e7
* Removed the check on parameters in _assign as the schedule check co…
eggerdj May 21, 2021
c666777
Merge branch 'main' into calibrations_definition
eggerdj Jun 1, 2021
33f4811
Merge branch 'main' into calibrations_definition
eggerdj Jun 1, 2021
c492b35
Update qiskit_experiments/calibration/calibrations.py
eggerdj Jun 3, 2021
048684d
* Added an Enum type for the frequency elements.
eggerdj Jun 3, 2021
7316a9d
Merge branch 'main' into calibrations_definition
eggerdj Jun 3, 2021
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
123 changes: 123 additions & 0 deletions qiskit_experiments/calibration/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# 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.

r"""
Qiskit Experiments Calibration Root.

.. warning::
The calibrations interface is still in active development. It may have
breaking API changes without deprecation warnings in future releases until
otherwise indicated.

Calibrations are managed by the Calibrations class. This class stores schedules which are
eggerdj marked this conversation as resolved.
Show resolved Hide resolved
intended to be fully parameterized, including the index of the channels. This class:
- supports having different schedules share parameters
- allows default schedules for qubits that can be overridden for specific qubits.

The following code illustrates how a user can create a parameterized schedule, add
values to the parameters and query a schedule.

.. code-block:: python

dur = Parameter("dur")
amp = Parameter("amp")
sigma = Parameter("σ")

with pulse.build(name="xp") as xp:
pulse.play(Gaussian(dur, amp, sigma), DriveChannel(Parameter("ch0")))

cals = Calibrations()
cals.add_schedule(xp)

# add duration and sigma parameter values for all qubits.
cals.add_parameter_value(160, "dur", schedule="xp")
cals.add_parameter_value(35.5, "σ", schedule="xp")

# Add an amplitude for qubit 3.
cals.add_parameter_value(0.2+0.05j, "amp", (3, ), "xp")

# Retrieve an xp pulse with all parameters assigned
cals.get_schedule("xp", (3, ))

# Retrieve an xp pulse with unassigned amplitude
cals.get_schedule("xp", (3, ), free_params=["amp"])

The Calibrations make a couple of assumptions which are discussed below.

Parametric channel naming convention
=========================

Parametrized channel indices must be named according to a predefined pattern to properly
identify the channels and control channels when assigning values to the parametric
channel indices. A channel must have a name that starts with `ch` followed by an integer.
For control channels this integer can be followed by a sequence `.integer`.
Optionally, the name can end with `$integer` to specify the index of a control channel
eggerdj marked this conversation as resolved.
Show resolved Hide resolved
for the case when a set of qubits share multiple control channels. For example,
valid channel names include "ch0", "ch1", "ch0.1", "ch0$", "ch2$3", and "ch1.0.3$2".
The "." delimiter is used to specify the different qubits when looking for control
channels. The optional $ delimiter is used to specify which control channel to use
if several control channels work together on the same qubits. For example, if the
control channel configuration is {(3,2): [ControlChannel(3), ControlChannel(12)]}
then given qubits (2, 3) the name "ch1.0$1" will resolve to ControlChannel(12) while
"ch1.0$0" will resolve to ControlChannel(3). A channel can only have one parameter.

Parameter naming restriction
===================

Each parameter must have a unique name within each schedule. For example, it is
acceptable to have a parameter named 'amp' in the schedule 'xp' and a different
parameter instance named 'amp' in the schedule named 'xm'. It is not acceptable
to have two parameters named 'amp' in the same schedule. The naming restriction
only applies to parameters used in the immediate scope of the schedule. Schedules
called by Call instructions have their own scope for Parameter names.

The code block below illustrates the creation of a template schedule for a echoed cross-
resonance gate.

.. code-block:: python

amp_cr = Parameter("amp")
amp = Parameter("amp")
d0 = DriveChannel(Parameter("ch0"))
c1 = ControlChannel(Parameter("ch0.1"))
sigma = Parameter("σ")
width = Parameter("w")
dur_xp = Parameter("duration")
dur_cr = Parameter("duration")

with pulse.build(name="xp") as xp:
pulse.play(Gaussian(dur_xp, amp, sigma), d0)

with pulse.build(name="cr") as cr:
with pulse.align_sequential():
pulse.play(GaussianSquare(dur_cr, amp_cr, sigma, width), c1)
pulse.call(xp)
pulse.play(GaussianSquare(dur_cr, -amp_cr, sigma, width), c1)
pulse.call(xp)

cals = Calibrations()
cals.add_schedule(xp)
cals.add_schedule(cr)

Note that a registered template schedule can be retrieve by doing

.. code-block:: python

xp = cals.get_template("xp")

which would return the default xp schedule block template for all qubits.
"""
eggerdj marked this conversation as resolved.
Show resolved Hide resolved

from .calibrations import Calibrations
from .backend_calibrations import BackendCalibrations
from .exceptions import CalibrationError
from .parameter_value import ParameterValue
149 changes: 149 additions & 0 deletions qiskit_experiments/calibration/backend_calibrations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# 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.

"""Store and manage the results of calibration experiments in the context of a backend."""

from datetime import datetime
from enum import Enum
from typing import List
import copy

from qiskit.providers.backend import BackendV1 as Backend
from qiskit.circuit import Parameter
from qiskit_experiments.calibration.calibrations import Calibrations, ParameterKey
from qiskit_experiments.calibration.exceptions import CalibrationError


class FrequencyElement(Enum):
"""An extendable enum for components that have a frequency."""

QUBIT = "Qubit"
READOUT = "Readout"


class BackendCalibrations(Calibrations):
Copy link
Collaborator

Choose a reason for hiding this comment

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

As we discussed offline, this induces tight coupling to execution chain because this class exists for generating a backend dependent runtime option though the Calibrations is just a database of programs and parameters. If you really think this coupling is necessary, Calibrations should be an abstract class. There is no calibration operation without backend. We should define calibration subclass for every target backend configuration.

I think the right direction should be exporting configured backend with Calibration, and override runtime option with parameters in the backend. This runtime option generation should be done by Experiment class.

"""
A Calibrations class to enable a seamless interplay with backend objects.
This class enables users to export their calibrations into a backend object.
Additionally, it creates frequency parameters for qubits and readout resonators.
The parameters are named `qubit_lo_freq` and `meas_lo_freq` to be consistent
with the naming in backend.defaults(). These two parameters are not attached to
any schedule.
"""

def __init__(self, backend: Backend):
"""Setup an instance to manage the calibrations of a backend."""
super().__init__(backend.configuration().control_channels)

# Use the same naming convention as in backend.defaults()
self.qubit_freq = Parameter("qubit_lo_freq")
self.meas_freq = Parameter("meas_lo_freq")
self._register_parameter(self.qubit_freq, ())
self._register_parameter(self.meas_freq, ())

self._qubits = set(range(backend.configuration().n_qubits))
self._backend = backend

def _get_frequencies(
self,
element: FrequencyElement,
group: str = "default",
cutoff_date: datetime = None,
) -> List[float]:
"""Internal helper method."""

if element == FrequencyElement.READOUT:
param = self.meas_freq.name
elif element == FrequencyElement.QUBIT:
param = self.qubit_freq.name
else:
raise CalibrationError(f"Frequency element {element} is not supported.")

freqs = []
for qubit in self._qubits:
if ParameterKey(None, param, (qubit,)) in self._params:
freq = self.get_parameter_value(param, (qubit,), None, True, group, cutoff_date)
else:
if element == FrequencyElement.READOUT:
freq = self._backend.defaults().meas_freq_est[qubit]
elif element == FrequencyElement.QUBIT:
freq = self._backend.defaults().qubit_freq_est[qubit]
else:
raise CalibrationError(f"Frequency element {element} is not supported.")

freqs.append(freq)

return freqs

def get_qubit_frequencies(
eggerdj marked this conversation as resolved.
Show resolved Hide resolved
self,
group: str = "default",
cutoff_date: datetime = None,
) -> List[float]:
"""
Get the most recent qubit frequencies. They can be passed to the run-time
options of :class:`BaseExperiment`. If no calibrated frequency value of a
qubit is found then the default value from the backend defaults is used.
Only valid parameter values are returned.

Args:
group: The calibration group from which to draw the
parameters. If not specified, this defaults to the 'default' group.
cutoff_date: Retrieve the most recent parameter up until the cutoff date. Parameters
generated after the cutoff date will be ignored. If the cutoff_date is None then
all parameters are considered. This allows users to discard more recent values
that may be erroneous.

Returns:
A List of qubit frequencies for all qubits of the backend.
"""
return self._get_frequencies(FrequencyElement.QUBIT, group, cutoff_date)

def get_meas_frequencies(
self,
group: str = "default",
cutoff_date: datetime = None,
) -> List[float]:
"""
Get the most recent measurement frequencies. They can be passed to the run-time
options of :class:`BaseExperiment`. If no calibrated frequency value of a
measurement is found then the default value from the backend defaults is used.
Only valid parameter values are returned.

Args:
group: The calibration group from which to draw the
parameters. If not specified, this defaults to the 'default' group.
cutoff_date: Retrieve the most recent parameter up until the cutoff date. Parameters
generated after the cutoff date will be ignored. If the cutoff_date is None then
all parameters are considered. This allows users to discard more recent values
that may be erroneous.

Returns:
A List of measurement frequencies for all qubits of the backend.
"""
return self._get_frequencies(FrequencyElement.READOUT, group, cutoff_date)

def export_backend(self) -> Backend:
"""
Exports the calibrations to a backend object that can be used.

Returns:
calibrated backend: A backend with the calibrations in it.
"""
backend = copy.deepcopy(self._backend)

backend.defaults().qubit_freq_est = self.get_qubit_frequencies()
backend.defaults().meas_freq_est = self.get_meas_frequencies()

# TODO: build the instruction schedule map using the stored calibrations

return backend
Loading