Maximum execution time for Qiskit Runtime workloads
To ensure fairness, there is a service-calculated maximum amount of time each Qiskit Runtime job can run. If a job exceeds this time limit, it is forcibly canceled and a RuntimeJobMaxTimeoutError exception is raised. You can also set a maximum execution time on your jobs to help control costs.
The session or batch is immediately terminated when the cost limit is reached. Any jobs currently running in that session or batch will run to completion, but any pending jobs will be canceled.
Set a maximum execution time
The maximum execution time for a job is the smaller of these values:
- The value set for
max_execution_time - The service-determined job timeout value
The max_execution_time value is based on QPU usage, not wall clock time.
Set the maximum execution time (in seconds) on the job options, as shown in the following example. See the Estimator options, Sampler options, or Executor options guides for information about setting options.
from qiskit_ibm_runtime import QiskitRuntimeService
from qiskit_ibm_runtime import EstimatorV2 as Estimator
service = QiskitRuntimeService()
backend = service.least_busy(operational=True, simulator=False)
estimator = Estimator(mode=backend)
estimator.options.max_execution_time = 2500You can also find how much usage completed jobs have consumed by returning the job metrics as follows:
# Find QPU usage of a specific job
print(f"QPU usage of job {job.job_id()} was {job.metrics()['usage']['quantum_seconds']} seconds")Service-calculated maximum execution time
The service calculates an appropriate job timeout value based on the input circuits and options. This service-calculated timeout is capped at 3 hours to ensure fair device usage. If a max_execution_time is also specified for the job, the lesser of the two values is used.
For example, if you specify max_execution_time=5000 (approximately 83 minutes), but the service determines it should not take more than 5 minutes (300 seconds) to execute the job, then the job is canceled after 5 minutes.
Batch maximum execution time
When a batch is started, it is assigned a maximum time to live (maximum TTL) value. After this TTL is reached, the batch is terminated, any jobs that are already running continue running, and any queued jobs that remain in the batch are put into a failed state.
Batches also have an interactive time to live (interactive TTL) value between jobs that cannot be configured. If you don't explicitly close a batch, it is deactivated after the interactive TTL expires and can be reactivated at any time until it reaches its maximum TTL.
For instructions to work with these values, see Run jobs in a batch.
Session maximum execution time
When a session is started, it is assigned a maximum TTL value that determines how long a session can run. After this TTL is reached, the session is terminated, any jobs that are already running continue running, and any queued jobs that remain in the session are put into a failed state.
There is also an interactive TTL value that cannot be configured. If no session jobs are queued within that window, the session is temporarily deactivated.
For instructions to work with these values, see Run jobs in a session.
Other limitations
- Inputs to jobs cannot exceed 50MB in size.
- On the Open Plan, you can use up to 10 minutes on a QPU per 28-day rolling window. You can view an instance's usage on the Instances page.
Next steps
- Workload usage.
- Review these tips: Minimize job run time.