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 via ScheduleBuilder.get_implementation().

GateImplementations also have the __call__() method, which takes the operation parameters (e.g. rotation angles) as input, and returns a TimeBox 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

parameters

Required calibration data, may be nested

qualified_name

Qualified name of the implementation.

special_implementation

Set to True if the implementation is a special purpose implementation that should never get called in ScheduleBuilder.get_implementation unless explicitly requested via the impl_name argument.

symmetric

True iff the implementation is symmetric in its locus components.

Methods

build

Utility method for constructing a GateImplementation with self.builder.

convert_calibration_data

Convert time-like items in the calibration data to fractions of the time duration of the gate.

duration_in_seconds

Duration of the Schedule of the gate implementation (in seconds).

get_custom_locus_mapping

Get custom locus mapping for this GateImplementation.

get_locus_mapping_name

Get the name of the locus mapping stored in ScheduleBuilder.ChipTopology for this implementation.

get_parameters

Calibration data tree the GateImplementation subclass expects for each locus.

needs_calibration

Whether the implementation needs calibration data

to_timebox

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.

parameters: dict[str, Parameter | Setting | dict] = {}#

Required calibration data, may be nested

special_implementation: bool = False#

Set to True if the implementation is a special purpose implementation that should never get called in ScheduleBuilder.get_implementation unless explicitly requested via the impl_name argument.

property qualified_name: str#

Qualified name of the implementation.

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:

bool

_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.

Return type:

TimeBox | list[TimeBox]

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

  • locus (tuple[str, ...]) – locus the operation acts on

  • 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:

GateImplementation

to_timebox(schedule)#

Wraps the given instruction schedule into an atomic/resolved timebox.

Parameters:

schedule (Schedule) –

Return type:

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:

float

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 the calibration_data items to convert and return

  • channel_props (ChannelProperties) – used to convert "duration" from seconds into channel samples

  • duration (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. One Setting will be generated for each component name in locus. If there are no wildcard characters in cls.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.

Parameters:
  • operation_name (str) – name of the quantum operation.

  • implementation_name (str) – name of the implementation

Returns:

name of the locus mapping

Return type:

str

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 this GateImplementation. 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()

Return type:

dict[tuple[str, …] | frozenset[str], tuple[str, …]] | None