Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Migrate fake backends to provider #740

Closed
wants to merge 64 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
f46081a
Add tests executing a circuit on each fake backend (Qiskit/qiskit#4018)
mtreinish Mar 25, 2020
9093fe4
Remove marshmallow from providers/ (Qiskit/qiskit#4016)
mtreinish Apr 10, 2020
71db0a0
New fake backends: Cambridge, Paris, London, Valencia, Essex, Armonk …
ajavadia Apr 17, 2020
cc8d8a1
Add missing dict conversion in backconfiguration class (Qiskit/qiskit…
mtreinish Apr 21, 2020
6555b46
Update configurations to perform serialization/deserialization scalin…
taalexander Jul 30, 2020
f3849a9
Remove coding: utf-8 per PEP 3120 (Qiskit/qiskit#4914)
levbishop Aug 12, 2020
bef1bce
Add a lazy loading wrapper class for __qiskit_version__ (Qiskit/qiski…
mtreinish Feb 2, 2021
d84a620
Update fake backend and fake provider to use versioned interface (Qis…
mtreinish Apr 29, 2021
5cd5d4c
Switch to using black for code formatting (Qiskit/qiskit#6361)
mtreinish May 5, 2021
08c9ea0
Deprecate legacy provider interface (Qiskit/qiskit#6337)
mtreinish Jun 9, 2021
aef12f6
Optimise `import qiskit` with lazy imports (Qiskit/qiskit#7525)
jakelishman Feb 2, 2022
e0bde61
Add fake backends for new IBM Quantum systems (Qiskit/qiskit#7392)
mtreinish Feb 21, 2022
bb299c6
Relocate mock backends from qiskit.test.mock to qiskit.mock (Qiskit/q…
iuliazidaru Mar 4, 2022
88c32a2
Rename old FakeMumbaiV2 to avoid name conflict with new FakeMumbaiV2 …
HuangJunye Mar 30, 2022
dc286d2
Add BackendV2 mocked backend (Qiskit/qiskit#7643)
HuangJunye Mar 31, 2022
b5b5a78
Add BackendV2 mocked backend (Qiskit/qiskit#7643)
HuangJunye Mar 31, 2022
d1fe840
Remove legacy providers interface (Qiskit/qiskit#7886)
mtreinish Apr 19, 2022
ec63dc2
Remove legacy providers interface (Qiskit/qiskit#7886)
mtreinish Apr 19, 2022
defb04e
Fix `dt` units in test util function `convert_to_target` (Qiskit/qisk…
kevinhartman Apr 29, 2022
6ce9e50
Add missing delay instruction to fake backends (Qiskit/qiskit#8003)
mtreinish May 3, 2022
2e459c8
Fix fake backend v2 dtm unit (Qiskit/qiskit#8019)
HuangJunye May 4, 2022
597922f
Move `qiskit.test.mock` to `qiskit.providers.fake_provider` and depre…
HuangJunye Jun 23, 2022
b1294e3
Move `qiskit.test.mock` to `qiskit.providers.fake_provider` and depre…
HuangJunye Jun 23, 2022
6bdebc7
Add logic to return channels to FakeBackendV2 (Qiskit/qiskit#8444)
nkanazawa1989 Aug 22, 2022
7856fc1
adding FakePerth (Qiskit/qiskit#8344)
1ucian0 Sep 16, 2022
c0b3c33
Add FakeOslo backend to fake provider (Qiskit/qiskit#8358)
1ucian0 Sep 19, 2022
cd34093
Add FakeAuckland backend to fake provider (Qiskit/qiskit#8467)
1ucian0 Sep 19, 2022
ca5bb94
adding FakeGeneva (Qiskit/qiskit#8322)
1ucian0 Sep 20, 2022
1a54e67
Add BackendV2Converter class for treating BackendV1 as BackendV2 (Qis…
mtreinish Sep 28, 2022
e39265d
Remove pulse defaults for old fake 20q backends (Qiskit/qiskit#8665)
mtreinish Sep 29, 2022
a2465c8
Ensure target is generated during run() with FakeBackendV2 (Qiskit/qi…
mtreinish Oct 10, 2022
4443700
Disable pylint's import-error (Qiskit/qiskit#8973)
jakelishman Oct 21, 2022
ee8b0ec
Stop using jupyter-sphinx extension in docs builds (Qiskit/qiskit#9346)
mtreinish Jan 6, 2023
0e499b3
Fix typo in fake_provider.py (Qiskit/qiskit#9290)
eltociear Jan 10, 2023
e3d1a69
Add FakePrague Egret R1 to fake backends (Qiskit/qiskit#9369)
nonhermitian Jan 13, 2023
eeafb35
Lazy pulse qobj loading for large backend (Qiskit/qiskit#8885)
nkanazawa1989 Jan 13, 2023
b440d99
Add FakeSherbrooke backend (Qiskit/qiskit#9339)
mtreinish Jan 13, 2023
78f5a2d
Add deprecation warning on use of qiskit.IBMQ (Qiskit/qiskit#8080)
mtreinish Jan 18, 2023
5576f83
Fix typo in Target (Qiskit/qiskit#9473)
nkanazawa1989 Feb 6, 2023
c1c1a17
Remove deprecated arguments (Qiskit/qiskit#9542)
itoko Feb 7, 2023
c785fcb
Fix handling of simulator backends in BackendV2Converter (Qiskit/qisk…
mtreinish Feb 22, 2023
aaf8999
Add loop ops to Aer BackendV2 test (Qiskit/qiskit#9636)
jakelishman Feb 22, 2023
2d690bd
Remove useless pylint suppressions (Qiskit/qiskit#9697)
levbishop Mar 1, 2023
d94d3d8
Add flag to filter faulty qubits and gates to BackendV2Converter (Qis…
mtreinish Apr 5, 2023
864caa3
fixed issue 9453 by removing "_v2" from name in BackendV2 class (Qisk…
shivalee12 Apr 11, 2023
281a5e9
Add support to `switch` in `transpile` (Qiskit/qiskit#9928)
jakelishman Apr 19, 2023
2572dac
Use backend_compat module's convert to target (Qiskit/qiskit#10016)
mtreinish Apr 25, 2023
42d6600
Use backend_compat module's convert to target (Qiskit/qiskit#10016)
mtreinish Apr 25, 2023
4a34de4
Fix qubit filtering in BackendV2Converter with add_delay (Qiskit/qisk…
mtreinish Apr 25, 2023
4dd6d7b
Remove list argument broadcasting and simplify transpile() (Qiskit/qi…
mtreinish Jul 19, 2023
2e16165
Add a new argument concurrent_measurements to target class (Qiskit/qi…
to24toro Jul 20, 2023
cffeaeb
Fix broken documentation references in `qiskit.providers` (Qiskit/qis…
jakelishman Aug 31, 2023
67d89bd
Deprecate ``qiskit.extensions`` (Qiskit/qiskit#10725)
Cryoris Sep 29, 2023
e2bd0ee
Many mentions to QASM should be changed to OpenQASM 2 (Qiskit/qiskit#…
1ucian0 Sep 29, 2023
36086d6
Merge branch 'main' of ../qiskit-terra into migrate-fake-backends
ElePT Oct 4, 2023
0af343f
Update fake backends
ElePT Oct 4, 2023
851e653
Fix style
ElePT Oct 4, 2023
a828c4c
Fix mypy
ElePT Oct 5, 2023
4421f7d
Integration test proposal
ElePT Oct 5, 2023
ae61eac
Fix lint
ElePT Oct 5, 2023
a9bc06e
Fix black
ElePT Oct 5, 2023
1b9bbcb
Add different integration test
ElePT Oct 9, 2023
e882e83
Fix lint, mypy
ElePT Oct 9, 2023
d80b46c
Fix lint
ElePT Oct 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
253 changes: 253 additions & 0 deletions qiskit_ibm_provider/fake_provider/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2022, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""
======================================================
Fake Provider (:mod:`qiskit_ibm_provider.fake_provider`)
======================================================

.. currentmodule:: qiskit_ibm_provider.fake_provider

Overview
========

The fake provider module contains fake providers and fake backends classes. The fake backends are
built to mimic the behaviors of IBM Quantum systems using system snapshots. The system snapshots
contain important information about the quantum system such as coupling map, basis gates, qubit
properties (T1, T2, error rate, etc.) which are useful for testing the transpiler and performing
noisy simulation of the system.

Example Usage
=============

Here is an example of using a fake backend for transpilation and simulation.

.. plot::
:include-source:

from qiskit import QuantumCircuit
from qiskit_ibm_provider.fake_provider import FakeManilaV2
from qiskit import transpile
from qiskit.tools.visualization import plot_histogram


# Get a fake backend from the fake provider
backend = FakeManilaV2()

# Create a simple circuit
circuit = QuantumCircuit(3)
circuit.h(0)
circuit.cx(0,1)
circuit.cx(0,2)
circuit.measure_all()
circuit.draw('mpl')

# Transpile the ideal circuit to a circuit that can be directly executed by the backend
transpiled_circuit = transpile(circuit, backend)
transpiled_circuit.draw('mpl')

# Run the transpiled circuit using the simulated fake backend
job = backend.run(transpiled_circuit)
counts = job.result().get_counts()
plot_histogram(counts)

.. important::

Please note that the simulation is done using a noise model generated from system snapshots
obtained in the past (sometimes a few years ago) and the results are not representative of the
latest behaviours of the real quantum system which the fake backend is mimicking. If you want to
run noisy simulations to compare with the real quantum system, you should use the ``qiskit_aer``
library. After installation, you can follow the steps below to generate a simulator that
mimics a real quantum system with the latest calibration results.

.. code-block:: python

from qiskit_ibm_provider import IBMProvider
from qiskit.providers.aer import AerSimulator
ElePT marked this conversation as resolved.
Show resolved Hide resolved

# get a real backend from a real provider
provider = IBMProvider()
backend = provider.get_backend('ibmq_manila')

# generate a simulator that mimics the real quantum system with the latest calibration results
backend_sim = AerSimulator.from_backend(backend)


Fake Providers
==============

Fake providers provide access to a list of fake backends.

.. autosummary::
:toctree: ../stubs/

FakeProviderForBackendV2
FakeProvider

Fake Backends
=============

Fake V2 Backends
----------------

Fake V2 backends are fake backends with IBM Quantum systems snapshots implemented with
:mod:`~qiskit.providers.backend.BackendV2` interface. They are all subclasses of
:class:`FakeBackendV2`.

.. autosummary::
:toctree: ../stubs/

FakeAlmadenV2
FakeArmonkV2
FakeAthensV2
FakeAuckland
FakeBelemV2
FakeBoeblingenV2
FakeBogotaV2
FakeBrooklynV2
FakeBurlingtonV2
FakeCairoV2
FakeCambridgeV2
FakeCasablancaV2
FakeEssexV2
FakeGeneva
FakeGuadalupeV2
FakeHanoiV2
FakeJakartaV2
FakeJohannesburgV2
FakeKolkataV2
FakeLagosV2
FakeLimaV2
FakeLondonV2
FakeManhattanV2
FakeManilaV2
FakeMelbourneV2
FakeMontrealV2
FakeMumbaiV2
FakeNairobiV2
FakeOslo
FakeOurenseV2
FakeParisV2
FakePerth
FakePrague
FakePoughkeepsieV2
FakeQuitoV2
FakeRochesterV2
FakeRomeV2
.. FakeRueschlikonV2 # no v2 version
FakeSantiagoV2
FakeSherbrooke
FakeSingaporeV2
FakeSydneyV2
.. FakeTenerifeV2 # no v2 version
.. FakeTokyoV2 # no v2 version
FakeTorontoV2
FakeValenciaV2
FakeVigoV2
FakeWashingtonV2
FakeYorktownV2

Fake V1 Backends
----------------

Fake V1 backends are fake backends with IBM Quantum systems snapshots implemented with
:mod:`~qiskit.providers.backend.BackendV1` interface.

.. autosummary::
:toctree: ../stubs/

FakeAlmaden
FakeArmonk
FakeAthens
FakeBelem
FakeBoeblingen
FakeBogota
FakeBrooklyn
FakeBurlington
FakeCairo
FakeCambridge
FakeCasablanca
FakeEssex
FakeGuadalupe
FakeHanoi
FakeJakarta
FakeJohannesburg
FakeKolkata
FakeLagos
FakeLima
FakeLondon
FakeManhattan
FakeManila
FakeMelbourne
FakeMontreal
FakeMumbai
FakeNairobi
FakeOurense
FakeParis
FakePoughkeepsie
FakeQuito
FakeRochester
FakeRome
FakeRueschlikon
FakeSantiago
FakeSingapore
FakeSydney
FakeTenerife
FakeTokyo
FakeToronto
FakeValencia
FakeVigo
FakeWashington
FakeYorktown

Special Fake Backends
=====================

Special fake backends are fake backends that were created for special testing purposes.

.. autosummary::
:toctree: ../stubs/

FakeQasmSimulator

Fake Backend Base Classes
=========================

The fake backends based on IBM hardware are based on a set of base classes:

.. currentmodule:: qiskit_ibm_provider.fake_provider.fake_backend
.. autoclass:: qiskit_ibm_provider.fake_provider.fake_backend.FakeBackendV2

.. currentmodule:: qiskit_ibm_provider.fake_provider
.. autoclass:: FakeBackend
.. autoclass:: FakeQasmBackend
.. autoclass:: FakePulseBackend
"""

# Fake job and qobj classes
from .fake_job import FakeJob
from .fake_qobj import FakeQobj

# Base classes for fake backends
from . import fake_backend
from .fake_backend import FakeBackend
from .fake_qasm_backend import FakeQasmBackend
from .fake_pulse_backend import FakePulseBackend

# Fake providers
from .fake_provider import FakeProviderFactory, FakeProviderForBackendV2, FakeProvider

# Standard fake backends with IBM Quantum systems snapshots
from .backends import *

# Special fake backends for special testing purposes
from .fake_qasm_simulator import FakeQasmSimulator
110 changes: 110 additions & 0 deletions qiskit_ibm_provider/fake_provider/backends/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2019, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.


"""
Mocked versions of real quantum backends.
"""

# BackendV2 Backends
from .almaden import FakeAlmadenV2
from .armonk import FakeArmonkV2
from .athens import FakeAthensV2
from .auckland import FakeAuckland
from .belem import FakeBelemV2
from .boeblingen import FakeBoeblingenV2
from .bogota import FakeBogotaV2
from .brooklyn import FakeBrooklynV2
from .burlington import FakeBurlingtonV2
from .cairo import FakeCairoV2
from .cambridge import FakeCambridgeV2
from .casablanca import FakeCasablancaV2
from .essex import FakeEssexV2
from .geneva import FakeGeneva
from .guadalupe import FakeGuadalupeV2
from .hanoi import FakeHanoiV2
from .jakarta import FakeJakartaV2
from .johannesburg import FakeJohannesburgV2
from .kolkata import FakeKolkataV2
from .lagos import FakeLagosV2
from .lima import FakeLimaV2
from .london import FakeLondonV2
from .manhattan import FakeManhattanV2
from .manila import FakeManilaV2
from .melbourne import FakeMelbourneV2
from .montreal import FakeMontrealV2
from .mumbai import FakeMumbaiV2
from .nairobi import FakeNairobiV2
from .oslo import FakeOslo
from .ourense import FakeOurenseV2
from .paris import FakeParisV2
from .perth import FakePerth
from .prague import FakePrague
from .poughkeepsie import FakePoughkeepsieV2
from .quito import FakeQuitoV2
from .rochester import FakeRochesterV2
from .rome import FakeRomeV2
from .santiago import FakeSantiagoV2
from .sherbrooke import FakeSherbrooke
from .singapore import FakeSingaporeV2
from .sydney import FakeSydneyV2
from .toronto import FakeTorontoV2
from .valencia import FakeValenciaV2
from .vigo import FakeVigoV2
from .washington import FakeWashingtonV2
from .yorktown import FakeYorktownV2

# BackendV1 Backends
from .almaden import FakeAlmaden
from .armonk import FakeArmonk
from .athens import FakeAthens
from .belem import FakeBelem
from .boeblingen import FakeBoeblingen
from .bogota import FakeBogota
from .brooklyn import FakeBrooklyn
from .burlington import FakeBurlington
from .cairo import FakeCairo
from .cambridge import FakeCambridge
from .cambridge import FakeCambridgeAlternativeBasis
from .casablanca import FakeCasablanca
from .essex import FakeEssex
from .guadalupe import FakeGuadalupe
from .hanoi import FakeHanoi
from .jakarta import FakeJakarta
from .johannesburg import FakeJohannesburg
from .kolkata import FakeKolkata
from .lagos import FakeLagos
from .lima import FakeLima
from .london import FakeLondon
from .manhattan import FakeManhattan
from .manila import FakeManila
from .melbourne import FakeMelbourne
from .montreal import FakeMontreal
from .mumbai import FakeMumbai
from .nairobi import FakeNairobi
from .ourense import FakeOurense
from .paris import FakeParis
from .poughkeepsie import FakePoughkeepsie
from .quito import FakeQuito
from .rochester import FakeRochester
from .rome import FakeRome
from .rueschlikon import FakeRueschlikon
from .santiago import FakeSantiago
from .singapore import FakeSingapore
from .sydney import FakeSydney
from .tenerife import FakeTenerife
from .tokyo import FakeTokyo
from .toronto import FakeToronto
from .valencia import FakeValencia
from .vigo import FakeVigo
from .washington import FakeWashington
from .yorktown import FakeYorktown
16 changes: 16 additions & 0 deletions qiskit_ibm_provider/fake_provider/backends/almaden/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2019, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""Mock almaden backend"""

from .fake_almaden import FakeAlmadenV2
from .fake_almaden import FakeAlmaden

Large diffs are not rendered by default.

Loading
Loading