mqt.ionshuttler.linear.actions¶
Actions supported by the Linear hardware model and compiler.
Malformed serialized action values raise ValueError because they represent
invalid saved data rather than incorrect Python API argument types.
Module Contents¶
- class Action[source]¶
Bases:
abc.ABCAn operation that the Linear compiler can place in a schedule.
Hardware models can introduce new operations by subclassing
Actionand defining when they are available and how they change the state. Decisions involving several operations or circuit dependencies remain with the compiler.- classmethod from_dict(data: Mapping[str, object]) Action[source]¶
Restore an action from its serialized dataclass fields.
Actions containing nested values can override this method.
- Returns:
The restored action.
- Raises:
ValueError – If the saved fields cannot construct the action.
- classmethod available_actions(state: State, architecture: Architecture, transport_timing: TransportTiming) Iterable[Action][source]¶
Return instances this action type makes available in a given state.
Action types that are not generated directly by the compiler return no instances by default.
- is_valid(state: State, architecture: Architecture) bool[source]¶
Return whether this action can start in the current state.
Actions without their own restrictions are available by default. This check considers one action at a time; the compiler separately checks interactions between simultaneous actions.
- abstractmethod apply(state: State, architecture: Architecture) State[source]¶
Return the state produced when this action starts.
Physical actions leave circuit-progress tracking unchanged. Callers should check
is_valid()before applying an action.
- class SchedulableAction[source]¶
Bases:
ActionAn action that may appear in a compiled schedule.
- __post_init__() None[source]¶
Validate an action’s duration when it defines one.
- Raises:
TypeError – If the duration is not an integer.
ValueError – If the duration is not a positive integer.
- class PhysicalAction[source]¶
Bases:
SchedulableActionA control operation exposed by the hardware model.
Physical actions update ion placement or hardware availability while leaving the compiler’s circuit-progress tracking unchanged.
- class TransportAction[source]¶
Bases:
PhysicalActionA hardware operation that changes where ions are located.
- class Shuttle[source]¶
Bases:
TransportActionMove one ion between adjacent sites.
- classmethod from_dict(data: Mapping[str, object]) Action[source]¶
Restore a shuttle from serialized fields.
- Returns:
The restored shuttle.
- classmethod available_actions(state: State, architecture: Architecture, transport_timing: TransportTiming) Iterable[Action][source]¶
Return shuttles to adjacent empty sites for every free ion.
- is_valid(state: State, architecture: Architecture) bool[source]¶
Return whether the ion can move into an adjacent empty site.
- apply(state: State, architecture: Architecture) State[source]¶
Move the ion and reserve it for the configured duration.
- Returns:
The updated state with compiler progress preserved.
- class PhysicalSwap[source]¶
Bases:
TransportActionExchange two ions occupying adjacent sites.
- classmethod from_dict(data: Mapping[str, object]) Action[source]¶
Restore a physical swap from serialized fields.
- Returns:
The restored swap.
- classmethod available_actions(state: State, architecture: Architecture, transport_timing: TransportTiming) Iterable[Action][source]¶
Return adjacent swaps between pairs of free ions.
- is_valid(state: State, architecture: Architecture) bool[source]¶
Return whether two free ions occupy the specified adjacent sites.
- apply(state: State, architecture: Architecture) State[source]¶
Exchange both positions and reserve both ions.
- Returns:
The updated state with compiler progress preserved.
- class GateAction[source]¶
Bases:
PhysicalActionA gate operation supported by the hardware model.
- classmethod from_instruction(ions: tuple[int, ...], parameters: tuple[float, ...], timing: GateTiming) GateAction[source]¶
Create a gate from frontend-independent circuit operands.
- Raises:
ValueError – If the gate type does not support circuit lowering.
- class SingleQubitGate[source]¶
Bases:
GateActionA rotation acting on one ion, implemented physically or virtually.
A virtual rotation changes the logical frame without occupying hardware time or a processing zone, but it remains part of the compiled circuit. A physical rotation uses the ion and its processing zone, even when a hardware abstraction assigns it zero duration.
- classmethod from_instruction(ions: tuple[int, ...], parameters: tuple[float, ...], timing: GateTiming) GateAction[source]¶
Create a single-ion rotation from normalized circuit operands.
- Returns:
The lowered gate.
- classmethod from_dict(data: Mapping[str, object]) Action[source]¶
Restore a single-ion gate from serialized fields.
- Returns:
The restored gate.
- __post_init__() None[source]¶
Validate virtuality and duration consistency.
- Raises:
TypeError – If
virtualis not Boolean.ValueError – If the duration is invalid or a virtual gate has nonzero duration.
- Warns:
UserWarning – If a physical gate has zero duration.
- is_valid(state: State, architecture: Architecture) bool[source]¶
Return whether the target ion and physical resources are eligible.
- apply(state: State, architecture: Architecture) State[source]¶
Reserve physical resources, or leave machine state unchanged if virtual.
- Returns:
The updated state with compiler progress preserved.
- class TwoQubitGate[source]¶
Bases:
GateActionA gate acting on two ions in the same processing zone.
- classmethod from_instruction(ions: tuple[int, ...], parameters: tuple[float, ...], timing: GateTiming) GateAction[source]¶
Create a two-ion gate from normalized circuit operands.
- Returns:
The lowered gate.
- classmethod from_dict(data: Mapping[str, object]) Action[source]¶
Restore a two-ion gate from serialized fields.
- Returns:
The restored gate.
- is_valid(state: State, architecture: Architecture) bool[source]¶
Return whether both free ions occupy one free processing zone.
- apply(state: State, architecture: Architecture) State[source]¶
Reserve both ions and their shared processing zone.
- Returns:
The updated state with compiler progress preserved.
- class Rx[source]¶
Bases:
SingleQubitGateRotate one ion around the x axis.
- class Ry[source]¶
Bases:
SingleQubitGateRotate one ion around the y axis.
- class Rz[source]¶
Bases:
SingleQubitGateRotate one ion around the z axis.
The rotation is virtual by default to align with typical trapped-ion hardware implementations. Set
virtual=Falseto model a physical implementation subject to ordinary scheduling-resource checks.
- class Rxx[source]¶
Bases:
TwoQubitGateRotate two ions around the xx axis.
- class Ryy[source]¶
Bases:
TwoQubitGateRotate two ions around the yy axis.
- class Rzz[source]¶
Bases:
TwoQubitGateRotate two ions around the zz axis.
- class GlobalPulse[source]¶
Bases:
GateActionApply one gate to ions simultaneously, as in coil-based microwave control.
The default Linear model treats this pulse as non-blocking w.r.t to other gates. A hardware model with shared-drive conflicts can subclass it and provide stricter validity and state-update behavior.
- classmethod from_dict(data: Mapping[str, object]) Action[source]¶
Restore a global pulse and its nested gate description.
- Returns:
The restored pulse.
- apply(state: State, architecture: Architecture) State[source]¶
Return the state with hardware availability unchanged.
- class AdvanceTime[source]¶
Bases:
SchedulableActionMove the schedule forward by one timestep.
This is a compiler operation advancing the clock state and has no real hardware equivalent. It allows running operations to finish before further actions are scheduled.
- classmethod from_dict(data: Mapping[str, object]) Action[source]¶
Restore the scheduler’s AdvanceTime marker.
- Returns:
The restored marker.
- apply(state: State, architecture: Architecture) State[source]¶
Advance time and finish operations due by the next timestep.
- Returns:
The state at the next compiler timestep.
- build_action_type_registry(action_types: Iterable[type[Action]] | None = None, *, include_advance_time: bool = True) dict[str, type[Action]][source]¶
Return built-in and caller-provided action classes by serialized name.
- Returns:
A mapping from serialized action name to its action class.
- Raises:
TypeError – If a supplied entry is not an action class.
ValueError – If two different action classes have the same serialized name.