CompositeGate#

class iqm.pulse.gate_implementation.CompositeGate(parent, name, locus, calibration_data, builder)#

Bases: GateImplementation

Base class for gate implementations that are defined in terms of other gate implementations.

Composite gates can be implemented using other pre-existing gate implementations (called its member gates) by using build() in the _call() method. You should not call ScheduleBuilder.get_implementation() directly in composite gate code.

A CompositeGate subclass needs to declare what its member gates are, e.g. to be able to verify that they are calibrated, using the registered_gates class attribute.

It is possibe to calibrate (some of) the member gates separately from the common calibration, by listing their names in customizable_gates class attribute. However, if no custom calibration data is provided, the composite gate will use the common calibration for the member operations.

Note

CompositeGate.needs_calibration() only tells whether the implementation class itself needs calibration data, not whether the member gates need some.

Module: iqm.pulse.gate_implementation

Attributes

customizable_gates

These member operations can be calibrated separately from their common calibration by adding OCalibrationData nodes for them under the OILCalibrationData node of the composite gate.

default_implementations

Mapping from member operation names to the designated default implementation of that operation.

registered_gates

Names of the member operations used by the composite gate.

id

Unique str identifier, needed for certain caching properties.

sub_implementations

Single-component sub-implementations for factorizable gates with len(locus) > 1, otherwise empty.

Methods

build

Construct an implementation for a member (registered) gate.

optional_calibration_keys

Optional calibration data keys for this class, in addition to the required items in parameters.

Parameters:
registered_gates: tuple[str, ...] = ()#

Names of the member operations used by the composite gate. There must be corresponding keys in builder.op_table.

customizable_gates: tuple[str, ...] | None = None#

These member operations can be calibrated separately from their common calibration by adding OCalibrationData nodes for them under the OILCalibrationData node of the composite gate. Must be a subset of registered_gates. By default all member operations are customizable.

default_implementations: dict[str, str] = {}#

Mapping from member operation names to the designated default implementation of that operation. Filling this attribute allows one to define a different default implementation from the common default in builder.op_table to be used in the context of this composite gate. If a member operation is not found in this dict as a key, the CompositeGate will use the common default as its default implementation.

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 OILCalibrationData when validating it.

Returns:

Optional top-level calibration data keys.

Return type:

tuple[str, …]

build(op_name, locus, impl_name=None, *, strict_locus=False, priority_calibration=None)#

Construct an implementation for a member (registered) gate.

A custom calibration for op_name will be sought in calibration_data. If any calibration parameters are found, they override the corresponding parameters in the common calibration data.

Parameters:
  • op_name (str) – member operation name

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

  • impl_name (str | None) – Implementation name. If not given, uses the default implementation defined in the class instance if any, and otherwise the common default in builder.op_table.

  • 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

  • priority_calibration (dict[str, Any] | None) – If given, overrides the custom calibration for the member gate. Deprecated, should not be used.

Returns:

Calibrated member gate implementation.

Return type:

GateImplementation