fiqci.ems.backend.jobs#
Classes
|
Lazy handle over one or more backend jobs submitted as ordered batches. |
|
Lazy view over a |
|
Snapshot of a single batch within a multi-batch job. |
Exceptions
Raised when one or more batches of a submitted job fail. |
- exception BatchFailedError#
Bases:
RuntimeErrorRaised when one or more batches of a submitted job fail.
The message identifies the failing batch by its index and the range of original circuit indices it covered, so callers can map the failure back to their input.
- class PartialBatch(index: int, circuit_range: tuple[int, int], status: JobStatus, job_id: str, result: Result | None)#
Bases:
NamedTupleSnapshot of a single batch within a multi-batch job.
- index#
Position of the batch in submission order.
- Type:
int
- circuit_range#
(start, end_exclusive)original circuit indices covered by the batch.- Type:
tuple[int, int]
- status#
Current
JobStatusof the batch job.- Type:
qiskit.providers.jobstatus.JobStatus
- job_id#
Backend job id of the batch.
- Type:
str
- result#
The batch’s
Resultif it has completed, elseNone.- Type:
qiskit.result.result.Result | None
- index: int#
Alias for field number 0
- circuit_range: tuple[int, int]#
Alias for field number 1
- status: JobStatus#
Alias for field number 2
- job_id: str#
Alias for field number 3
- result: Result | None#
Alias for field number 4
- class BatchedJob(jobs: list[JobV1], batch_ranges: list[tuple[int, int]] | None = None, post_process: Callable[[Result], Result] | None = None, mitigator_options: dict[str, Any] | None = None)#
Bases:
objectLazy handle over one or more backend jobs submitted as ordered batches.
A larger circuit list is split into batches that are each submitted to the backend; this wrapper holds the resulting per-batch jobs. It is returned immediately from
FiQCIBackend.run()(the submission loop does not wait for results), so callers can inspectjob_ids()and pollstatus()/done()right away.Calling
result()blocks until every batch reaches a terminal state, then concatenates the batches’resultslists in submission order (soget_counts(idx)on the combined Result corresponds to the original circuit index) and runs the optionalpost_processcallback that applies error mitigation. The combined/post-processed result is computed once and cached. If any batch failed,result()raisesBatchFailedErroridentifying the batch and the original circuit indices it covered.- __init__(jobs: list[JobV1], batch_ranges: list[tuple[int, int]] | None = None, post_process: Callable[[Result], Result] | None = None, mitigator_options: dict[str, Any] | None = None) None#
Initialize the handle.
- Parameters:
jobs – Per-batch jobs in submission order. Must be non-empty.
batch_ranges –
(start, end_exclusive)original circuit-index range for each batch, used for partial-result reporting and failure messages. If omitted, ranges are reported as best-effort placeholders.post_process – Optional callback mapping the combined raw Result to the final (mitigated) Result. Runs once on the first
result()call.mitigator_options – Frozen snapshot of the mitigation settings used at submission time, exposed via
mitigator_options.Nonewhen unknown.
- property mitigator_options: dict[str, Any] | None#
Mitigation settings frozen at submission time (
mitigation_level,rem,dd,pauli_twirl).Unlike
FiQCIBackend.mitigator_options(which is live and mutable), this reports the configuration this job actually ran with and never changes.Noneif no snapshot was attached.
- job_id() str#
Backend job id of the first batch (for single-job back-compat).
- job_ids() list[str]#
Backend job ids of every batch, in submission order.
- statuses() list[JobStatus]#
Current
JobStatusof each batch, in submission order.
- status() JobStatus#
Single aggregated status across all batches (see
_aggregate_status()).
- done() bool#
True once every batch has reached a terminal state (DONE/ERROR/CANCELLED).
- all_succeeded() bool#
True once every batch has completed successfully (DONE).
- partial_results() list[PartialBatch]#
Per-batch snapshot, exposing results for batches that have already completed.
Each entry carries the batch’s status and, for completed (DONE) batches, its Result. Batches that are still running or have failed report
result=None. Results are exposed at batch granularity only; the globally-indexed combined Result is available fromresult()once all batches are terminal.
- result(timeout: float | None = None) Result#
Return the combined, post-processed result, computed once and cached.
Blocks until every batch is terminal. Raises
BatchFailedErrorif any batch failed, otherwise concatenates batch results in submission order and applies thepost_processcallback (if any).- Parameters:
timeout – Best-effort total budget (seconds) shared across all batches.
- class MitigatedJob(handle: BatchedJob)#
Bases:
objectLazy view over a
BatchedJobwhose result has error mitigation applied.The mitigation work is deferred to the wrapped handle’s
post_processcallback, so this wrapper simply exposes the handle’s polling API and aresult()that returns the mitigated, combined Result. It exists as a distinct type so callers and tests can detect that mitigation was configured for the run.- __init__(handle: BatchedJob) None#
Initialize the wrapper.
- Parameters:
handle – The submission handle carrying the batch jobs and the mitigation
post_processcallback.
- result(timeout: float | None = None) Result#
Return the mitigated, combined result (computed once by the underlying handle).