GateImplementation#
- class iqm.pulse.gate_implementation.GateImplementation(parent, name, locus, calibration_data, builder)#
Bases:
ABC
ABC for implementing quantum gates and other quantum operations using instruction schedules.
There is a separate GateImplementation subclass for every implementation of every operation type. Each GateImplementation instance represents a particular locus for that implementation, and encapsulates the calibration data it requires.
All GateImplementation subclasses
__init__
must have exactly the below arguments in order to be usable viaScheduleBuilder.get_implementation()
.GateImplementations also have the
__call__()
method, which takes the operation parameters (e.g. rotation angles) as input, and returns aTimeBox
instance which implements an instance of the operation at that locus.- Parameters:
parent (QuantumOp) – Quantum operation this instance implements.
name (str) – Name of the implementation provided by this instance.
locus (Locus) – Locus the operation acts on.
calibration_data (OILCalibrationData) – (Raw) calibration data for the (operation, implementation, locus) represented by this instance
builder (ScheduleBuilder) – Schedule builder.
Module:
iqm.pulse.gate_implementation
Attributes
Required calibration data, may be nested
Qualified name of the implementation.
Set to
True
if the implementation is a special purpose implementation that should never get called inScheduleBuilder.get_implementation
unless explicitly requested via theimpl_name
argument.True iff the implementation is symmetric in its locus components.
Methods
Utility method for constructing a GateImplementation with
self.builder
.Convert time-like items in the calibration data to fractions of the time duration of the gate.
Duration of the Schedule of the gate implementation (in seconds).
Get custom locus mapping for this GateImplementation.
Get the name of the locus mapping stored in
ScheduleBuilder.ChipTopology
for this implementation.Calibration data tree the GateImplementation subclass expects for each locus.
Whether the implementation needs calibration data
Wraps the given instruction schedule into an atomic/resolved timebox.
- symmetric: bool = False#
True iff the implementation is symmetric in its locus components. Only meaningful if
arity != 1
, and the locus components are of the same type.
- special_implementation: bool = False#
Set to
True
if the implementation is a special purpose implementation that should never get called inScheduleBuilder.get_implementation
unless explicitly requested via theimpl_name
argument.
- classmethod needs_calibration()#
Whether the implementation needs calibration data
Returns True if the calibration dict must contain a node with keyed with <operation name>: <implementation name>: <appropriate locus> in order to use this implementation.
- Return type:
- _call(*args, **kwargs)#
The GateImplementation-specific logic for implementing a quantum operation.
Inheriting classes may override this method if the default
__call__()
caching (based on the args & kwargs in the signature) is sufficient. Any additional caching may also be implemented inside this function if needed.
- build(op_name, locus, impl_name=None, strict_locus=False)#
Utility method for constructing a GateImplementation with
self.builder
.Inheriting classes may override this in order to add additional logic.
- Parameters:
op_name (str) – operation name
impl_name (str | None) – implementation name. Uses the assigned default implementation if not specified.
strict_locus (bool) – iff False, for non-symmetric implementations of symmetric ops the locus order may be changed if no calibration data is available for the requested locus order
- Returns:
Calibrated gate implementation.
- Return type:
- to_timebox(schedule)#
Wraps the given instruction schedule into an atomic/resolved timebox.
- duration_in_seconds()#
Duration of the Schedule of the gate implementation (in seconds).
Can be left unimplemented if the duration e.g. depends on the gate arguments. Subclasses can reimplement this method in case it makes sense in their context.
- Return type:
- classmethod convert_calibration_data(calibration_data, params, channel_props, duration=None)#
Convert time-like items in the calibration data to fractions of the time duration of the gate.
This is a convenience method for converting calibration data items involving time durations measured in seconds into fractions of the duration of the gate.
Values of items that are not measured in seconds or Hz are returned as is.
Additionally, converts
duration
to channel samples and adds it in the converted calibration data under the key"n_samples"
, while the original"duration"
key is removed.
- Parameters:
calibration_data (OILCalibrationData) – (subset of) calibration data for the gate/implementation/locus
params (NestedParams) – (subset of)
cls.parameters
specifying thecalibration_data
items to convert and returnchannel_props (ChannelProperties) – used to convert
"duration"
from seconds into channel samplesduration (float | None) – Time duration of the gate, in seconds. If None,
calibration_data
must have an item named"duration"
, measured in seconds, which will be used instead.
- Returns:
converted
calibration_data
items- Return type:
OILCalibrationData
- classmethod get_parameters(locus, path=())#
Calibration data tree the GateImplementation subclass expects for each locus.
Helper method for EXA use.
- Parameters:
locus (Iterable[str]) – Locus component names to replace the wildcard character
"*"
in the calibration parameter names. OneSetting
will be generated for each component name inlocus
. If there are no wildcard characters incls.parameters
, this argument has no effect.path (Iterable[str]) – parts of the dotted name for the root node, if any.
- Returns:
EXA setting node describing the required calibration data for each locus. All the Setting values are
None
.- Return type:
SettingNode
- classmethod get_locus_mapping_name(operation_name, implementation_name)#
Get the name of the locus mapping stored in
ScheduleBuilder.ChipTopology
for this implementation.By default, it is
"<operation_name>.<implementation_name>"
. Inheriting classes may override this for different behaviour.
- classmethod get_custom_locus_mapping(chip_topology, component_to_channels)#
Get custom locus mapping for this GateImplementation.
This method can be used to return the locus mapping (wrt. to the given
ChipTopology
) for thisGateImplementation
. Overriding this method allows a GateImplementation to be “self-sufficient” in the sense that it knows its own locus mapping.- Parameters:
chip_topology (ChipTopology) – ChipTopology instance in which context to create the custom locus mapping.
component_to_channels (dict[str, Iterable[str]]) – dict mapping QPU component names to an
Iterable
of channel operation names available for this component (i.e. “readout”, “drive”, “flux”). This info is often needed in building a locus mapping.
- Returns:
- Custom locus mapping for this GateImplementation or
None
if the gate implementation has no need for a custom locus mapping, otherwise the returned mapping should be like in
ChipTopology.set_locus_mapping()
- Custom locus mapping for this GateImplementation or
- Return type: