Skip to content

Commit

Permalink
Switch tests and documentation to use qiskit-ibm-runtime fake backends
Browse files Browse the repository at this point in the history
The IBM-specific fake backends in Qiskit are being removed in Qiskit 1.0
in Qiskit/qiskit#11376. The same fake backends
have been moved to qiskit-ibm-runtime in
Qiskit/qiskit-ibm-runtime#1140 and follow up
PRs.

Here the `qiskit` imports are replaced with `qiskit-ibm-runtime` imports
in order to provide a smooth transition between Qiskit 0.45 and Qiskit
1.0. In the future, it may be preferable to use generic fake backends
maintained in the repo and not depend on `qiskit-ibm-runtime` for them.

Additionally, this commit reorders the requirements-dev.txt file so it
is easier to read and adds qiskit-ibm-runtime as a development
dependency.
  • Loading branch information
wshanks committed Jan 23, 2024
1 parent b66f662 commit db3f98f
Show file tree
Hide file tree
Showing 34 changed files with 101 additions and 69 deletions.
8 changes: 6 additions & 2 deletions docs/manuals/characterization/stark_experiment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,13 @@ drive port of the qubit.
In a typical IBM device using the cross-resonance drive architecture,
such channel can be identified with your backend as follows:

.. note::
This tutorial requires the :mod:`qiskit_ibm_runtime` package to model a
backend. You can install it with ``python -m pip install qiskit-ibm-runtime``.

.. jupyter-execute::

from qiskit.providers.fake_provider import FakeHanoiV2
from qiskit_ibm_runtime.fake_provider import FakeHanoiV2

backend = FakeHanoiV2()
qubit = 0
Expand Down Expand Up @@ -143,7 +147,7 @@ by a variant of the Hahn-echo pulse sequence [5]_.

from qiskit_experiments.library import StarkRamseyXY
from qiskit import schedule, pulse
from qiskit.providers.fake_provider import FakeHanoi
from qiskit_ibm_runtime.fake_provider import FakeHanoi
from qiskit.visualization.pulse_v2 import IQXSimple

backend = FakeHanoi()
Expand Down
7 changes: 4 additions & 3 deletions docs/manuals/characterization/t1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ The following code demonstrates a basic run of a :math:`T_1` experiment
for qubit 0.

.. note::
This manual requires the :mod:`qiskit_aer` package to run simulations.
You can install it with ``python -m pip install qiskit-aer``.
This tutorial requires the :mod:`qiskit_aer` and :mod:`qiskit_ibm_runtime`
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::

Expand All @@ -42,9 +43,9 @@ for qubit 0.
from qiskit_experiments.library.characterization.analysis.t1_analysis import T1KerneledAnalysis

# A T1 simulator
from qiskit.providers.fake_provider import FakePerth
from qiskit_aer import AerSimulator
from qiskit_aer.noise import NoiseModel
from qiskit_ibm_runtime.fake_provider import FakePerth

# A kerneled data simulator
from qiskit_experiments.test.mock_iq_backend import MockIQBackend
Expand Down
7 changes: 4 additions & 3 deletions docs/manuals/characterization/t2ramsey.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ We run the experiment on a simulated backend using Qiskit Aer with a
pure T1/T2 relaxation noise model.

.. note::
This manual requires the :mod:`qiskit_aer` package to run simulations.
You can install it with ``python -m pip install qiskit-aer``.
This tutorial requires the :mod:`qiskit_aer` and :mod:`qiskit_ibm_runtime`
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::

# A T1 simulator
from qiskit.providers.fake_provider import FakePerth
from qiskit_ibm_runtime.fake_provider import FakePerth
from qiskit_aer import AerSimulator
from qiskit_aer.noise import NoiseModel

Expand Down
7 changes: 4 additions & 3 deletions docs/manuals/characterization/tphi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ From the :math:`T_1` and :math:`T_2` estimates, we compute the results for
:math:`T_\varphi.`

.. note::
This manual requires the :mod:`qiskit_aer` package to run simulations.
You can install it with ``python -m pip install qiskit-aer``.
This tutorial requires the :mod:`qiskit_aer` and :mod:`qiskit_ibm_runtime`
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::

Expand All @@ -31,9 +32,9 @@ From the :math:`T_1` and :math:`T_2` estimates, we compute the results for
from qiskit_experiments.library.characterization import Tphi

