Skip to content

Commit

Permalink
Fast forward experimental to latest main (#1178)
Browse files Browse the repository at this point in the history
* Remove min execution time check (#1065)

* Remove min execution time check

* update unit test

* remove integration test

* Update `max_execution_time` docstrings (#1059)

* Update max_execution_time docstrings

* add commas

* Update qiskit_ibm_runtime/options/options.py

Co-authored-by: Rebecca Dimock <66339736+beckykd@users.noreply.github.com>

* Update qiskit_ibm_runtime/options/options.py

Co-authored-by: Rebecca Dimock <66339736+beckykd@users.noreply.github.com>

* Update qiskit_ibm_runtime/runtime_options.py

Co-authored-by: Rebecca Dimock <66339736+beckykd@users.noreply.github.com>

* Update releasenotes/notes/max-execution-time-definition-196cb6297693c0f2.yaml

Co-authored-by: Rebecca Dimock <66339736+beckykd@users.noreply.github.com>

---------

Co-authored-by: Rebecca Dimock <66339736+beckykd@users.noreply.github.com>

* Removed remaining code related to Schedules (#1068)

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* Enable datetime parameter for backend properties (#1070)

* enable datetime param for backend properties

* add test & reno

* improve test

* Update default resilience options (#1062)

* remove default resilience options

* add reno

* add logic to override default

* add test

* purge None values from options

* fix test (#1074)

* Prepare release 0.12.1 (#1075)

* Update main branch veresion 0.12.2 (#1076)

* use ibmq_qasm_simulator (#1078)

* Add reason code to error message (#1072)

* Add reason code to error message

* add reno

* Remove importing PauliSumOp, which is deprecated. (#1079)

---------

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* Adjusts default value for optimization_level (#1082)

* add instance info (#1083)

* add instance info

* Add cloud note

* Update README.md

Co-authored-by: Kevin Tian <kt474@cornell.edu>

---------

Co-authored-by: Kevin Tian <kt474@cornell.edu>

* Fix links to options in README.md (#1084)

* Remove auth parameter (#1077)

* Removed auth parameter

* Removed calls to migrate()

* black and lint

---------

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* Remove opflow and algorithms from serialization tests (#1085)

* Remove opflow from tests

* Re-add test for PauliSumOp

* Fix lint

* Fix black

---------

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* RuntimeJobTimeoutError should inherit from JobTimeoutError (#1090)

* RuntimeJobTimeoutError inherits from JobTimeoutError

* black

---------

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* Allow user to define a default account as an environment variable (#1018)

* Allow user to define a default account as an environment variable

* Fixed test

* Fixed mistaken paste

* Cleaned up test

* Moved test to TestAccountManager

* Added ability to define default channel in save_account

* Cleaned up code, fixed bugs

* Changed name of parameter

* Added test. Cleaned up code surrounding preferences of channel selection

* black and lint

* Fixed bug when json file was empty

* Code cleanup and documentation

* Documentation

* Removed channel from condition, because unnecessary

* changed default_channel to default_account

* Changed saving and getting default channel to default account

* black

* Documentation

* Release notes

* Reverted diff that was unnecessary

---------

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* Skip test_job_logs (#1094)

* Update session max_time docstring (#1089)

* Update session max_time docstring

* Update qiskit_ibm_runtime/session.py

Co-authored-by: Rebecca Dimock <66339736+beckykd@users.noreply.github.com>

---------

Co-authored-by: Rebecca Dimock <66339736+beckykd@users.noreply.github.com>

* Fix unit tests against qiskit/main (#1099)

* Add measurements to sampler

* Remove observables from sampler run

---------

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* fix iqp link (#1096)

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* Only return channel strategy supported backends  (#1095)

* Q-CTRL Backend filters

* add reno

* fix unit tests

* Attempt to fix terra unit tests (#1102)

* Attempt to fix terra unit tests

* test on my fork

* revert coder_qc change

* Making account code more generic  (#1060)

* Making account code more generic by defining subclasses for channel types

* Removed channel parameter from _assert_valid_instance

* mypy, lint and black

* Changed order of decorators

* Code cleanup

* Documentation fixes

* black

---------

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* Remove old deprecations (#1106)

* removing old deprecations

* update unit tests

* Open plan updates (#1105)

* Initial edits

* edit

* Update docs/faqs/max_execution_time.rst

* Update docs/faqs/max_execution_time.rst

* Update docs/faqs/max_execution_time.rst

* Update docs/faqs/max_execution_time.rst

* Update docs/faqs/max_execution_time.rst

* Update docs/faqs/max_execution_time.rst

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

* Jessie comments

* Update docs/faqs/max_execution_time.rst

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

* Update docs/faqs/max_execution_time.rst

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

* Update docs/sessions.rst

* Update docs/faqs/max_execution_time.rst

---------

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

* New method to create a new Session object with a given id (#1101)

* Added the Session.from_id method

* release notes

* Added integration test

---------

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* fix test_session_from_id (#1110)

* Warn users if job submitted will exceed quota (#1100)

* Warn users if job will exceed quota

* update reno

* update reno again

* Removed support for backend as session parameter (#1091)

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* Fix minor todos (#1112)

* Change qpu complex wording (#1109)

* Don't use QPU complex

* don't use the word 'limit'

* Update docs/faqs/max_execution_time.rst

* Update qiskit_ibm_runtime/options/options.py

* Update qiskit_ibm_runtime/runtime_job.py

* Update releasenotes/notes/0.11/job-cost-estimation-d0ba83dbc95c3f67.yaml

* Clarify usage

* reclarify reset time

* rogue comma

* fix whitespace & formatting

* job -> system execution time

---------

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* Add IBM Cloud channel (#1113)

* Changes for #1806

* Update docs/faqs/max_execution_time.rst

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

---------

Co-authored-by: Kevin Tian <kt474@cornell.edu>
Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>
Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* Prepare release 0.12.2 (#1115)

* Update main branch 0.13.0 (#1116)

* remove error message test (#1125)

* Exceptions should inherit from Terra where suitable (#1120)

* Changed RuntimeJobFailureError to inherit from JobError

* Changed error type

---------

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* update docstring & remove max_time (#1137)

* Expose new session details  (#1119)

* add session details method

* add reno

* support iqp urls

* update details mehotd, add status()

* update status() to use enum

* revert previous change, wait for impl details

* update fields returned

* update status method

* update docstring & reno

* update docstrings for both methods

* fix docs build

* address comments

* fix docs build

* fix typo

* docs build again

* fix indent

* fix indent again

* fix indent 3rd time

* Support only LocalFoldingAmplifier as noise_amplifier option (#1093)

* Removed support for all noise_amplifier options other than LocalFoldingAmplifier. Removed deprecation warning.

* Removed tests that covered deprecation. Updated documentation

---------

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* Fix target_history date bug  (#1143)

* fix target_history datetime bug

* add reno

* add test

* Fixed bug when defining shots as int64 (#1151)

* Log instance on initialization and when running a job (#1150)

* log instances

* add _default_instance & fix lint

* add test

* change var name to current_instance

* Move methods into class pages for docs (#1144)

* Fix link to `Close a session` (#1152)

[1] links to [2] but doesn't go directly to the target section.

[1] https://qiskit.org/ecosystem/ibm-runtime/sessions.html#what-happens-when-a-session-ends
[2] https://qiskit.org/ecosystem/ibm-runtime/how_to/run_session.html#close-a-session

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* logging instance test is IQP channel only (#1154)

* Update deploy yml (#1148)

* Allow users to indicate they are done submitting jobs to a session (#1139)

* copy changes over

* clean up branch again

* address comments, update docstrings

* catch appropriate error code

* update status code to 404

* Update qiskit_ibm_runtime/session.py

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

* set self._active & remove runtime_session

* Update releasenotes/notes/session-accepting-jobs-d7ef6b60c0f5527b.yaml

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

---------

Co-authored-by: Jessie Yu <jessieyu@us.ibm.com>

* Prepare release 0.13 (#1157)

* Update main branch 0.13.1 (#1158)

* Update Sphinx theme (#1156)

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* Added IBM Quantum logo (#1164)

* sessions changes (#1169)

* sessions changes

* add more ticks

* fix link

* fix links

* Update docs/sessions.rst

Co-authored-by: abbycross <across@us.ibm.com>

* Update docs/sessions.rst

Co-authored-by: abbycross <across@us.ibm.com>

---------

Co-authored-by: abbycross <across@us.ibm.com>

* Disallow unsupported options (#1108)

* Disallow unsupported options

* Moved checking of unsupported options to 'flexible' decorator

* Modified the test to give TypeError where needed

* Removed empty newline

* Moved tests from test_ibm_primitives to test_options, because they don't require a primitive

* typo

* Release note

* black and lint

* black again

* Fixed test failing in CI

* Removed _flexible decorator. Moved _post_init into Options class

* lint

* lint

* Fixed bug

* lint

---------

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* fix merge issues

* black

* lint

---------

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>
Co-authored-by: Rebecca Dimock <66339736+beckykd@users.noreply.github.com>
Co-authored-by: merav-aharoni <merav@il.ibm.com>
Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Co-authored-by: Esteban Ginez <175813+eginez@users.noreply.github.com>
Co-authored-by: Kevin Tian <kt474@cornell.edu>
Co-authored-by: mberna <mariana.bernagozzi@gmail.com>
Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
Co-authored-by: Arnau Casau <47946624+arnaucasau@users.noreply.github.com>
Co-authored-by: Matt Riedemann <mriedem.os@gmail.com>
Co-authored-by: abbycross <across@us.ibm.com>
  • Loading branch information
13 people authored Oct 31, 2023
1 parent 2785023 commit 3e0b4af
Show file tree
Hide file tree
Showing 83 changed files with 1,482 additions and 1,277 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ on:
jobs:
Deploy:
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
strategy:
matrix:
python-version: [3.9]
Expand All @@ -28,12 +31,12 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install deps
run: pip install -U pip setuptools build
- name: Build sdist
run: python3 -m build
- uses: actions/upload-artifact@v3
with:
path: ./dist/*
- name: Deploy to Pypi
env:
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
TWINE_USERNAME: qiskit
run : |
pip install -U twine pip setuptools virtualenv wheel
python3 setup.py sdist bdist_wheel
twine upload dist/qiskit*
shell: bash
uses: pypa/gh-action-pypi-publish@release/v1
60 changes: 45 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

**Qiskit** is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.

**Qiskit IBM Runtime** is a new environment offered by IBM Quantum that streamlines quantum computations and provides optimal
implementations of the Qiskit primitives `sampler` and `estimator` for IBM Quantum hardware. It is designed to use additional classical compute resources to execute quantum circuits with more efficiency on quantum processors, by including near-time computations such as error suppression and error mitigation. Examples of error suppression include dynamical decoupling, noise-aware compilation, error mitigation including readout mitigation, zero-noise extrapolation (ZNE), and probabilistic error cancellation (PEC).
**Qiskit IBM Runtime** is a new environment offered by IBM Quantum that streamlines quantum computations and provides optimal
implementations of the Qiskit primitives `sampler` and `estimator` for IBM Quantum hardware. It is designed to use additional classical compute resources to execute quantum circuits with more efficiency on quantum processors, by including near-time computations such as error suppression and error mitigation. Examples of error suppression include dynamical decoupling, noise-aware compilation, error mitigation including readout mitigation, zero-noise extrapolation (ZNE), and probabilistic error cancellation (PEC).

Using the runtime service, a research team at IBM Quantum was able to achieve a 120x speedup
in their lithium hydride simulation. For more information, see the
Expand All @@ -30,8 +30,6 @@ pip install qiskit-ibm-runtime

### Qiskit Runtime service on IBM Quantum Platform

The default method for using the runtime service is IBM Quantum Platform.

You will need your IBM Quantum API token to authenticate with the runtime service:

1. Create an IBM Quantum account or log in to your existing account by visiting the [IBM Quantum login page].
Expand Down Expand Up @@ -114,7 +112,7 @@ All quantum applications and algorithms level are fundamentally built using thre

The IBM Runtime service offers these primitives with additional features, such as built-in error suppression and mitigation.

There are several different options you can specify when calling the primitives. See [`qiskit_ibm_runtime.Options`](https://github.com/Qiskit/qiskit-ibm-runtime/blob/main/qiskit_ibm_runtime/options.py#L103) class for more information.
There are several different options you can specify when calling the primitives. See [`qiskit_ibm_runtime.Options`](https://github.com/Qiskit/qiskit-ibm-runtime/blob/main/qiskit_ibm_runtime/options/options.py#L33) class for more information.

### Sampler

Expand All @@ -138,7 +136,7 @@ bell.cx(0, 1)
# 2. Map the qubits to a classical register in ascending order
bell.measure_all()

# 3. Execute using the Sampler primitive
# 3. Execute using the Sampler primitive
backend = service.get_backend('ibmq_qasm_simulator')
sampler = Sampler(backend=backend, options=options)
job = sampler.run(circuits=bell)
Expand Down Expand Up @@ -174,14 +172,14 @@ qc_example.cx(0, 2) # condition 2nd qubit on 0th qubit
# 2. the observable to be measured
M1 = SparsePauliOp.from_list([("XXY", 1), ("XYX", 1), ("YXX", 1), ("YYY", -1)])

# batch of theta parameters to be executed
# batch of theta parameters to be executed
points = 50
theta1 = []
for x in range(points):
theta = [x*2.0*np.pi/50]
theta1.append(theta)

# 3. Execute using the Estimator primitive
# 3. Execute using the Estimator primitive
backend = service.get_backend('ibmq_qasm_simulator')
estimator = Estimator(backend, options=options)
job = estimator.run(circuits=[qc_example]*points, observables=[M1]*points, parameter_values=theta1)
Expand All @@ -197,7 +195,7 @@ This code batches together 50 parameters to be executed in a single job. If a us
In many algorithms and applications, an Estimator needs to be called iteratively without incurring queuing delays on each iteration. To solve this, the IBM Runtime service provides a **Session**. A session starts when the first job within the session is started, and subsequent jobs within the session are prioritized by the scheduler.

You can use the [`qiskit_ibm_runtime.Session`](https://github.com/Qiskit/qiskit-ibm-runtime/blob/main/qiskit_ibm_runtime/session.py) class to start a
session. Consider the same example above and try to find the optimal `theta`. The following example uses the [golden search method](https://en.wikipedia.org/wiki/Golden-section_search) to iteratively find the optimal theta that maximizes the observable.
session. Consider the same example above and try to find the optimal `theta`. The following example uses the [golden search method](https://en.wikipedia.org/wiki/Golden-section_search) to iteratively find the optimal theta that maximizes the observable.

To invoke the `Estimator` primitive within a session:

Expand All @@ -224,15 +222,15 @@ qc_example.cx(0, 2) # condition 2nd qubit on 0th qubit
M1 = SparsePauliOp.from_list([("XXY", 1), ("XYX", 1), ("YXX", 1), ("YYY", -1)])


gr = (np.sqrt(5) + 1) / 2 # golden ratio
gr = (np.sqrt(5) + 1) / 2 # golden ratio
thetaa = 0 # lower range of theta
thetab = 2*np.pi # upper range of theta
tol = 1e-1 # tol
tol = 1e-1 # tol

# 3. Execute iteratively using the Estimator primitive
# 3. Execute iteratively using the Estimator primitive
with Session(service=service, backend="ibmq_qasm_simulator") as session:
estimator = Estimator(session=session, options=options)
#next test range
#next test range
thetac = thetab - (thetab - thetaa) / gr
thetad = thetaa + (thetab - thetaa) / gr
while abs(thetab - thetaa) > tol:
Expand All @@ -245,8 +243,8 @@ with Session(service=service, backend="ibmq_qasm_simulator") as session:
thetaa = thetac
thetac = thetab - (thetab - thetaa) / gr
thetad = thetaa + (thetab - thetaa) / gr
# Final job to evaluate Estimator at midpoint found using golden search method

# Final job to evaluate Estimator at midpoint found using golden search method
theta_mid = (thetab + thetaa) / 2
job = estimator.run(circuits=qc_example, observables=M1, parameter_values=theta_mid)
print(f"Session ID is {session.session_id}")
Expand All @@ -256,6 +254,38 @@ with Session(service=service, backend="ibmq_qasm_simulator") as session:

This code returns `Job result is [4.] at theta = 1.575674623307102` using only nine iterations. This is a very powerful extension to the primitives. However, using too much code between iterative calls can lock the QPU and use excessive QPU time, which is expensive. We recommend only using sessions when needed. The Sampler can also be used within a session, but there are not any well-defined examples for this.

## Instances

Access to IBM Quantum Platform channel is controlled by the instances (previously called providers) to which you are assigned. An instance is defined by a hierarchical organization of hub, group, and project. A hub is the top level of a given hierarchy (organization) and contains within it one or more groups. These groups are in turn populated with projects. The combination of hub/group/project is called an instance. Users can belong to more than one instance at any time.

> **_NOTE:_** IBM Cloud instances are different from IBM Quantum Platform instances. IBM Cloud does not use the hub/group/project structure for user management. To view and create IBM Cloud instances, visit the [IBM Cloud Quantum Instances page](https://cloud.ibm.com/quantum/instances).
To view a list of your instances, visit your [account settings page](https://www.quantum-computing.ibm.com/account) or use the `instances()` method.

You can specify an instance when initializing the service or provider, or when picking a backend:

```python
# Optional: List all the instances you can access.
service = QiskitRuntimeService(channel='ibm_quantum')
print(service.instances())

# Optional: Specify the instance at service level. This becomes the default unless overwritten.
service = QiskitRuntimeService(channel='ibm_quantum', instance="hub1/group1/project1")
backend1 = service.backend("ibmq_manila")

# Optional: Specify the instance at the backend level, which overwrites the service-level specification when this backend is used.
backend2 = service.backend("ibmq_manila", instance="hub2/group2/project2")

sampler1 = Sampler(backend=backend1) # this will use hub1/group1/project1
sampler2 = Sampler(backend=backend2) # this will use hub2/group2/project2
```

If you do not specify an instance, then the code will select one in the following order:

1. If your account only has access to one instance, it is selected by default.
2. If your account has access to multiple instances, but only one can access the requested backend, the instance with access is selected.
3. In all other cases, the code selects the first instance other than ibm-q/open/main that has access to the backend.

## Access your IBM Quantum backends

A **backend** is a quantum device or simulator capable of running quantum circuits or pulse schedules.
Expand Down
10 changes: 3 additions & 7 deletions docs/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@

.. rubric:: Attributes

.. autosummary::
:toctree: ../stubs/
{% for item in all_attributes %}
{%- if not item.startswith('_') %}
{{ name }}.{{ item }}
.. autoattribute:: {{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% endif %}
Expand All @@ -32,16 +30,14 @@

.. rubric:: Methods

.. autosummary::
:toctree: ../stubs/
{% for item in all_methods %}
{%- if not item.startswith('_') or item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
{{ name }}.{{ item }}
.. automethod:: {{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% for item in inherited_members %}
{%- if item in ['__call__', '__mul__', '__getitem__', '__len__'] %}
{{ name }}.{{ item }}
.. automethod:: {{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}

Expand Down
2 changes: 1 addition & 1 deletion docs/cloud/cost.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Time limits on programs

The maximum execution time for the Sampler primitive is 10000 seconds (2.78 hours). The maximum execution time for the Estimator primitive is 18000 seconds (5 hours).

Additionally, the system limit on the job execution time is 3 hours for a job that is running on a simulator and 8 hours for a job running on a physical system.
Additionally, the system limit on the system execution time is 3 hours for a job that is running on a simulator and 8 hours for a job running on a physical system.

How to limit your cost
***********************
Expand Down
18 changes: 10 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = '0.12.1'
release = '0.13.1'

docs_url_prefix = "ecosystem/ibm-runtime"

Expand Down Expand Up @@ -146,18 +146,20 @@

# -- Options for HTML output -------------------------------------------------

html_theme = 'qiskit_sphinx_theme'
html_theme = "qiskit-ecosystem"
html_title = f"{project} {release}"

html_logo = 'images/logo.png'
html_last_updated_fmt = '%Y/%m/%d'
html_logo = "images/ibm-quantum-logo.png"

html_theme_options = {
'logo_only': True,
'display_version': True,
'prev_next_buttons_location': 'bottom',
'style_external_links': True,
# Because this is an IBM-focused project, we use a blue color scheme.
"light_css_variables": {
"color-brand-primary": "var(--qiskit-color-blue)",
},
}

html_last_updated_fmt = '%Y/%m/%d'

html_sourcelink_suffix = ''

autoclass_content = 'both'
50 changes: 11 additions & 39 deletions docs/faqs/max_execution_time.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ a job exceeds this time limit, it is forcibly cancelled and a ``RuntimeJobMaxTim
exception is raised.

.. note::
As of August 7, 2023, the ``max_execution_time`` value is based on quantum
time instead of wall clock time. Quantum time represents the time that the QPU
As of August 7, 2023, the ``max_execution_time`` value is based on system execution time, which is the time that the QPU
complex (including control software, control electronics, QPU, and so on) is engaged in
processing the job.
processing the job, instead of wall clock time.

Simulator jobs continue to use wall clock time because they do not have quantum time.
Simulator jobs continue to use wall clock time.

You can set the maximum execution time (in seconds) on the job options by using one of the following methods:

Expand All @@ -32,12 +31,12 @@ You can set the maximum execution time (in seconds) on the job options by using
# Create the options object with attributes and values
options = {"max_execution_time": 360}
You can also find quantum time used by previously completed jobs by using:
You can also find the system execution time for previously completed jobs by using:

.. code-block:: python
# Find quantum time used by the job
print(f"Quantum time used by job {job.job_id()} was {job.metrics()['usage']['quantum_seconds']} seconds")
# Find the system execution time
print(f"Job {job.job_id()} system execution time was {job.metrics()['usage']['seconds']} seconds")
In addition, the system calculates an appropriate job timeout value based on the
input circuits and options. This system-calculated timeout is currently capped
Expand All @@ -48,42 +47,15 @@ For example, if you specify ``max_execution_time=5000``, but the system determin
it should not take more than 5 minutes (300 seconds) to execute the job, then the job will be
cancelled after 5 minutes.

Session time limits
***************************

When a session is started, it is assigned a maximum session timeout value.
After this timeout 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.
You can set the maximum session timeout value using the ``max_time`` parameter:

.. code-block:: python
# Set the session max time
with Session(max_time="1h"):
...
If you don't specify a session ``max_time``, the system defaults are used:

+--------------+------------------+--------------+-----------+
| Primitive programs | Private programs |
+==============+==================+==============+===========+
| Premium User | Open User | Premium User | Open User |
+--------------+------------------+--------------+-----------+
| 8h | 4h | 8h | N/A |
+--------------+------------------+--------------+-----------+

Note that a *premium user* here means a user who has access to backends in providers other than ``ibm-q/open/main``.

.. note::
Session ``max_time`` is based on wall clock time, not quantum time.


Additionally, there is a 5 minute *interactive* timeout value. If there are no session jobs queued within that window, the session is temporarily deactivated and normal job selection resumes. During job selection, if the job scheduler gets a new job from the session and its maximum timeout value has not been reached, the session is reactivated until its maximum timeout value is reached.
Session maximum execution time
*******************************

.. note:: The timer for the session's ``max_time`` is not paused during any temporary deactivation periods.
When a session is started, it is assigned a maximum session timeout value. After this timeout 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. For instructions to set the session maximum time, see `Specify the session length <../how_to/run_session#session_length.html>`__.


Other limitations
***************************

- Programs cannot exceed 750KB in size.
- Inputs to jobs cannot exceed 64MB in size.
- Inputs to jobs cannot exceed 64MB in size.
- Open plan users can use up to 10 minutes of system execution time per month (resets at 00:00 UTC on the first of each month). System execution time is the amount of time that the system is dedicated to processing your job. You can track your monthly usage on the `Platform dashboard, <https://quantum-computing.ibm.com/>`__ `Jobs, <https://quantum-computing.ibm.com/jobs>`__ and `Account <https://quantum-computing.ibm.com/account>`__ page.
8 changes: 3 additions & 5 deletions docs/how_to/backends.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,9 @@ If you are using a runtime session, add the ``backend`` option when starting you
service = QiskitRuntimeService()
with Session(service=service, backend="ibmq_qasm_simulator") as session:
estimator = Estimator(session=session, options=options)
job = estimator.run(circuit, observable)
result = job.result()
# Close the session only if all jobs are finished, and you don't need to run more in the session
session.close() # Closes the session
estimator = Estimator(session=session, options=options)
job = estimator.run(circuit, observable)
result = job.result()
display(circuit.draw("mpl"))
print(f" > Observable: {observable.paulis}")
Expand Down
Loading

0 comments on commit 3e0b4af

Please sign in to comment.