GateImplementation#
- class iqm.pulse.gate_implementation.GateImplementation(parent, name, locus, calibration_data, builder)#
Bases:
ABCABC for implementing quantum gates and other quantum operations using instruction schedules.
Every implementation of every operation type can have its own GateImplementation subclass. 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().GateImplementation also has the
__call__()method, which takes the operation parameters (e.g. rotation angles) as input, and builds, caches and then returns aTimeBoxinstance which implements an instance of the operation at that locus.__call__()normally should not be reimplemented by the subclasses, instead they should define_call()which contains the actual implementation without the caching logic.Even though it is possible, GateImplementations should not use other gates to implement themselves, unless they are subclasses of
CompositeGate. This is to encapsulate the calibration data better, and avoid unpredictable dependencies between gates.- 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 instance that can be used to access system properties (and in the case of
CompositeGate, other gates).
Module:
iqm.pulse.gate_implementationAttributes
Required calibration data, may be nested
Qualified name of the implementation.
Set to
Trueif the implementation is a special purpose implementation that should never get called inScheduleBuilder.get_implementationunless explicitly requested via theimpl_nameargument.True iff the implementation is symmetric in its locus components.
Unique str identifier, needed for certain caching properties.
Single-component sub-implementations for factorizable gates with len(locus) > 1, otherwise empty.
Methods
Construct an implementation for a factorizable operation.
Convert time- and frequency-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.ChipTopologyfor this implementation.Calibration data tree the GateImplementation subclass expects for each locus.
True iff the implementation may have calibration data.
True iff the implementation needs calibration data.
Optional calibration data keys for this class, in addition to the required items in
parameters.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
Trueif the implementation is a special purpose implementation that should never get called inScheduleBuilder.get_implementationunless explicitly requested via theimpl_nameargument.
- id#
Unique str identifier, needed for certain caching properties.
- sub_implementations: dict[str, GateImplementation]#
Single-component sub-implementations for factorizable gates with len(locus) > 1, otherwise empty. At least one of self.sub_implementations and self.calibration_data is always empty.
- classmethod needs_calibration()#
True iff the implementation needs calibration data.
- Returns:
True iff
OpCalibrationDataTreemust contain a nodef"{self.parent.name}.{self.name}.{self.locus}for the calibration data this instance needs.- Return type:
- classmethod optional_calibration_keys()#
Optional calibration data keys for this class, in addition to the required items in
parameters.These keys are not required to be present in
OILCalibrationDatawhen validating it.
- classmethod may_have_calibration()#
True iff the implementation may have calibration data.
- Returns:
True iff
OpCalibrationDataTreemay contain a node"{self.parent.name}.{self.name}.{self.locus}for the calibration data of this instance.- 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.
- final classmethod construct_factorizable(parent, name, locus, builder, sub_implementations)#
Construct an implementation for a factorizable operation.
Instead of calibration data this method is given
sub_implementations, which contains single-qubit implementations for all the components inlocus.- Parameters:
parent (QuantumOp)
name (str)
locus (Locus)
builder (ScheduleBuilder)
sub_implementations (dict[str, GateImplementation])
- Return type:
- final 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:
- final classmethod convert_calibration_data(calibration_data, params, channel_props, *, duration=None, _top_level=True)#
Convert time- and frequency-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 and frequencies measured in Hz into fractions of the duration of the gate, e.g. to be used to parameterize
Waveformclasses.Values of items that are not measured in seconds or Hz are returned as is.
Items named
durationget special treatment for convenience. They are not included in the converted data. If thedurationparameter is None, there must be a"duration"item at the top level incalibration_datawhose value will be used instead.The
durationparameter is converted to channel samples and included in the converted data under the top-level key"n_samples".
- Parameters:
calibration_data (OILCalibrationData) – (subset of) calibration data for the gate/implementation/locus
params (NestedParams) – (subset of)
cls.parametersspecifying thecalibration_dataitems 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_datamust have an item named"duration", measured in seconds, which will be used instead._top_level (bool)
- Returns:
converted
calibration_dataitems- Return type:
OILCalibrationData
- final 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. OneSettingwill 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.ChipTopologyfor 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 (Mapping[str, Iterable[str]]) – dict mapping QPU component names to an
Iterableof 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
Noneif 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: