mqt.core.plugins.qdmi_batch¶
Retained attempts and recovery of QDMI submissions.
Module Contents¶
- class JobFailure¶
An original exception and the operation that raised it.
- cause: BaseException¶
- class JobAttempt¶
Bases:
Generic[_Result]An attempt and its result index, or an uncertain submission without a handle.
- failures: tuple[JobFailure, ...] = ()¶
- class BatchEntry¶
Bases:
Generic[_Result]An input’s ordered attempts; indices refer to the adapter’s input batch.
- attempts: tuple[JobAttempt[_Result], ...] = ()¶
- class Batch(owner: _Owner, entries: Sequence[BatchEntry[_Result]], *, submit: Callable[[_Owner, int], Job] | None, decode: Callable[[_Owner, int, Job, int], _Result], submission_error: Callable[[_Owner, str], Exception], execution_error: Callable[[_Owner, str], Exception], max_retries: int, on_submit: Callable[[_Owner, Sequence[int]], None] | None = None, submit_programs: Callable[[_Owner, Sequence[int]], Job | None] | None = None, group_by: Sequence[Hashable] | None = None, supports_programs: Callable[[_Owner, Sequence[int]], bool] | None = None)¶
Bases:
Generic[_Owner,_Result]Shared recovery engine for the QDMI adapters.
A batch retains submission attempts and completed results so that an adapter can recover after a failure without repeating successful work. The adapter prepares all inputs before constructing the batch and converts device results to its own result type. A decoded result must not be None, which marks an unavailable result.
Submit and recover work through the adapter’s job handle. Operations on one batch are synchronous, and concurrent calls on the same batch are unsupported.
Entries with the same group key share one multi-program job when the device accepts it. If the device declines a group, the batch checks the largest accepted program count and submits the fewest near-equal contiguous parts. It halves a declined part down to single entries. Without a support check, it halves the declined group.
The batch holds only a weak reference to its owner, the adapter job that holds the batch, and passes the owner to every callback as the first argument. Callbacks must not capture the owner. Reference counting then releases the adapter job and its native QDMI jobs when the application drops its last reference, without the cyclic garbage collector.
- property entries: tuple[BatchEntry[_Result], ...]¶
Immutable snapshots without querying the provider.
- record_failure(index: int, stage: str, cause: BaseException, position: int = -1) None¶
Retain a failure without discarding the handle or a decoded result.
- submit(indices: Sequence[int] | None = None) None¶
Submit untouched entries, or all remaining untouched entries by default.
- Raises:
ValueError – If a selected entry has already been attempted.
- statuses() tuple[Status | None, ...]¶
Query each shared job once and return ordered per-entry outcomes.
Provider query failures propagate after being retained on the attempts.
- Returns:
None for untouched entries or uncertain submissions.
- collect(indices: Sequence[int] | None = None) tuple[BatchEntry[_Result], ...]¶
Collect existing attempts without replacements or aggregate failure.
- Returns:
Ordered entry snapshots, including every recorded failure.
- complete() None¶
Collect and replace confirmed failures within each entry’s lifetime budget.
The adapter’s error factory supplies aggregate and submission errors.