# An Aer simulator
from qiskit.providers.fake_provider import FakePerth
from qiskit_aer import AerSimulator
from qiskit_aer.noise import NoiseModel
from qiskit_ibm_runtime.fake_provider import FakePerth

# Create a pure relaxation noise model for AerSimulator
noise_model = NoiseModel.from_backend(
Expand Down
7 changes: 4 additions & 3 deletions docs/manuals/measurement/readout_mitigation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ This notebook demonstrates the usage of both the local and correlated
experiments to generate the corresponding mitigators.

.. note::
This manual requires the :mod:`qiskit_aer` package to run simulations.
You can install it with ``python -m pip install qiskit-aer``.
This tutorial requires the :mod:`qiskit_aer` and :mod:`qiskit_ibm_runtime`
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::

Expand All @@ -43,7 +44,7 @@ experiments to generate the corresponding mitigators.
from qiskit_experiments.library import LocalReadoutError, CorrelatedReadoutError

from qiskit_aer import AerSimulator
from qiskit.providers.fake_provider import FakePerth
from qiskit_ibm_runtime.fake_provider import FakePerth

from qiskit.result.mitigation.utils import (
expval_with_stddev,
Expand Down
7 changes: 6 additions & 1 deletion docs/manuals/measurement/restless_measurements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,20 @@ a fake backend and a rough DRAG experiment. Note however, that you will not
observe any meaningful outcomes with fake backends since the circuit simulator
they use always starts with the qubits in the ground state.

.. note::
This tutorial requires the :mod:`qiskit_ibm_runtime` package to model a
backend. You can install it with ``python -m pip install qiskit-ibm-runtime``.

.. jupyter-execute::

from qiskit_ibm_runtime.fake_provider import FakePerth

from qiskit_experiments.library import RoughDragCal
from qiskit_experiments.calibration_management import (
Calibrations,
FixedFrequencyTransmon,
)
from qiskit_experiments.data_processing.data_processor import DataProcessor
from qiskit.providers.fake_provider import FakePerth

# replace this lines with an IBM Quantum backend to run the experiment.
backend = FakePerth()
Expand Down
11 changes: 6 additions & 5 deletions docs/manuals/verification/quantum_volume.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,19 @@ probability` > 2/3 with confidence level > 0.977 (corresponding to
z_value = 2), and at least 100 trials have been ran.

.. note::
This manual requires the :mod:`qiskit_aer` package to run simulations.
You can install it with ``python -m pip install qiskit-aer``.
This tutorial requires the :mod:`qiskit_aer` and :mod:`qiskit_ibm_runtime`
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::

from qiskit_experiments.framework import BatchExperiment
from qiskit_experiments.library import QuantumVolume
from qiskit import Aer
from qiskit_aer import AerSimulator

# For simulation
from qiskit.providers.fake_provider import FakeSydneyV2
from qiskit import Aer
from qiskit_aer import AerSimulator
from qiskit_ibm_runtime.fake_provider import FakeSydneyV2

backend = AerSimulator.from_backend(FakeSydneyV2())

Expand Down
7 changes: 6 additions & 1 deletion docs/manuals/verification/randomized_benchmarking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ error estimates for the quantum device, by calculating the Error Per Clifford. S
<https://github.com/Qiskit/textbook/blob/main/notebooks/quantum-hardware/randomized-benchmarking.ipynb>`__ for an
explanation on the RB method, which is based on Refs. [1]_ [2]_.

.. note::
This tutorial requires the :mod:`qiskit_aer` and :mod:`qiskit_ibm_runtime`
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::

import numpy as np
Expand All @@ -20,7 +25,7 @@ explanation on the RB method, which is based on Refs. [1]_ [2]_.

# For simulation
from qiskit_aer import AerSimulator
from qiskit.providers.fake_provider import FakePerth
from qiskit_ibm_runtime.fake_provider import FakePerth

backend = AerSimulator.from_backend(FakePerth())

Expand Down
7 changes: 4 additions & 3 deletions docs/manuals/verification/state_tomography.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ of a quantum state by preparing the state many times and measuring them in a tom
complete basis of measurement operators.

.. note::
This tutorial requires the :mod:`qiskit_aer` package for simulations.
You can install it with ``python -m pip install qiskit-aer``.
This tutorial requires the :mod:`qiskit_aer` and :mod:`qiskit_ibm_runtime`
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

We first initialize a simulator to run the experiments on.

.. jupyter-execute::

from qiskit_aer import AerSimulator
from qiskit.providers.fake_provider import FakePerth
from qiskit_ibm_runtime.fake_provider import FakePerth

backend = AerSimulator.from_backend(FakePerth())

Expand Down
11 changes: 6 additions & 5 deletions docs/tutorials/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,17 @@ the experiment from the Qiskit Experiments library:
from qiskit_experiments.library import T1

Experiments must be run on a backend. We're going to use a simulator,
:class:`~qiskit.providers.fake_provider.FakePerth`, for this example, but you can use any
:class:`~qiskit_ibm_runtime.fake_provider.FakePerth`, for this example, but you can use any
backend, real or simulated, that you can access through Qiskit.

.. note::
This tutorial requires the :mod:`qiskit_aer` package to run simulations.
You can install it with ``python -m pip install qiskit-aer``.
This tutorial requires the :mod:`qiskit_aer` and :mod:`qiskit_ibm_runtime`
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::

from qiskit.providers.fake_provider import FakePerth
from qiskit_ibm_runtime.fake_provider import FakePerth
from qiskit_aer import AerSimulator

backend = AerSimulator.from_backend(FakePerth())
Expand Down Expand Up @@ -419,4 +420,4 @@ Use the `broadcast` parameter to set analysis options to each of the child exper

If the child experiment inherits from :class:`.CompositeExperiment` (such as :class:`.ParallelExperiment`
and :class:`.BatchExperiment` classes), this process will continue to work recursively.
In this instance, the analysis will not generate a figure for the child experiment after the analysis.
In this instance, the analysis will not generate a figure for the child experiment after the analysis.
7 changes: 4 additions & 3 deletions docs/tutorials/visualization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ Generating and customizing a figure using a plotter
First, we display the default figure from a :class:`.Rabi` experiment as a starting point:

.. note::
This tutorial requires the :mod:`qiskit_dynamics` package to run simulations.
You can install it with ``python -m pip install qiskit-dynamics``.
This tutorial requires the :mod:`qiskit_dynamics`, :mod:`qiskit_aer`, and
:mod:`qiskit_ibm_runtime` packages to run simulations. You can install them
with ``python -m pip install qiskit-dynamics qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::

Expand Down Expand Up @@ -191,8 +192,8 @@ until now in this tutorial:
.. jupyter-execute::

from qiskit_experiments.library import T1
from qiskit.providers.fake_provider import FakePerth
from qiskit_aer import AerSimulator
from qiskit_ibm_runtime.fake_provider import FakePerth

backend = AerSimulator.from_backend(FakePerth())

Expand Down
35 changes: 22 additions & 13 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
# Linters
black~=22.0
pylint~=3.0.2
astroid~=3.0.1 # Must be kept aligned to what pylint wants

# Test runner tools
coverage>=5.5
ddt>=1.6.0
fixtures
stestr
testtools
pylint~=3.0.2
astroid~=3.0.1 # Must be kept aligned to what pylint wants

# Extra dependencies for tests/documentation code
multimethod
qiskit-ibm-runtime>=0.18

# Documentation tools
arxiv
jinja2==3.0.3
sphinx>=6.2.1,<=7
jupyter-sphinx>=0.4.0
qiskit-sphinx-theme~=1.14.0rc1
sphinx-design~=0.4.1
pygments>=2.4
reno>=4.0.0
nbsphinx
arxiv
ddt>=1.6.0
pygments>=2.4
pylatexenc
multimethod
qiskit-sphinx-theme~=1.14.0rc1
reno>=4.0.0
sphinx>=6.2.1,<=7
sphinx-copybutton
coverage>=5.5
sphinx-design~=0.4.1
sphinx-remove-toctrees

# Pin versions below because of build errors
ipykernel<=6.21.3
jupyter-client<=8.0.3
ipython<8.13.0 ; python_version<"3.9" # for python 3.8 compatibility
sphinx-remove-toctrees
jupyter-client<=8.0.3
2 changes: 1 addition & 1 deletion test/calibration/test_calibrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from qiskit.circuit.library import CXGate, XGate
from qiskit.pulse.transforms import inline_subroutines, block_to_schedule
from qiskit.providers import BackendV2, Options
from qiskit.providers.fake_provider import FakeArmonkV2, FakeBelemV2
from qiskit_ibm_runtime.fake_provider import FakeArmonkV2, FakeBelemV2
from qiskit.transpiler import Target

from qiskit_experiments.framework import BackendData
Expand Down
2 changes: 1 addition & 1 deletion test/calibration/test_update_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
from test.base import QiskitExperimentsTestCase
import numpy as np

from qiskit.providers.fake_provider import FakeAthensV2
from qiskit.qobj.utils import MeasLevel
from qiskit_ibm_runtime.fake_provider import FakeAthensV2

from qiskit_experiments.framework import BackendData
from qiskit_experiments.library import QubitSpectroscopy
Expand Down
2 changes: 1 addition & 1 deletion test/database_service/test_db_experiment_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import matplotlib.pyplot as plt
import numpy as np

from qiskit.providers.fake_provider import FakeMelbourneV2
from qiskit_ibm_runtime.fake_provider import FakeMelbourneV2
from qiskit.result import Result
from qiskit.providers import JobV1 as Job
from qiskit.providers import JobStatus
Expand Down
2 changes: 1 addition & 1 deletion test/framework/test_backend_timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from ddt import data, ddt, unpack
from qiskit import QiskitError
from qiskit.providers.fake_provider import FakeNairobiV2
from qiskit_ibm_runtime.fake_provider import FakeNairobiV2

from qiskit_experiments.framework import BackendTiming

Expand Down
3 changes: 2 additions & 1 deletion test/framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
import ddt

from qiskit import QuantumCircuit
from qiskit.providers.fake_provider import FakeVigoV2, FakeJob
from qiskit.providers.fake_provider import FakeJob
from qiskit.providers.jobstatus import JobStatus
from qiskit.exceptions import QiskitError
from qiskit_ibm_runtime.fake_provider import FakeVigoV2

from qiskit_experiments.exceptions import AnalysisError
from qiskit_experiments.framework import (
Expand Down
2 changes: 1 addition & 1 deletion test/library/calibration/test_drag.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
from qiskit import pulse
from qiskit.circuit import Parameter
from qiskit.exceptions import QiskitError
from qiskit.providers.fake_provider import FakeWashingtonV2
from qiskit.pulse import DriveChannel, Drag
from qiskit.qobj.utils import MeasLevel
from qiskit_ibm_runtime.fake_provider import FakeWashingtonV2

from qiskit_experiments.library import RoughDrag, RoughDragCal
from qiskit_experiments.library.characterization.analysis import DragCalAnalysis
Expand Down
2 changes: 1 addition & 1 deletion test/library/calibration/test_fine_amplitude.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
from qiskit import pulse
from qiskit.circuit import Gate
from qiskit.circuit.library import XGate, SXGate
from qiskit.providers.fake_provider import FakeArmonkV2
from qiskit.pulse import DriveChannel, Drag
from qiskit_ibm_runtime.fake_provider import FakeArmonkV2

from qiskit_experiments.library import (
FineXAmplitude,
Expand Down
2 changes: 1 addition & 1 deletion test/library/calibration/test_fine_drag.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from qiskit import pulse
from qiskit.circuit import Gate
from qiskit.providers.fake_provider import FakeArmonkV2
from qiskit_ibm_runtime.fake_provider import FakeArmonkV2

from qiskit_experiments.library import FineDrag, FineXDrag, FineDragCal
from qiskit_experiments.test.mock_iq_backend import MockIQBackend
Expand Down
2 changes: 1 addition & 1 deletion test/library/calibration/test_fine_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from ddt import ddt, data

from qiskit import pulse
from qiskit.providers.fake_provider import FakeArmonkV2
from qiskit_ibm_runtime.fake_provider import FakeArmonkV2

from qiskit_experiments.library import (
FineFrequency,
Expand Down
2 changes: 1 addition & 1 deletion test/library/calibration/test_ramsey_xy.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from test.base import QiskitExperimentsTestCase

from ddt import ddt, data, named_data
from qiskit.providers.fake_provider import FakeArmonkV2
from qiskit_aer import AerSimulator
from qiskit_ibm_runtime.fake_provider import FakeArmonkV2

from qiskit_experiments.calibration_management.calibrations import Calibrations
from qiskit_experiments.calibration_management.basis_gate_library import FixedFrequencyTransmon
Expand Down
Loading

0 comments on commit db3f98f

Please sign in to comment.