Skip to content

Commit

Permalink
Remove workarounds for passing run options to sampler
Browse files Browse the repository at this point in the history
This runtime patching code was added along with the initial support for
sampler execution because the path through
`qiskit_ibm_runtime.SamplerV2` through to `BackendSamplerV2` did not
carry through options for level 1 measurements or noise models. This
path is used in the tests (while execution on physical backends with
`SamplerV2` does not use this path). Now with Qiskit 1.3 and
qiskit-ibm-runtime 0.34, this patching is no longer needed. Remaining
warnings filtering was moved to the calibrations tutorial where it was
needed.
wshanks committed Dec 8, 2024
1 parent fc7acf0 commit 1a1d17d
Showing 27 changed files with 7 additions and 392 deletions.
7 changes: 0 additions & 7 deletions docs/howtos/artifacts.rst
Original file line number Diff line number Diff line change
@@ -25,13 +25,6 @@ Viewing artifacts
Here we run a parallel experiment consisting of two :class:`.T1` experiments in parallel and then view the output
artifacts as a list of :class:`.ArtifactData` objects accessed by :meth:`.ExperimentData.artifacts`:

.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

from qiskit_ibm_runtime.fake_provider import FakePerth
7 changes: 0 additions & 7 deletions docs/manuals/characterization/t1.rst
Original file line number Diff line number Diff line change
@@ -34,13 +34,6 @@ for qubit 0.
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

import numpy as np
7 changes: 0 additions & 7 deletions docs/manuals/characterization/t2ramsey.rst
Original file line number Diff line number Diff line change
@@ -62,13 +62,6 @@ pure T1/T2 relaxation noise model.
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

# A T1 simulator
7 changes: 0 additions & 7 deletions docs/manuals/characterization/tphi.rst
Original file line number Diff line number Diff line change
@@ -25,13 +25,6 @@ From the :math:`T_1` and :math:`T_2` estimates, we compute the results for
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

import numpy as np
7 changes: 0 additions & 7 deletions docs/manuals/measurement/readout_mitigation.rst
Original file line number Diff line number Diff line change
@@ -35,13 +35,6 @@ experiments to generate the corresponding mitigators.
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

import numpy as np
4 changes: 0 additions & 4 deletions docs/manuals/measurement/restless_measurements.rst
Original file line number Diff line number Diff line change
@@ -88,10 +88,6 @@ they use always starts with the qubits in the ground state.
category=DeprecationWarning,
)

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

from qiskit_ibm_runtime.fake_provider import FakePerth
7 changes: 0 additions & 7 deletions docs/manuals/verification/quantum_volume.rst
Original file line number Diff line number Diff line change
@@ -29,13 +29,6 @@ z_value = 2), and at least 100 trials have been ran.
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

from qiskit_experiments.framework import BatchExperiment
7 changes: 0 additions & 7 deletions docs/manuals/verification/randomized_benchmarking.rst
Original file line number Diff line number Diff line change
@@ -16,13 +16,6 @@ explanation on the RB method, which is based on Refs. [1]_ [2]_.
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

import numpy as np
7 changes: 0 additions & 7 deletions docs/manuals/verification/state_tomography.rst
Original file line number Diff line number Diff line change
@@ -14,13 +14,6 @@ complete basis of measurement operators.

We first initialize a simulator to run the experiments on.

.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

from qiskit_aer import AerSimulator
1 change: 1 addition & 0 deletions docs/tutorials/calibrations.rst
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@ This automatic updating can also be disabled using the ``auto_update`` flag.
message=".*The entire Qiskit Pulse package is being deprecated.*",
category=DeprecationWarning,
)
warnings.filterwarnings("ignore", ".*Could not determine job completion time.*", UserWarning)

.. jupyter-execute::

7 changes: 0 additions & 7 deletions docs/tutorials/custom_experiment.rst
Original file line number Diff line number Diff line change
@@ -562,13 +562,6 @@ To test our code, we first simulate a noisy backend with asymmetric readout erro
You can install it with ``python -m pip install qiskit-aer``.


.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

from qiskit_aer import AerSimulator, noise
7 changes: 0 additions & 7 deletions docs/tutorials/getting_started.rst
Original file line number Diff line number Diff line change
@@ -86,13 +86,6 @@ backend, real or simulated, that you can access through Qiskit.
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

