IterationTracker#
Module: iqm.iqm_client.iqm_client
- class iqm.iqm_client.iqm_client.IterationTracker(client: IQMClient, iteration_data: IterationData)#
Bases:
objectContext and lifecycle manager for an iteration on IQM Server.
An iteration is an exclusive timeslot for a particular quantum computer on IQM Server, during which only the jobs the iteration owner submits to the iteration-specific job queue are being executed on that quantum computer. Hence it e.g. enables workflows based on quick quantum-classical iteration, such as various quantum optimization algorithms. Unlike the normal timeslots which are reserved in advance and take place during a fixed time interval, iterations can be requested on demand, and can be ended at any time.
A new iteration is requested using
IQMClient.request_iteration(), which returns an instance of this class if successful. The request goes into the normal server job queue, and once it reaches the front of the queue the iteration becomes active.An existing iteration can be queried using
IQMClient.get_iteration().
The user is billed for the entire time from when the iteration becomes active, until either the iteration or the last executed job in the iteration ends, whichever comes last. This means that keeping the iteration active costs, whether jobs are executing in it or not, since it reserves the quantum computer for your exclusive use.
The user can end the iteration anytime (even before it has become active) using
end(). This will also cancel the jobs submitted into the iteration that have not started executing yet. The same happens if the iteration ends on its own when it reaches its maximum duration. The currently executing job(s) are allowed to finish.IterationTrackercan be used as a context manager, in which case it ends the iteration automatically when you exit the context.For the exact description on how the iteration workflow and billing works, see the IQM Server API documentation on IQM Resonance.
- Parameters:
client (IQMClient) – Client used to connect to the server.
iteration_data (IterationData) – Properties of the iteration, obtained from IQM Server.
Attributes
Unique ID of the iteration.
Last queried status of the iteration.
IQMClient used to connect to the server where the iteration takes place.
Last known status and other properties of the iteration.
Methods
End the iteration.
Get trackers for all the jobs submitted to the given iteration.
Submit a batch of quantum circuits for execution in the iteration.
Submit a run definition for execution.
Refresh
iteration_databy querying the server, unless the status is already terminal.Poll the server for the iteration status until it is no longer WAITING, or until we hit a timeout.
- client#
IQMClient used to connect to the server where the iteration takes place.
- iteration_data#
Last known status and other properties of the iteration. Updated by
update(),wait_until_active()andend().
- property status: IterationStatus#
Last queried status of the iteration.
Note
This is not necessarily the same as the current status of the iteration, unless the status is terminal! To get the current status, use
update().
- update() IterationStatus#
Refresh
iteration_databy querying the server, unless the status is already terminal.Once the iteration reaches a terminal status (see
IterationStatus.terminal_statuses()),iteration_datano longer changes, so this method skips the server query and returns the cached status instead.- Returns:
Current status of the iteration (included in the refreshed iteration data).
- Return type:
IterationStatus
- wait_until_active(*, timeout_secs: float = 10800.0, polling_interval: float = 1.0) IterationStatus#
Poll the server for the iteration status until it is no longer WAITING, or until we hit a timeout.
The iteration stops waiting either by becoming
IterationStatus.ACTIVE, or by reaching a terminal status (seeIterationStatus.terminal_statuses()) without ever becoming active, e.g. if it is ended before its turn comes up.Will stop the polling (but does not end the iteration) upon receiving a KeyboardInterrupt (Ctrl-C). If you want to end the iteration, call
end().Updates
iteration_data.- Parameters:
- Returns:
Last seen iteration status. Not necessarily
IterationStatus.ACTIVE, see above.- Raises:
KeyboardInterrupt – Received Ctrl-C while waiting for the iteration to become active.
- Return type:
IterationStatus
- jobs() Iterator[JobTracker]#
Get trackers for all the jobs submitted to the given iteration.
- Returns:
Trackers for each job submitted to the iteration.
- Return type:
Iterator[JobTracker]
- end() None#
End the iteration.
See
IQMServerExecutor.end_iteration()for the exact semantics of ending an iteration, and the statuses involved.Updates
iteration_data.- Return type:
None
- submit_circuits(circuits: list[Circuit | _Circuit | str], *, qubit_mapping: WithJsonSchema(json_schema={'anyOf': [{'type': 'array', 'items': {'type': 'object', 'required': ['logical_name', 'physical_name'], 'properties': {'logical_name': {'type': 'string'}, 'physical_name': {'type': 'string'}}, 'additionalProperties': False}}, {'type': 'null'}]}, mode=None)] | None = None, calibration_set_id: UUID | None = None, shots: int = 1, options: CircuitCompilationOptions | None = None) CircuitJobTracker#
Submit a batch of quantum circuits for execution in the iteration.
See
IQMClient.submit_circuits().- Parameters:
qubit_mapping (Annotated[dict[str, str], BeforeValidator(func=~iqm.station_control.interface.models.circuit._parse_legacy_qubit_mapping, json_schema_input_type=PydanticUndefined), PlainSerializer(func=~iqm.station_control.interface.models.circuit._serialize_as_legacy_qubit_mapping, return_type=PydanticUndefined, when_used=always), WithJsonSchema(json_schema={'anyOf': [{'type': 'array', 'items': {'type': 'object', 'required': ['logical_name', 'physical_name'], 'properties': {'logical_name': {'type': 'string'}, 'physical_name': {'type': 'string'}}, 'additionalProperties': False}}, {'type': 'null'}]}, mode=None)] | None)
calibration_set_id (UUID | None)
shots (int)
options (CircuitCompilationOptions | None)
- Return type:
CircuitJobTracker
Inheritance
