AQTJob#
- class qiskit_aqt_provider.aqt_job.AQTJob[source]#
Handle for quantum circuits jobs running on AQT backends.
Jobs contain one or more quantum circuits that are executed with a common set of options (see
AQTOptions
).Job handles should be retrieved from calls to
qiskit.execute
orAQTResource.run
, both of which immediately submit the job for execution. Theresult()
method allows blocking until a job completes:>>> import qiskit >>> from qiskit.providers import JobStatus >>> from qiskit_aqt_provider import AQTProvider ... >>> backend = AQTProvider("").get_backend("offline_simulator_no_noise") ... >>> qc = qiskit.QuantumCircuit(1) >>> _ = qc.rx(3.14, 0) >>> _ = qc.measure_all() ... >>> job = qiskit.execute(qc, backend, shots=100) >>> result = job.result() >>> job.status() is JobStatus.DONE True >>> result.success True >>> result.get_counts() {'1': 100}
- __init__(backend: AQTResource, circuits: List[QuantumCircuit], options: AQTOptions)[source]#
Initialize an
AQTJob
instance.Tip
AQTJob
instances should not be created directly. UseAQTResource.run
to submit circuits for execution and retrieve a job handle.- Parameters:
backend – backend to run the job on.
circuits – list of circuits to execute.
options – overridden resource options for this job.
- persist(*, store_path: Path | None = None) Path [source]#
Save this job to local persistent storage.
Warning
Only jobs that have been submitted for execution can be persisted (a valid job_id is required).
- Parameters:
store_path – local persistent storage directory. By default, use a standard cache directory.
- Returns:
The path to the job data in local persistent storage.
- Raises:
RuntimeError – the job was never submitted for execution.
- classmethod restore(job_id: str, *, access_token: str | None = None, store_path: Path | None = None, remove_from_store: bool = True) Self [source]#
Restore a job handle from local persistent storage.
Warning
The default local storage path depends on the qiskit_aqt_provider package version. Job persisted with a different package version will therefore not be found!
Hint
If the job’s execution backend is an offline simulator, the job is re-submitted to the simulation backend and the new job ID differs from the one passed to this function.
- Parameters:
job_id – identifier of the job to retrieve.
access_token – access token for the AQT cloud. See
AQTProvider
.store_path – local persistent storage directory. By default, use a standard cache directory.
remove_from_store – if
True
, remove the retrieved job’s data from persistent storage after a successful load.
- Returns:
A job handle for the passed job_id.
- Raises:
JobNotFoundError – the target job was not found in persistent storage.
- result() Result [source]#
Block until all circuits have been evaluated and return the combined result.
Success or error is signalled by the success field in the returned
Result
instance.- Returns:
The combined result of all circuit evaluations.
- status() JobStatus [source]#
Query the job’s status.
- Returns:
Aggregated job status for all the circuits in this job.
- submit() None [source]#
Submit this job for execution.
This operation is not blocking. Use
result()
to block until the job completes.- Raises:
RuntimeError – this job was already submitted.