qiskit-documentation/docs/guides/max-execution-time.ipynb

146 lines
7.1 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"id": "175ff1e8-9d71-4396-9936-37304fa5df1c",
"metadata": {},
"source": [
"# Maximum execution time for Qiskit Runtime workloads"
]
},
{
"cell_type": "markdown",
"id": "653b0c37-be57-49af-b8fe-d60e3bbdc939",
"metadata": {
"tags": [
"version-info"
]
},
"source": []
},
{
"cell_type": "markdown",
"id": "a0d6acc5-754c-4955-8cf0-5e3e12b9dd1f",
"metadata": {},
"source": [
"<LegacyContent>\n",
"<Admonition type=\"note\">\n",
"This documentation is relevant to IBM Quantum&reg; Platform Classic. If you need the newer version, go to the new [IBM Quantum Platform documentation.]( https://quantum.cloud.ibm.com/docs/guides/max-execution-time)\n",
"</Admonition>\n",
"</LegacyContent>\n",
"<CloudContent>\n",
"<Admonition type=\"note\">\n",
"This documentation is relevant to the new IBM Quantum&reg; Platform. If you need the previous version, return to the [IBM Quantum Platform Classic documentation.](https://docs.quantum.ibm.com/guides/max-execution-time)\n",
"</Admonition>\n",
"</CloudContent>\n",
"\n",
"To ensure fairness and help control costs, there is a 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.\n",
"<LegacyContent>\n",
" <Admonition>\n",
" If you use Qiskit Runtime on IBM Cloud&reg;, the session or batch is immediately terminated when the cost limit is reached.\n",
"</Admonition>\n",
"</LegacyContent>\n",
"<CloudContent>\n",
" <Admonition>\n",
" The session or batch is immediately terminated when the cost limit is reached.\n",
"</Admonition>\n",
"</CloudContent>\n",
"<span id=\"max-job\"></span>\n",
"## Job maximum execution time\n",
"\n",
"The maximum execution time for a job is the smaller of these values:\n",
"\n",
"- The value set for `max_execution_time`\n",
"- The service-determined job timeout value\n",
"\n",
"The `max_execution_time` value is based on _quantum time_, not wall clock time. Quantum time is the amount of time that the QPU is dedicated to processing your job. Simulator jobs use wall clock time because they do not have quantum time.\n",
"\n",
"Set the maximum execution time (in seconds) on the job options, as shown in the following example. See [Specify options](/docs/guides/specify-runtime-options) for information about setting options.\n",
"\n",
"```python\n",
"from qiskit_ibm_runtime import QiskitRuntimeService\n",
"from qiskit_ibm_runtime import EstimatorV2 as Estimator\n",
"\n",
"service = QiskitRuntimeService()\n",
"backend = service.least_busy(operational=True, simulator=False)\n",
"\n",
"estimator = Estimator(mode=backend)\n",
"\n",
"estimator.options.max_execution_time = 2500\n",
"```\n",
"\n",
"You can also find how much quantum time completed jobs have used by returning the job metrics as follows:\n",
"\n",
"```python\n",
"# Find quantum time used by the job\n",
"print(f\"Quantum time used by job {job.job_id()} was {job.metrics()['usage']['quantum_seconds']} seconds\")\n",
"```\n",
"\n",
"<span id=\"max-QPU\"></span>\n",
"### Service-calculated maximum execution time\n",
"\n",
"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.\n",
"\n",
"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.\n",
"\n",
"<span id=\"batch-max-time\"></span>\n",
"## Batch maximum execution time\n",
"\n",
"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.\n",
"\n",
"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.\n",
"\n",
"For instructions to work with these values, see [Run jobs in a batch.](/docs/guides/run-jobs-batch)\n",
"\n",
"<span id=\"session-max-time\"></span>\n",
"## Session maximum execution time\n",
"\n",
"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.\n",
"\n",
"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.\n",
"\n",
"For instructions to work with these values, see [Run jobs in a session.](/docs/guides/run-jobs-session)\n",
"\n",
"## Other limitations\n",
"<LegacyContent>\n",
"* Inputs to jobs cannot exceed 64MB in size.\n",
"* Open Plan users can use up to 10 minutes of quantum time per month (resets at 00:00 UTC on the first of each month). Quantum time is the amount of time that the QPU is dedicated to processing your job. You can track your monthly usage on the [Platform dashboard,](https://quantum.ibm.com/) [IBM Quantum&reg; Platform Workloads page,](https://quantum.ibm.com/workloads) and [Account](https://quantum.ibm.com/account) page.\n",
"</LegacyContent>\n",
"<CloudContent>\n",
"* Inputs to jobs cannot exceed 50MB in size.\n",
"* Open Plan users can use up to 10 minutes of quantum time per month. Quantum time is the amount of time that the QPU is dedicated to processing your job. You can view an instance's usage on the [Instances](https://quantum.cloud.ibm.com/instances) page.\n",
"</CloudContent>\n",
"## Next steps\n",
"\n",
"<Admonition type=\"tip\" title=\"Recommendations\">\n",
" - [Workload usage](estimate-job-run-time).\n",
" - Review these tips: [Minimize job run time](minimize-time).\n",
"</Admonition>"
]
}
],
"metadata": {
"description": "Describes how long a Qiskit Runtime job can run, regardless of what execution mode is used.",
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3"
},
"title": "Maximum execution time for Qiskit Runtime workloads"
},
"nbformat": 4,
"nbformat_minor": 4
}