IonQ Job¶
IonQ’s Job implementation.
Note
IonQ job status names are slightly different than those of the standard
JobStatus
enum values.
As such, the IonQJob.status()
method on the IonQJob class attempts to
perform a mapping between these status values for compatibility with
BaseJob
.
- class qiskit_ionq.ionq_job.IonQJob(backend: ionq_backend.IonQBackend, job_id: str | None = None, client: ionq_client.IonQClient | None = None, circuit: QuantumCircuit | None = None, passed_args: dict | None = None)[source]¶
Representation of a Job that will run on an IonQ backend.
It is not recommended to create Job instances directly, but rather use the
run
andretrieve_job
methods on sub-class instances of IonQBackend to create and retrieve jobs (both methods return a job instance).- circuit¶
A possibly
None
Qiskit quantum circuit.- Type:
QuantumCircuit
- _result¶
The actual Qiskit Result of this job when done.
- Type:
Result
Initializes the asynchronous job.
- Parameters:
backend – the backend used to run the job.
job_id – a unique id in the context of the backend used to run the job.
kwargs – Any key value metadata to associate with this job.
- backend() Backend ¶
Return the backend where this job was executed.
- cancelled() bool ¶
Return whether the job has been cancelled.
- done() bool ¶
Return whether the job has successfully run.
- get_counts(circuit: QuantumCircuit | None = None) dict [source]¶
Return the counts for the job.
Attention
Result counts for jobs processed by
IonQSimulatorBackend
are returned from the API as probabilities, and are converted to counts via simple statistical sampling that occurs on the cient side.To obtain the true probabilities, use the get_probabilties() method instead.
- Parameters:
circuit (str or QuantumCircuit or int or None) – Optional. The index of the experiment.
- Returns:
A dictionary of counts.
- Return type:
dict
- get_probabilities(circuit=None)[source]¶
Return the probabilities for the job.
- This is effectively a pass-through to
- Parameters:
circuit (str or QuantumCircuit or int or None) – Optional.
- Returns:
A tuple counts, probabilities.
- Return type:
tuple(dict[str, float], dict[str, float])
- in_final_state() bool ¶
Return whether the job is in a final job state such as
DONE
orERROR
.
- job_id() str ¶
Return a unique id identifying the job.
- result(sharpen: bool | None = None, extra_query_params: dict | None = None, **kwargs)[source]¶
Retrieve job result data.
This method calls the
wait_for_final_state
method to poll for a completed job.- Raises:
IonQJobTimeoutError – If after the default wait period in
wait_for_final_state
elapses and the job has not reached a “final” state.IonQJobError – If the job has reached a final state but the job itself was never converted to a
Result
.
- Returns:
A Qiskit
Result
representation of this job.- Return type:
Result
- running() bool ¶
Return whether the job is actively running.
- status(detailed: bool = False) JobStatus | dict [source]¶
Retrieve the status of a job
- Parameters:
detailed (bool) – If True, returns a detailed status of children.
- Returns:
- An enum value from Qiskit’s
JobStatus
if detailed is False. A dictionary containing the detailed status of the children if detailed is True.
- Return type:
JobStatus or dict
- Raises:
IonQJobError – If the IonQ job status was unknown or otherwise unmappable to a qiskit job status.
IonQJobFailureError – If the job fails
IonQJobStateError – If the job was cancelled
- submit() None [source]¶
Submit a job to the IonQ API.
- Raises:
IonQJobError – If this instance’s
qobj
was None.
- wait_for_final_state(timeout: float | None = None, wait: float = 5, callback: Callable | None = None) None ¶
Poll the job status until it progresses to a final state such as
DONE
orERROR
.- Parameters:
timeout – Seconds to wait for the job. If
None
, wait indefinitely.wait – Seconds between queries.
callback –
Callback function invoked after each query. The following positional arguments are provided to the callback function:
job_id: Job ID
job_status: Status of the job from the last query
job: This BaseJob instance
Note: different subclass might provide different arguments to the callback function.
- Raises:
JobTimeoutError – If the job does not reach a final state before the specified timeout.