Skip to main contentIBM Quantum Documentation

Monitor or cancel a job

Jobs are listed on the Workloads page for your quantum service channel:

  • IBM Cloud® channel: From the IBM Cloud console quantum Instances page, click the name of your instance, then click the Jobs tab.
  • IBM Quantum™ channel: In IBM Quantum Platform, open the Workloads page.

Monitor a job

Use the job instance to check the job status or retrieve the results by calling the appropriate command:

job.result()Review job results immediately after the job completes. Job results are available after the job completes. Therefore, job.result() is a blocking call until the job completes.
job.job_id()Return the ID that uniquely identifies that job. Retrieving the job results at a later time requires the job ID. Therefore, it is recommended that you save the IDs of jobs you might want to retrieve later.
job.status()Check the job status.
job = service.job(<job_id>)Retrieve a job you previously submitted. This call requires the job ID.

Retrieve job results at a later time

Call service.job(\<job\_id>) to retrieve a job you previously submitted. If you don’t have the job ID, or if you want to retrieve multiple jobs at once; including jobs from retired QPUs (quantum processing units), call service.jobs() with optional filters instead. See QiskitRuntimeService.jobs.

Deprecated provider packages

service.jobs() also returns jobs run from the deprecated qiskit-ibm-provider package. Jobs submitted by the older (also deprecated) qiskit-ibmq-provider package are no longer available.

Example

This example returns the 10 most recent runtime jobs that were run on my_backend:

from qiskit_ibm_runtime import QiskitRuntimeService
 
# Initialize the account first.
service = QiskitRuntimeService()
 
service.jobs(backend_name=my_backend)

Cancel a job

You can cancel a job from the IBM Quantum Platform dashboard either on the Jobs page or the details page for a specific job. Click the menu with three vertical dots (at the end of the row on the Jobs page, or the top of the page on the Job details page), and select Cancel.

In Qiskit, use job.cancel() to cancel a job.


View Sampler execution spans

The results of SamplerV2 jobs executed in Qiskit Runtime contain execution timing information in their metadata. This timing information can be used to place upper and lower timestamp bounds on when particular shots were executed on the QPU. Shots are grouped into ExecutionSpan objects, each of which indicates a start time, a stop time, and a specification of which shots were collected in the span.

An execution span specifies which data was executed during its window by providing an ExecutionSpan.mask method. This method, given any Primitive Unified Block (PUB) index, returns a boolean mask that is True for all shots executed during its window. PUBs are indexed by the order in which they were given to the Sampler run call. If, for example, a PUB has shape (2, 3) and was run with four shots, then the mask's shape is (2, 3, 4). See the execution_span API page for full details.

Example:

# Get the mask of the 1st PUB for the 0th span.
mask = spans[0].mask(1)
 
# Decide whether the 0th shot of parameter set (1, 2) occurred in this span.
in_this_span = mask[1, 2, 0]
 
# Create a new bit array containing only the PUB-1 data collected during this span.
bits = pub_results[1].data.meas
filtered_data = BitArray(bits.array[mask], bits.num_bits)

To view execution span information, review the metadata of the result returned by SamplerV2, which comes in the form of an ExecutionSpans object. This object is a list-like container containing subclass instances of ExecutionSpans such as SliceSpan:

pub_results = job.result()
spans = pub_results.metadata["execution"]["execution_spans"]
for span in spans:
     print(span)

Output:

SliceSpan(<start='2024-09-09 11:48:21', stop='2024-09-09 11:48:22', size=1280>)
SliceSpan(<start='2024-09-09 11:48:21', stop='2024-09-09 11:48:25', size=1280>)
SliceSpan(<start='2024-09-09 11:48:21', stop='2024-09-09 11:48:24', size=1280>)
SliceSpan(<start='2024-09-09 11:48:21', stop='2024-09-09 11:48:27', size=1280>)
SliceSpan(<start='2024-09-09 11:48:21', stop='2024-09-09 11:48:26', size=1280>)
...

Execution spans can be filtered to include information pertaining to specific PUBs, selected by their indices:

# take the subset of spans that reference data in PUBs 0 or 2
spans.filter_by_pub([0, 2])

View global information about the collection of execution spans:

print("Number of execution spans:", len(spans))
print("  Start of the first span:", spans.start)
print("     End of the last span:", spans.stop)
print("       Total duration (s):", spans.duration)

Extract and inspect a particular span:

spans.sort()
print(" Start of first span:", spans[0].start)
print("   End of first span:", spans[0].stop)
print("#shots in first span:", spans[0].size)
Note

It is possible for time windows specified by distinct execution spans to overlap. This is not because a QPU was performing multiple executions at once, but is instead an artifact of certain classical processing that might happen concurrently with quantum execution. The guarantee being made is that the referenced data definitely occurred in the reported execution span, but not necessarily that the limits of the time window are as tight as possible.


Next steps

Recommendations
Was this page helpful?
Report a bug or request content on GitHub.