from qiskit_ibm_runtime.fake_provider import FakePerth
Original file line number Diff line number Diff line change
@@ -77,10 +77,6 @@ class CorrelatedReadoutError(BaseExperiment):
.. jupyter-execute::
:hide-code:
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()
from qiskit.providers.fake_provider import GenericBackendV2
from qiskit_aer import AerSimulator
4 changes: 0 additions & 4 deletions qiskit_experiments/library/characterization/fine_frequency.py
Original file line number Diff line number Diff line change
@@ -53,10 +53,6 @@ class FineFrequency(BaseExperiment):
.. jupyter-execute::
:hide-code:
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()
# backend
from qiskit_ibm_runtime.fake_provider import FakePerth
from qiskit_aer import AerSimulator
Original file line number Diff line number Diff line change
@@ -66,10 +66,6 @@ class LocalReadoutError(BaseExperiment):
.. jupyter-execute::
:hide-code:
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()
# backend
from qiskit_aer import AerSimulator
from qiskit_ibm_runtime.fake_provider import FakePerth
Original file line number Diff line number Diff line change
@@ -58,10 +58,6 @@ class MultiStateDiscrimination(BaseExperiment):
.. jupyter-execute::
:hide-code:
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()
# backend
from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend
backend = SingleTransmonTestBackend(5.2e9,-.25e9, 1e9, 0.8e9, 1e4, noise=False, seed=199)
4 changes: 0 additions & 4 deletions qiskit_experiments/library/characterization/ramsey_xy.py
Original file line number Diff line number Diff line change
@@ -85,10 +85,6 @@ class RamseyXY(BaseExperiment, RestlessMixin):
.. jupyter-execute::
:hide-code:
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()
# backend
from qiskit_aer import AerSimulator
from qiskit_ibm_runtime.fake_provider import FakePerth
4 changes: 0 additions & 4 deletions qiskit_experiments/library/characterization/t1.py
Original file line number Diff line number Diff line change
@@ -41,10 +41,6 @@ class T1(BaseExperiment):
.. jupyter-execute::
:hide-code:
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()
# backend
from qiskit_ibm_runtime.fake_provider import FakeManilaV2
from qiskit_aer import AerSimulator
4 changes: 0 additions & 4 deletions qiskit_experiments/library/characterization/t2ramsey.py
Original file line number Diff line number Diff line change
@@ -63,10 +63,6 @@ class T2Ramsey(BaseExperiment):
.. jupyter-execute::
:hide-code:
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()
# backend
from qiskit_ibm_runtime.fake_provider import FakeManilaV2
from qiskit_aer import AerSimulator
4 changes: 0 additions & 4 deletions qiskit_experiments/library/characterization/tphi.py
Original file line number Diff line number Diff line change
@@ -54,10 +54,6 @@ class Tphi(BatchExperiment):
.. jupyter-execute::
:hide-code:
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()
# backend
from qiskit_ibm_runtime.fake_provider import FakeManilaV2
from qiskit_aer import AerSimulator
4 changes: 0 additions & 4 deletions qiskit_experiments/library/characterization/zz_ramsey.py
Original file line number Diff line number Diff line change
@@ -129,10 +129,6 @@ class ZZRamsey(BaseExperiment):
.. jupyter-execute::
:hide-code:
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()
# backend
from qiskit_ibm_runtime.fake_provider import FakePerth
from qiskit_aer import AerSimulator
5 changes: 0 additions & 5 deletions qiskit_experiments/test/mock_iq_backend.py
Original file line number Diff line number Diff line change
@@ -47,11 +47,6 @@ def __init__(
backend_version: str = None,
**fields,
):
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support

patch_sampler_test_support()

super().__init__(provider, name, description, online_date, backend_version, **fields)

backend_v1 = FakeOpenPulse2Q()
260 changes: 0 additions & 260 deletions qiskit_experiments/test/patching.py

This file was deleted.

5 changes: 0 additions & 5 deletions qiskit_experiments/test/pulse_backend.py
Original file line number Diff line number Diff line change
@@ -90,11 +90,6 @@ def __init__(
atol: Absolute tolerance during solving.
rtol: Relative tolerance during solving.
"""
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support

patch_sampler_test_support()

from qiskit_dynamics import Solver

super().__init__(
6 changes: 0 additions & 6 deletions qiskit_experiments/test/t2hahn_backend.py
Original file line number Diff line number Diff line change
@@ -103,12 +103,6 @@ def __init__(
"""
Initialize the T2Hahn backend
"""

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support

patch_sampler_test_support()

super().__init__(
name="T2Hahn_simulator",
backend_version="0",
7 changes: 6 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -12,7 +12,12 @@ testtools

# Extra dependencies for tests/documentation code
multimethod
qiskit-ibm-runtime>=0.19
# qiskit-ibm-runtime 0.34 and qiskit 1.3 neeeded to pass run options through
# qiskit_ibm_runtime.SamplerV2 through to test backends' backend.run calls.
# Earlier versions work okay when using physical backends or not passing run
# options.
qiskit-ibm-runtime>=0.34 # see above
qiskit>=1.3 # see above

# Documentation tools
arxiv
5 changes: 0 additions & 5 deletions test/base.py
Original file line number Diff line number Diff line change
@@ -106,11 +106,6 @@ def setUpClass(cls):
"""Set-up test class."""
super().setUpClass()

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support

patch_sampler_test_support()

# Tests should not generate any warnings unless testing those
# warnings. In that case, the test should catch the warning
# assertWarns or warnings.catch_warnings.

0 comments on commit 1a1d17d

Please sign in to comment.