AsyncJobBackend¶
- class AsyncJobBackend(*args, **kwargs)[source]¶
Bases:
ProtocolBackend that runs circuits as an asynchronous remote job.
Implementations submit work to a scheduler (cloud HPC, hardware queue, etc.) and return an
ExecutionResultcarrying ajob_idrather than circuit results. Callers then poll for status viapoll_job_status(), fetch outcomes withget_job_results(), and maycancel_job()an in-flight handle.Attributes Summary
Number of measurement shots applied to sampling-mode circuits.
Methods Summary
cancel_job(execution_result)Request cancellation of an in-flight job.
get_job_results(execution_result)Fetch results for a completed job and return them populated.
poll_job_status(execution_result[, ...])Query the scheduler-side job state; optionally block until terminal.
submit_circuits(circuits, *[, ...])Submit a batch of QASM circuits and return a handle.
Attributes Documentation
- shots¶
Number of measurement shots applied to sampling-mode circuits.
Methods Documentation
- cancel_job(execution_result)[source]¶
Request cancellation of an in-flight job.
Must be idempotent: cancelling a job already in a terminal state is a normal race outcome and should not raise (a 409 from the scheduler is acceptable to either swallow or surface as a recognisable exception that callers can ignore).
- Return type:
- get_job_results(execution_result)[source]¶
Fetch results for a completed job and return them populated.
Must only be called after
poll_job_status()reports aCOMPLETEDJobStatus.- Return type:
- poll_job_status(execution_result, loop_until_complete=False, on_complete=None, verbose=True, progress_callback=None, cancellation_event=None)[source]¶
Query the scheduler-side job state; optionally block until terminal.
- Parameters:
execution_result (
ExecutionResult) – Handle returned bysubmit_circuits().loop_until_complete (
bool) – IfTrue, poll until a terminal status (COMPLETED/FAILED/CANCELLED); otherwise return after a single query.on_complete (
Callable[[Response],None] |None) – Invoked with the final HTTP response when a terminal status is reached.verbose (
bool) – WhenTrue, log per-poll status. Disable when rendering progress viaprogress_callbackso user-facing output isn’t doubled.progress_callback (
Callable[[int,str],None] |None) – Called as(poll_attempt, status_str)for progress-bar updates.cancellation_event (
Event|None) – When set, the loop exits by raisingExecutionCancelledError. In-flight HTTP requests are not interrupted — cancellation latency is bounded by the per-request timeout.
- Returns:
The most recent
JobStatus.
- submit_circuits(circuits, *, cancellation_event=None, **kwargs)[source]¶
Submit a batch of QASM circuits and return a handle.
The returned
ExecutionResultcarries the scheduler-sidejob_idbut no circuit results; populate it viaget_job_results()once polling reports a terminal status.- Parameters:
circuits (
Mapping[str,str]) – Mapping of unique label → OpenQASM source.cancellation_event (
Event|None) – When set, the implementation should refuse to dispatch (or short-circuit dispatch) and raiseExecutionCancelledError. The same event is honoured bypoll_job_status()to interrupt an in-flight polling loop.**kwargs – Backend-specific options (
ham_ops,shot_groups, …).
- Return type: