-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add sessions how-to and update links #1297
Changes from 15 commits
bb1a3f3
33ab2b2
cf87818
95e5fcc
71dc042
decf0f7
7dea966
7decd94
3832747
b3079f0
0ccb305
80590e4
e3ba045
0686feb
7c99c9b
3774c34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,21 +104,17 @@ https://stestr.readthedocs.io/en/stable/MANUAL.html#test-selection | |
If you want to run a single test module, test class, or individual test method you can | ||
do this faster with the `-n`/`--no-discover` option. For example, to run a module: | ||
``` | ||
tox -- -n test.python.test_examples | ||
tox -epy310 -- -n test.framework.test_composite | ||
``` | ||
Or to run the same module by path: | ||
|
||
``` | ||
tox -- -n test/python/test_examples.py | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wish this worked 🙂 It would make tab completion easier. I try it sometimes because it's what pytest uses and I forget it's not what unittest uses. |
||
``` | ||
To run a class: | ||
|
||
``` | ||
tox -- -n test.python.test_examples.TestPythonExamples | ||
tox -epy310 -- -n test.framework.test_composite.TestCompositeExperimentData | ||
``` | ||
|
||
To run a method: | ||
``` | ||
tox -- -n test.python.test_examples.TestPythonExamples.test_all_examples | ||
tox -epy310 -- -n test.framework.test_composite.TestCompositeExperimentData.test_composite_save_load | ||
``` | ||
|
||
Note that tests will fail automatically if they do not finish execution within 60 seconds. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Use Experiments with Runtime sessions | ||
===================================== | ||
|
||
Problem | ||
------- | ||
|
||
You want to run experiments in a `Runtime session | ||
<https://qiskit.org/ecosystem/ibm-runtime/sessions.html>`_ so that jobs can run in close temporal proximity. | ||
wshanks marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Solution | ||
-------- | ||
|
||
Use the :class:`~qiskit_ibm_provider.IBMBackend` object in ``qiskit-ibm-provider``, which supports sessions. | ||
|
||
In this example, we will set the ``max_circuits`` property to an artificially low value so that the experiment will be | ||
split into multiple jobs that run sequentially in a single session. When running real experiments with a | ||
large number of circuits that can't fit in a single job, it may be helpful to follow this usage pattern: | ||
|
||
.. jupyter-input:: | ||
|
||
from qiskit_ibm_provider import IBMProvider | ||
from qiskit_experiments.library.tomography import ProcessTomography | ||
from qiskit import QuantumCircuit | ||
|
||
provider = IBMProvider() | ||
backend = provider.get_backend("ibm_nairobi") | ||
qc = QuantumCircuit(1) | ||
qc.x(0) | ||
|
||
with backend.open_session() as session: | ||
exp = ProcessTomography(qc) | ||
exp.set_experiment_options(max_circuits=3) | ||
exp_data = exp.run(backend) | ||
exp_data.block_for_results() | ||
# Calling cancel because session.close() is not available for qiskit-ibm-provider<=0.7.2. | ||
# It is safe to call cancel since block_for_results() ensures there are no outstanding jobs | ||
# still running that would be canceled. | ||
session.cancel() | ||
coruscating marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Note that runtime primitives are not currently supported natively in Qiskit Experiments, so either | ||
the `backend.run()` path or the ``circuit-runner`` program in ``qiskit-ibm-runtime`` is required | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we still mention There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, |
||
to run experiments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These commands were not working since some environments such as lint did not recognize the option, so an environment has to be specified.