qat.executables module

class AbstractProgram(**data)

Bases: RehydratableModel, ABC

Abstract base class for programs to be executed by an engine.

Child classes must implement the acquire_shapes property, which returns a mapping of acquisition output variables to the shape of the acquisition for this program. This specification enforces programs to be explicit about what acquisition outputs they will produce.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

abstract property acquire_shapes: dict[str, tuple[int, ...]]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class AcquireData(**data)

Bases: BaseModel

Holds the information required at runtime surrounding an acquisition.

Parameters:
  • mode – The type of acquisition performed on the hardware.

  • shape – The shape the data is expected to be returned in. Reflects the type of acquisition (e.g. scope or integrator mode), as well as the iteration structure (e.g. shots, loops). A shape of (1000,) would indicate 1000 shots of a single integrator acquisition.

  • physical_channel – The physical channel the acquisition is performed on, needed for post-processing reasons (e.g. error mitigation).

  • post_processing – A list of post-processing steps to be applied to the execution data.

  • results_processing – Contains information surrounding how the results should be formatted after post-processing.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

mode: AcquireMode
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

physical_channel: str
post_processing: list[PostProcessing]
results_processing: InlineResultsProcessing | None
shape: tuple[int, ...]
class Executable(**data)

Bases: BaseModel, Generic[Program]

Executable`s are packages of instructions that will be executed by the runtime. They contain a :class:`Program, or a number of :class:`Program`s to be executed by the engine. They also contain the acquire information, such as post-processing and result assignments.

Parameters:
  • programs – The program(s) to be executed against the engine.

  • assigns – Assigns results to given variables.

  • returns – Which acqusitions/variables should be returned.

  • calibration_id – The (unique) cabliration ID of the underlying hardware model.

  • shots – The total number of shots performed in the Executable.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

acquires: dict[str, AcquireData]
assigns: list[Assign]
calibration_id: str
classmethod deserialize(blob)

Instantiates a executable from a JSON blob.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

programs: list[TypeVar(Program, bound= AbstractProgram)]
returns: set[str]
serialize(indent=4)

Serializes the executable as a JSON blob.

Return type:

str

shots: Optional[Annotated[int]]