diff --git a/qiskit/providers/fake_provider/__init__.py b/qiskit/providers/fake_provider/__init__.py index d90b36acf100..0d06cfcb161b 100644 --- a/qiskit/providers/fake_provider/__init__.py +++ b/qiskit/providers/fake_provider/__init__.py @@ -20,7 +20,11 @@ The mock devices are mainly for testing the compiler. """ -from qiskit.test.mock.fake_provider import FakeProvider, FakeLegacyProvider +from qiskit.test.mock.fake_provider import ( + FakeProviderForBackendV2, + FakeProvider, + FakeLegacyProvider, +) from qiskit.test.mock.fake_provider import FakeProviderFactory from qiskit.test.mock.fake_backend import FakeBackend, FakeLegacyBackend from qiskit.test.mock.fake_pulse_backend import FakePulseBackend, FakePulseLegacyBackend diff --git a/qiskit/test/mock/__init__.py b/qiskit/test/mock/__init__.py index b4cb1d690b54..621aef085871 100644 --- a/qiskit/test/mock/__init__.py +++ b/qiskit/test/mock/__init__.py @@ -20,7 +20,7 @@ The mock devices are mainly for testing the compiler. """ -from .fake_provider import FakeProvider, FakeLegacyProvider +from .fake_provider import FakeProviderForBackendV2, FakeProvider, FakeLegacyProvider from .fake_provider import FakeProviderFactory from .fake_backend import FakeBackend, FakeLegacyBackend from .fake_backend_v2 import FakeBackendV2, FakeBackend5QV2 diff --git a/qiskit/test/mock/backends/__init__.py b/qiskit/test/mock/backends/__init__.py index ca0cbe8df086..36fc787dd80f 100644 --- a/qiskit/test/mock/backends/__init__.py +++ b/qiskit/test/mock/backends/__init__.py @@ -15,6 +15,48 @@ Mocked versions of real quantum backends. """ +# BackendV2 Backends +from .almaden import FakeAlmadenV2 +from .armonk import FakeArmonkV2 +from .athens import FakeAthensV2 +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 .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 .ourense import FakeOurenseV2 +from .paris import FakeParisV2 +from .poughkeepsie import FakePoughkeepsieV2 +from .quito import FakeQuitoV2 +from .rochester import FakeRochesterV2 +from .rome import FakeRomeV2 +from .santiago import FakeSantiagoV2 +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 diff --git a/qiskit/test/mock/backends/almaden/__init__.py b/qiskit/test/mock/backends/almaden/__init__.py index a4a1017d0722..2dd9d10bbee4 100644 --- a/qiskit/test/mock/backends/almaden/__init__.py +++ b/qiskit/test/mock/backends/almaden/__init__.py @@ -12,5 +12,6 @@ """Mock almaden backend""" +from .fake_almaden import FakeAlmadenV2 from .fake_almaden import FakeAlmaden from .fake_almaden import FakeLegacyAlmaden diff --git a/qiskit/test/mock/backends/almaden/fake_almaden.py b/qiskit/test/mock/backends/almaden/fake_almaden.py index 5c5f8987cdb2..5e64fe9dca3d 100644 --- a/qiskit/test/mock/backends/almaden/fake_almaden.py +++ b/qiskit/test/mock/backends/almaden/fake_almaden.py @@ -15,7 +15,26 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeAlmadenV2(fake_backend.FakeBackendV2): + """A fake Almaden V2 backend. + + 00 ↔ 01 ↔ 02 ↔ 03 ↔ 04 + ↕ ↕ + 05 ↔ 06 ↔ 07 ↔ 08 ↔ 09 + ↕ ↕ ↕ + 10 ↔ 11 ↔ 12 ↔ 13 ↔ 14 + ↕ ↕ + 15 ↔ 16 ↔ 17 ↔ 18 ↔ 19 + """ + + dirname = os.path.dirname(__file__) + conf_filename = "conf_almaden.json" + props_filename = "props_almaden.json" + defs_filename = "defs_almaden.json" + backend_name = "fake_almaden_v2" class FakeAlmaden(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/armonk/__init__.py b/qiskit/test/mock/backends/armonk/__init__.py index 9c640e17131d..04602d985a25 100644 --- a/qiskit/test/mock/backends/armonk/__init__.py +++ b/qiskit/test/mock/backends/armonk/__init__.py @@ -12,5 +12,6 @@ """Mock armonk backend""" +from .fake_armonk import FakeArmonkV2 from .fake_armonk import FakeArmonk from .fake_armonk import FakeLegacyArmonk diff --git a/qiskit/test/mock/backends/armonk/fake_armonk.py b/qiskit/test/mock/backends/armonk/fake_armonk.py index afaf2727fd9b..8c9e16b5e17d 100644 --- a/qiskit/test/mock/backends/armonk/fake_armonk.py +++ b/qiskit/test/mock/backends/armonk/fake_armonk.py @@ -15,7 +15,20 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeArmonkV2(fake_backend.FakeBackendV2): + """A fake 1 qubit backend. + + 0 + """ + + dirname = os.path.dirname(__file__) + conf_filename = "conf_armonk.json" + props_filename = "props_armonk.json" + defs_filename = "defs_armonk.json" + backend_name = "fake_armonk_v2" class FakeArmonk(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/athens/__init__.py b/qiskit/test/mock/backends/athens/__init__.py index 3515e141ce23..4f1442274e85 100644 --- a/qiskit/test/mock/backends/athens/__init__.py +++ b/qiskit/test/mock/backends/athens/__init__.py @@ -12,5 +12,6 @@ """Mock athens backend""" +from .fake_athens import FakeAthensV2 from .fake_athens import FakeAthens from .fake_athens import FakeLegacyAthens diff --git a/qiskit/test/mock/backends/athens/fake_athens.py b/qiskit/test/mock/backends/athens/fake_athens.py index 3de92aebd180..b56983a8751d 100644 --- a/qiskit/test/mock/backends/athens/fake_athens.py +++ b/qiskit/test/mock/backends/athens/fake_athens.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeAthensV2(fake_backend.FakeBackendV2): + """A fake 5 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_athens.json" + props_filename = "props_athens.json" + defs_filename = "defs_athens.json" + backend_name = "fake_athens_v2" class FakeAthens(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/belem/__init__.py b/qiskit/test/mock/backends/belem/__init__.py index 1290ce0c13fb..842164136550 100644 --- a/qiskit/test/mock/backends/belem/__init__.py +++ b/qiskit/test/mock/backends/belem/__init__.py @@ -12,5 +12,6 @@ """Mock belem backend""" +from .fake_belem import FakeBelemV2 from .fake_belem import FakeBelem from .fake_belem import FakeLegacyBelem diff --git a/qiskit/test/mock/backends/belem/fake_belem.py b/qiskit/test/mock/backends/belem/fake_belem.py index cc385f348462..af4db3e4239d 100644 --- a/qiskit/test/mock/backends/belem/fake_belem.py +++ b/qiskit/test/mock/backends/belem/fake_belem.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeBelemV2(fake_backend.FakeBackendV2): + """A fake 5 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_belem.json" + props_filename = "props_belem.json" + defs_filename = "defs_belem.json" + backend_name = "fake_belem_v2" class FakeBelem(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/boeblingen/__init__.py b/qiskit/test/mock/backends/boeblingen/__init__.py index 2b62a25fb7c6..f0f9565d1305 100644 --- a/qiskit/test/mock/backends/boeblingen/__init__.py +++ b/qiskit/test/mock/backends/boeblingen/__init__.py @@ -12,5 +12,6 @@ """Mock boeblingen backend""" +from .fake_boeblingen import FakeBoeblingenV2 from .fake_boeblingen import FakeBoeblingen from .fake_boeblingen import FakeLegacyBoeblingen diff --git a/qiskit/test/mock/backends/boeblingen/fake_boeblingen.py b/qiskit/test/mock/backends/boeblingen/fake_boeblingen.py index 0397da2ed433..8b44fa38ff22 100644 --- a/qiskit/test/mock/backends/boeblingen/fake_boeblingen.py +++ b/qiskit/test/mock/backends/boeblingen/fake_boeblingen.py @@ -15,7 +15,26 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeBoeblingenV2(fake_backend.FakeBackendV2): + """A fake Boeblingen V2 backend. + + 00 ↔ 01 ↔ 02 ↔ 03 ↔ 04 + ↕ ↕ + 05 ↔ 06 ↔ 07 ↔ 08 ↔ 09 + ↕ ↕ ↕ + 10 ↔ 11 ↔ 12 ↔ 13 ↔ 14 + ↕ ↕ + 15 ↔ 16 ↔ 17 ↔ 18 ↔ 19 + """ + + dirname = os.path.dirname(__file__) + conf_filename = "conf_boeblingen.json" + props_filename = "props_boeblingen.json" + defs_filename = "defs_boeblingen.json" + backend_name = "fake_boeblingen_v2" class FakeBoeblingen(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/bogota/__init__.py b/qiskit/test/mock/backends/bogota/__init__.py index 9d121f1d5310..c1cf6ce65022 100644 --- a/qiskit/test/mock/backends/bogota/__init__.py +++ b/qiskit/test/mock/backends/bogota/__init__.py @@ -12,5 +12,6 @@ """Mock bogota backend""" +from .fake_bogota import FakeBogotaV2 from .fake_bogota import FakeBogota from .fake_bogota import FakeLegacyBogota diff --git a/qiskit/test/mock/backends/bogota/fake_bogota.py b/qiskit/test/mock/backends/bogota/fake_bogota.py index 56ece3f3c45d..4c1e4fa6f4b1 100644 --- a/qiskit/test/mock/backends/bogota/fake_bogota.py +++ b/qiskit/test/mock/backends/bogota/fake_bogota.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeBogotaV2(fake_backend.FakeBackendV2): + """A fake 5 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_bogota.json" + props_filename = "props_bogota.json" + defs_filename = "defs_bogota.json" + backend_name = "fake_bogota_v2" class FakeBogota(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/brooklyn/__init__.py b/qiskit/test/mock/backends/brooklyn/__init__.py index 4fa690289122..cb0eadb49f42 100644 --- a/qiskit/test/mock/backends/brooklyn/__init__.py +++ b/qiskit/test/mock/backends/brooklyn/__init__.py @@ -12,4 +12,5 @@ """Mock brooklyn backend""" +from .fake_brooklyn import FakeBrooklynV2 from .fake_brooklyn import FakeBrooklyn diff --git a/qiskit/test/mock/backends/brooklyn/fake_brooklyn.py b/qiskit/test/mock/backends/brooklyn/fake_brooklyn.py index bf2968e900c2..30f1587c3fbb 100644 --- a/qiskit/test/mock/backends/brooklyn/fake_brooklyn.py +++ b/qiskit/test/mock/backends/brooklyn/fake_brooklyn.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeBrooklynV2(fake_backend.FakeBackendV2): + """A fake Brooklyn V2 backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_brooklyn.json" + props_filename = "props_brooklyn.json" + defs_filename = "defs_brooklyn.json" + backend_name = "fake_brooklyn_v2" class FakeBrooklyn(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/burlington/__init__.py b/qiskit/test/mock/backends/burlington/__init__.py index d81d099e227a..6a1f0b0fb409 100644 --- a/qiskit/test/mock/backends/burlington/__init__.py +++ b/qiskit/test/mock/backends/burlington/__init__.py @@ -12,5 +12,6 @@ """Mock burlington backend""" +from .fake_burlington import FakeBurlingtonV2 from .fake_burlington import FakeBurlington from .fake_burlington import FakeLegacyBurlington diff --git a/qiskit/test/mock/backends/burlington/fake_burlington.py b/qiskit/test/mock/backends/burlington/fake_burlington.py index 69d94be68095..ece8ce3079f9 100644 --- a/qiskit/test/mock/backends/burlington/fake_burlington.py +++ b/qiskit/test/mock/backends/burlington/fake_burlington.py @@ -15,7 +15,21 @@ """ import os -from qiskit.test.mock import fake_qasm_backend +from qiskit.test.mock import fake_qasm_backend, fake_backend + + +class FakeBurlingtonV2(fake_backend.FakeBackendV2): + """A fake 5 qubit backend. + + 0 ↔ 1 ↔ 3 ↔ 4 + ↕ + 2 + """ + + dirname = os.path.dirname(__file__) + conf_filename = "conf_burlington.json" + props_filename = "props_burlington.json" + backend_name = "fake_burlington_v2" class FakeBurlington(fake_qasm_backend.FakeQasmBackend): diff --git a/qiskit/test/mock/backends/cairo/__init__.py b/qiskit/test/mock/backends/cairo/__init__.py index 1cd358bdb497..a765383df106 100644 --- a/qiskit/test/mock/backends/cairo/__init__.py +++ b/qiskit/test/mock/backends/cairo/__init__.py @@ -12,4 +12,5 @@ """Mock cairo backend""" +from .fake_cairo import FakeCairoV2 from .fake_cairo import FakeCairo diff --git a/qiskit/test/mock/backends/cairo/fake_cairo.py b/qiskit/test/mock/backends/cairo/fake_cairo.py index 4fa3d367d0cd..5a72ec5591ea 100644 --- a/qiskit/test/mock/backends/cairo/fake_cairo.py +++ b/qiskit/test/mock/backends/cairo/fake_cairo.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeCairoV2(fake_backend.FakeBackendV2): + """A fake 27 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_cairo.json" + props_filename = "props_cairo.json" + defs_filename = "defs_cairo.json" + backend_name = "fake_cairo_v2" class FakeCairo(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/cambridge/__init__.py b/qiskit/test/mock/backends/cambridge/__init__.py index daa622ccdd17..26cab4e61cc3 100644 --- a/qiskit/test/mock/backends/cambridge/__init__.py +++ b/qiskit/test/mock/backends/cambridge/__init__.py @@ -12,6 +12,7 @@ """Mock cambridge backend""" +from .fake_cambridge import FakeCambridgeV2 from .fake_cambridge import FakeCambridge from .fake_cambridge import FakeCambridgeAlternativeBasis from .fake_cambridge import FakeLegacyCambridge diff --git a/qiskit/test/mock/backends/cambridge/fake_cambridge.py b/qiskit/test/mock/backends/cambridge/fake_cambridge.py index 17f24edaf24d..2eb89be093f9 100644 --- a/qiskit/test/mock/backends/cambridge/fake_cambridge.py +++ b/qiskit/test/mock/backends/cambridge/fake_cambridge.py @@ -15,7 +15,27 @@ """ import os -from qiskit.test.mock import fake_qasm_backend +from qiskit.test.mock import fake_qasm_backend, fake_backend + + +class FakeCambridgeV2(fake_backend.FakeBackendV2): + """A fake Cambridge backend. + + 00 ↔ 01 ↔ 02 ↔ 03 ↔ 04 + ↕ ↕ + 05 06 + ↕ ↕ + 07 ↔ 08 ↔ 09 ↔ 10 ↔ 11 ↔ 12 ↔ 13 ↔ 14 ↔ 15 + ↕ ↕ ↕ + 16 17 18 + ↕ ↕ ↕ + 19 ↔ 20 ↔ 21 ↔ 22 ↔ 23 ↔ 24 ↔ 25 ↔ 26 ↔ 27 + """ + + dirname = os.path.dirname(__file__) + conf_filename = "conf_cambridge.json" + props_filename = "props_cambridge.json" + backend_name = "fake_cambridge_v2" class FakeCambridge(fake_qasm_backend.FakeQasmBackend): diff --git a/qiskit/test/mock/backends/casablanca/__init__.py b/qiskit/test/mock/backends/casablanca/__init__.py index ddc376a7bf6e..02403355be29 100644 --- a/qiskit/test/mock/backends/casablanca/__init__.py +++ b/qiskit/test/mock/backends/casablanca/__init__.py @@ -12,5 +12,6 @@ """Mock casablanca backend""" +from .fake_casablanca import FakeCasablancaV2 from .fake_casablanca import FakeCasablanca from .fake_casablanca import FakeLegacyCasablanca diff --git a/qiskit/test/mock/backends/casablanca/fake_casablanca.py b/qiskit/test/mock/backends/casablanca/fake_casablanca.py index 65127e7e4bca..62f1008ed530 100644 --- a/qiskit/test/mock/backends/casablanca/fake_casablanca.py +++ b/qiskit/test/mock/backends/casablanca/fake_casablanca.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeCasablancaV2(fake_backend.FakeBackendV2): + """A fake 7 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_casablanca.json" + props_filename = "props_casablanca.json" + defs_filename = "defs_casablanca.json" + backend_name = "fake_casablanca_v2" class FakeCasablanca(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/essex/__init__.py b/qiskit/test/mock/backends/essex/__init__.py index 0b99064219ef..57c13692bfb0 100644 --- a/qiskit/test/mock/backends/essex/__init__.py +++ b/qiskit/test/mock/backends/essex/__init__.py @@ -12,5 +12,6 @@ """Mock essex backend""" +from .fake_essex import FakeEssexV2 from .fake_essex import FakeEssex from .fake_essex import FakeLegacyEssex diff --git a/qiskit/test/mock/backends/essex/fake_essex.py b/qiskit/test/mock/backends/essex/fake_essex.py index bfb4f6cba01f..b075bdf48a29 100644 --- a/qiskit/test/mock/backends/essex/fake_essex.py +++ b/qiskit/test/mock/backends/essex/fake_essex.py @@ -15,7 +15,23 @@ """ import os -from qiskit.test.mock import fake_qasm_backend +from qiskit.test.mock import fake_qasm_backend, fake_backend + + +class FakeEssexV2(fake_backend.FakeBackendV2): + """A fake 5 qubit backend. + + 0 ↔ 1 ↔ 2 + ↕ + 3 + ↕ + 4 + """ + + dirname = os.path.dirname(__file__) + conf_filename = "conf_essex.json" + props_filename = "props_essex.json" + backend_name = "fake_essex_v2" class FakeEssex(fake_qasm_backend.FakeQasmBackend): diff --git a/qiskit/test/mock/backends/guadalupe/__init__.py b/qiskit/test/mock/backends/guadalupe/__init__.py index 2219222e22d7..e15013b69fab 100644 --- a/qiskit/test/mock/backends/guadalupe/__init__.py +++ b/qiskit/test/mock/backends/guadalupe/__init__.py @@ -12,4 +12,5 @@ """Mock guadalupe backend""" +from .fake_guadalupe import FakeGuadalupeV2 from .fake_guadalupe import FakeGuadalupe diff --git a/qiskit/test/mock/backends/guadalupe/fake_guadalupe.py b/qiskit/test/mock/backends/guadalupe/fake_guadalupe.py index bc21774b484e..b44b8bbd9c71 100644 --- a/qiskit/test/mock/backends/guadalupe/fake_guadalupe.py +++ b/qiskit/test/mock/backends/guadalupe/fake_guadalupe.py @@ -16,7 +16,17 @@ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeGuadalupeV2(fake_backend.FakeBackendV2): + """A fake 16 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_guadalupe.json" + props_filename = "props_guadalupe.json" + defs_filename = "defs_guadalupe.json" + backend_name = "fake_guadalupe_v2" class FakeGuadalupe(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/hanoi/__init__.py b/qiskit/test/mock/backends/hanoi/__init__.py index b9d295477ace..f51accab3679 100644 --- a/qiskit/test/mock/backends/hanoi/__init__.py +++ b/qiskit/test/mock/backends/hanoi/__init__.py @@ -12,4 +12,5 @@ """Mock hanoi backend""" +from .fake_hanoi import FakeHanoiV2 from .fake_hanoi import FakeHanoi diff --git a/qiskit/test/mock/backends/hanoi/fake_hanoi.py b/qiskit/test/mock/backends/hanoi/fake_hanoi.py index e84a8c4ed9ec..67727cc5ce85 100644 --- a/qiskit/test/mock/backends/hanoi/fake_hanoi.py +++ b/qiskit/test/mock/backends/hanoi/fake_hanoi.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeHanoiV2(fake_backend.FakeBackendV2): + """A fake 27 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_hanoi.json" + props_filename = "props_hanoi.json" + defs_filename = "defs_hanoi.json" + backend_name = "fake_hanoi_v2" class FakeHanoi(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/jakarta/__init__.py b/qiskit/test/mock/backends/jakarta/__init__.py index 37e5d91dfb0a..df7db5e263ae 100644 --- a/qiskit/test/mock/backends/jakarta/__init__.py +++ b/qiskit/test/mock/backends/jakarta/__init__.py @@ -12,4 +12,5 @@ """Mock jakarta backend""" +from .fake_jakarta import FakeJakartaV2 from .fake_jakarta import FakeJakarta diff --git a/qiskit/test/mock/backends/jakarta/fake_jakarta.py b/qiskit/test/mock/backends/jakarta/fake_jakarta.py index bf8523925822..0cc699f709b4 100644 --- a/qiskit/test/mock/backends/jakarta/fake_jakarta.py +++ b/qiskit/test/mock/backends/jakarta/fake_jakarta.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeJakartaV2(fake_backend.FakeBackendV2): + """A fake 7 qubit V2 backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_jakarta.json" + props_filename = "props_jakarta.json" + defs_filename = "defs_jakarta.json" + backend_name = "fake_jakarta_v2" class FakeJakarta(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/johannesburg/__init__.py b/qiskit/test/mock/backends/johannesburg/__init__.py index 26a8a92a911f..e270f1c4f73d 100644 --- a/qiskit/test/mock/backends/johannesburg/__init__.py +++ b/qiskit/test/mock/backends/johannesburg/__init__.py @@ -12,5 +12,6 @@ """Mock johannesburg backend""" +from .fake_johannesburg import FakeJohannesburgV2 from .fake_johannesburg import FakeJohannesburg from .fake_johannesburg import FakeLegacyJohannesburg diff --git a/qiskit/test/mock/backends/johannesburg/fake_johannesburg.py b/qiskit/test/mock/backends/johannesburg/fake_johannesburg.py index ee3567afcce0..713bca2128f4 100644 --- a/qiskit/test/mock/backends/johannesburg/fake_johannesburg.py +++ b/qiskit/test/mock/backends/johannesburg/fake_johannesburg.py @@ -15,7 +15,26 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeJohannesburgV2(fake_backend.FakeBackendV2): + """A fake Johannesburg V2 backend. + + 00 ↔ 01 ↔ 02 ↔ 03 ↔ 04 + ↕ ↕ + 05 ↔ 06 ↔ 07 ↔ 08 ↔ 09 + ↕ ↕ ↕ + 10 ↔ 11 ↔ 12 ↔ 13 ↔ 14 + ↕ ↕ + 15 ↔ 16 ↔ 17 ↔ 18 ↔ 19 + """ + + dirname = os.path.dirname(__file__) + conf_filename = "conf_johannesburg.json" + props_filename = "props_johannesburg.json" + defs_filename = "defs_johannesburg.json" + backend_name = "fake_johannesburg_v2" class FakeJohannesburg(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/kolkata/__init__.py b/qiskit/test/mock/backends/kolkata/__init__.py index 0ba0705ec284..03c5143c9502 100644 --- a/qiskit/test/mock/backends/kolkata/__init__.py +++ b/qiskit/test/mock/backends/kolkata/__init__.py @@ -12,4 +12,5 @@ """Mock kolkata backend""" +from .fake_kolkata import FakeKolkataV2 from .fake_kolkata import FakeKolkata diff --git a/qiskit/test/mock/backends/kolkata/fake_kolkata.py b/qiskit/test/mock/backends/kolkata/fake_kolkata.py index 3cc1eff5bd4a..b37bf9351f77 100644 --- a/qiskit/test/mock/backends/kolkata/fake_kolkata.py +++ b/qiskit/test/mock/backends/kolkata/fake_kolkata.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeKolkataV2(fake_backend.FakeBackendV2): + """A fake 27 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_kolkata.json" + props_filename = "props_kolkata.json" + defs_filename = "defs_kolkata.json" + backend_name = "fake_kolkata_v2" class FakeKolkata(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/lagos/__init__.py b/qiskit/test/mock/backends/lagos/__init__.py index ff72ad04e05d..387afc6a5fe7 100644 --- a/qiskit/test/mock/backends/lagos/__init__.py +++ b/qiskit/test/mock/backends/lagos/__init__.py @@ -12,4 +12,5 @@ """Mock lagos backend""" +from .fake_lagos import FakeLagosV2 from .fake_lagos import FakeLagos diff --git a/qiskit/test/mock/backends/lagos/fake_lagos.py b/qiskit/test/mock/backends/lagos/fake_lagos.py index d91e421b12ed..4cdd2a3aab41 100644 --- a/qiskit/test/mock/backends/lagos/fake_lagos.py +++ b/qiskit/test/mock/backends/lagos/fake_lagos.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeLagosV2(fake_backend.FakeBackendV2): + """A fake 7 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_lagos.json" + props_filename = "props_lagos.json" + defs_filename = "defs_lagos.json" + backend_name = "fake_lagos_v2" class FakeLagos(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/lima/__init__.py b/qiskit/test/mock/backends/lima/__init__.py index 4041308aabe8..056166622b92 100644 --- a/qiskit/test/mock/backends/lima/__init__.py +++ b/qiskit/test/mock/backends/lima/__init__.py @@ -12,5 +12,6 @@ """Mock lima backend""" +from .fake_lima import FakeLimaV2 from .fake_lima import FakeLima from .fake_lima import FakeLegacyLima diff --git a/qiskit/test/mock/backends/lima/fake_lima.py b/qiskit/test/mock/backends/lima/fake_lima.py index 3fe9b6cba373..c621aead7c35 100644 --- a/qiskit/test/mock/backends/lima/fake_lima.py +++ b/qiskit/test/mock/backends/lima/fake_lima.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeLimaV2(fake_backend.FakeBackendV2): + """A fake 5 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_lima.json" + props_filename = "props_lima.json" + defs_filename = "defs_lima.json" + backend_name = "fake_lima" class FakeLima(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/london/__init__.py b/qiskit/test/mock/backends/london/__init__.py index 5adbf6a0995f..3ffc48c1454b 100644 --- a/qiskit/test/mock/backends/london/__init__.py +++ b/qiskit/test/mock/backends/london/__init__.py @@ -12,5 +12,6 @@ """Mock london backend""" +from .fake_london import FakeLondonV2 from .fake_london import FakeLondon from .fake_london import FakeLegacyLondon diff --git a/qiskit/test/mock/backends/london/fake_london.py b/qiskit/test/mock/backends/london/fake_london.py index 5f644906ac45..76e865277ac7 100644 --- a/qiskit/test/mock/backends/london/fake_london.py +++ b/qiskit/test/mock/backends/london/fake_london.py @@ -15,7 +15,23 @@ """ import os -from qiskit.test.mock import fake_qasm_backend +from qiskit.test.mock import fake_qasm_backend, fake_backend + + +class FakeLondonV2(fake_backend.FakeBackendV2): + """A fake 5 qubit backend. + + 0 ↔ 1 ↔ 2 + ↕ + 3 + ↕ + 4 + """ + + dirname = os.path.dirname(__file__) + conf_filename = "conf_london.json" + props_filename = "props_london.json" + backend_name = "fake_london_v2" class FakeLondon(fake_qasm_backend.FakeQasmBackend): diff --git a/qiskit/test/mock/backends/manhattan/__init__.py b/qiskit/test/mock/backends/manhattan/__init__.py index 6f1ef1d29271..ee35f3809537 100644 --- a/qiskit/test/mock/backends/manhattan/__init__.py +++ b/qiskit/test/mock/backends/manhattan/__init__.py @@ -12,5 +12,6 @@ """Mock manhattan backend""" +from .fake_manhattan import FakeManhattanV2 from .fake_manhattan import FakeManhattan from .fake_manhattan import FakeLegacyManhattan diff --git a/qiskit/test/mock/backends/manhattan/fake_manhattan.py b/qiskit/test/mock/backends/manhattan/fake_manhattan.py index 16a87ea92e34..5699b5c4f3f3 100644 --- a/qiskit/test/mock/backends/manhattan/fake_manhattan.py +++ b/qiskit/test/mock/backends/manhattan/fake_manhattan.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeManhattanV2(fake_backend.FakeBackendV2): + """A fake Manhattan backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_manhattan.json" + props_filename = "props_manhattan.json" + defs_filename = "defs_manhattan.json" + backend_name = "fake_manhattan_v2" class FakeManhattan(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/manila/__init__.py b/qiskit/test/mock/backends/manila/__init__.py index 5344288041d6..4ee7576ea3c4 100644 --- a/qiskit/test/mock/backends/manila/__init__.py +++ b/qiskit/test/mock/backends/manila/__init__.py @@ -12,4 +12,5 @@ """Mock manila backend""" +from .fake_manila import FakeManilaV2 from .fake_manila import FakeManila diff --git a/qiskit/test/mock/backends/manila/fake_manila.py b/qiskit/test/mock/backends/manila/fake_manila.py index 9739f18e5d52..d21167ba02da 100644 --- a/qiskit/test/mock/backends/manila/fake_manila.py +++ b/qiskit/test/mock/backends/manila/fake_manila.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeManilaV2(fake_backend.FakeBackendV2): + """A fake 5 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_manila.json" + props_filename = "props_manila.json" + defs_filename = "defs_manila.json" + backend_name = "fake_manila_v2" class FakeManila(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/melbourne/__init__.py b/qiskit/test/mock/backends/melbourne/__init__.py index 1375d17b2348..d3ce67f3fab8 100644 --- a/qiskit/test/mock/backends/melbourne/__init__.py +++ b/qiskit/test/mock/backends/melbourne/__init__.py @@ -12,5 +12,6 @@ """Mock melbourne backend""" +from .fake_melbourne import FakeMelbourneV2 from .fake_melbourne import FakeMelbourne from .fake_melbourne import FakeLegacyMelbourne diff --git a/qiskit/test/mock/backends/melbourne/fake_melbourne.py b/qiskit/test/mock/backends/melbourne/fake_melbourne.py index 576629a76083..91919bdacd6c 100644 --- a/qiskit/test/mock/backends/melbourne/fake_melbourne.py +++ b/qiskit/test/mock/backends/melbourne/fake_melbourne.py @@ -19,6 +19,16 @@ from qiskit.providers.models import GateConfig, QasmBackendConfiguration, BackendProperties from qiskit.test.mock.fake_backend import FakeBackend, FakeLegacyBackend +from qiskit.test.mock import fake_backend + + +class FakeMelbourneV2(fake_backend.FakeBackendV2): + """A fake 14 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_melbourne.json" + props_filename = "props_melbourne.json" + backend_name = "fake_melbourne_v2" class FakeMelbourne(FakeBackend): diff --git a/qiskit/test/mock/backends/montreal/__init__.py b/qiskit/test/mock/backends/montreal/__init__.py index da7c71e86605..8390468d928c 100644 --- a/qiskit/test/mock/backends/montreal/__init__.py +++ b/qiskit/test/mock/backends/montreal/__init__.py @@ -12,5 +12,6 @@ """Mock montreal backend""" +from .fake_montreal import FakeMontrealV2 from .fake_montreal import FakeMontreal from .fake_montreal import FakeLegacyMontreal diff --git a/qiskit/test/mock/backends/montreal/fake_montreal.py b/qiskit/test/mock/backends/montreal/fake_montreal.py index ad75c4dc3d51..8d24c2262a9a 100644 --- a/qiskit/test/mock/backends/montreal/fake_montreal.py +++ b/qiskit/test/mock/backends/montreal/fake_montreal.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeMontrealV2(fake_backend.FakeBackendV2): + """A fake 27 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_montreal.json" + props_filename = "props_montreal.json" + defs_filename = "defs_montreal.json" + backend_name = "fake_montreal_v2" class FakeMontreal(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/mumbai/__init__.py b/qiskit/test/mock/backends/mumbai/__init__.py index fda21b9a39ff..cfa1d860ac5f 100644 --- a/qiskit/test/mock/backends/mumbai/__init__.py +++ b/qiskit/test/mock/backends/mumbai/__init__.py @@ -12,5 +12,6 @@ """Mock mumbai backend""" +from .fake_mumbai import FakeMumbaiV2 from .fake_mumbai import FakeMumbai from .fake_mumbai import FakeLegacyMumbai diff --git a/qiskit/test/mock/backends/mumbai/fake_mumbai.py b/qiskit/test/mock/backends/mumbai/fake_mumbai.py index 7434a3accd46..41e6f83db8d1 100644 --- a/qiskit/test/mock/backends/mumbai/fake_mumbai.py +++ b/qiskit/test/mock/backends/mumbai/fake_mumbai.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeMumbaiV2(fake_backend.FakeBackendV2): + """A fake 27 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_mumbai.json" + props_filename = "props_mumbai.json" + defs_filename = "defs_mumbai.json" + backend_name = "fake_mumbai_v2" class FakeMumbai(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/nairobi/__init__.py b/qiskit/test/mock/backends/nairobi/__init__.py index ff1a49cf94f3..7c84cf255a72 100644 --- a/qiskit/test/mock/backends/nairobi/__init__.py +++ b/qiskit/test/mock/backends/nairobi/__init__.py @@ -12,4 +12,5 @@ """Mock nairobi backend""" +from .fake_nairobi import FakeNairobiV2 from .fake_nairobi import FakeNairobi diff --git a/qiskit/test/mock/backends/nairobi/fake_nairobi.py b/qiskit/test/mock/backends/nairobi/fake_nairobi.py index 601fcb42a13b..7db8d0a8d7d9 100644 --- a/qiskit/test/mock/backends/nairobi/fake_nairobi.py +++ b/qiskit/test/mock/backends/nairobi/fake_nairobi.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeNairobiV2(fake_backend.FakeBackendV2): + """A fake 7 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_nairobi.json" + props_filename = "props_nairobi.json" + defs_filename = "defs_nairobi.json" + backend_name = "fake_nairobi_v2" class FakeNairobi(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/ourense/__init__.py b/qiskit/test/mock/backends/ourense/__init__.py index 5da6833c7f79..4e73b1bffa47 100644 --- a/qiskit/test/mock/backends/ourense/__init__.py +++ b/qiskit/test/mock/backends/ourense/__init__.py @@ -12,5 +12,6 @@ """Mock ourense backend""" +from .fake_ourense import FakeOurenseV2 from .fake_ourense import FakeOurense from .fake_ourense import FakeLegacyOurense diff --git a/qiskit/test/mock/backends/ourense/fake_ourense.py b/qiskit/test/mock/backends/ourense/fake_ourense.py index 08d10706ddca..ae889ccb738b 100644 --- a/qiskit/test/mock/backends/ourense/fake_ourense.py +++ b/qiskit/test/mock/backends/ourense/fake_ourense.py @@ -15,7 +15,21 @@ """ import os -from qiskit.test.mock import fake_qasm_backend +from qiskit.test.mock import fake_qasm_backend, fake_backend + + +class FakeOurenseV2(fake_backend.FakeBackendV2): + """A fake 5 qubit backend. + + 0 ↔ 1 ↔ 3 ↔ 4 + ↕ + 2 + """ + + dirname = os.path.dirname(__file__) + conf_filename = "conf_ourense.json" + props_filename = "props_ourense.json" + backend_name = "fake_ourense_v2" class FakeOurense(fake_qasm_backend.FakeQasmBackend): diff --git a/qiskit/test/mock/backends/paris/__init__.py b/qiskit/test/mock/backends/paris/__init__.py index ae127163aac5..ed1354ade823 100644 --- a/qiskit/test/mock/backends/paris/__init__.py +++ b/qiskit/test/mock/backends/paris/__init__.py @@ -12,5 +12,6 @@ """Mock paris backend""" +from .fake_paris import FakeParisV2 from .fake_paris import FakeParis from .fake_paris import FakeLegacyParis diff --git a/qiskit/test/mock/backends/paris/fake_paris.py b/qiskit/test/mock/backends/paris/fake_paris.py index 8686c71a51af..452b5ac6a0ba 100644 --- a/qiskit/test/mock/backends/paris/fake_paris.py +++ b/qiskit/test/mock/backends/paris/fake_paris.py @@ -15,7 +15,28 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeParisV2(fake_backend.FakeBackendV2): + """A fake Paris backend. + + 06 17 + ↕ ↕ + 00 ↔ 01 ↔ 04 ↔ 07 ↔ 10 ↔ 12 ↔ 15 ↔ 18 ↔ 20 ↔ 23 + ↕ ↕ ↕ + 02 13 24 + ↕ ↕ ↕ + 03 ↔ 05 ↔ 08 ↔ 11 ↔ 14 ↔ 16 ↔ 19 ↔ 22 ↔ 25 ↔ 26 + ↕ ↕ + 09 20 + """ + + dirname = os.path.dirname(__file__) + conf_filename = "conf_paris.json" + props_filename = "props_paris.json" + defs_filename = "defs_paris.json" + backend_name = "fake_paris_v2" class FakeParis(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/poughkeepsie/__init__.py b/qiskit/test/mock/backends/poughkeepsie/__init__.py index 11c28b31bae0..2ca2c8bd853f 100644 --- a/qiskit/test/mock/backends/poughkeepsie/__init__.py +++ b/qiskit/test/mock/backends/poughkeepsie/__init__.py @@ -12,5 +12,6 @@ """Mock poughkeepsie backend""" +from .fake_poughkeepsie import FakePoughkeepsieV2 from .fake_poughkeepsie import FakePoughkeepsie from .fake_poughkeepsie import FakeLegacyPoughkeepsie diff --git a/qiskit/test/mock/backends/poughkeepsie/fake_poughkeepsie.py b/qiskit/test/mock/backends/poughkeepsie/fake_poughkeepsie.py index 7cd11f655dc6..0cb1bf117f92 100644 --- a/qiskit/test/mock/backends/poughkeepsie/fake_poughkeepsie.py +++ b/qiskit/test/mock/backends/poughkeepsie/fake_poughkeepsie.py @@ -19,6 +19,17 @@ from qiskit.providers.models import GateConfig, QasmBackendConfiguration, BackendProperties from qiskit.test.mock.fake_backend import FakeBackend, FakeLegacyBackend +from qiskit.test.mock import fake_backend + + +class FakePoughkeepsieV2(fake_backend.FakeBackendV2): + """A fake Poughkeepsie backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_poughkeepsie.json" + props_filename = "props_poughkeepsie.json" + defs_filename = "defs_poughkeepsie.json" + backend_name = "fake_poughkeepsie_v2" class FakePoughkeepsie(FakeBackend): diff --git a/qiskit/test/mock/backends/quito/__init__.py b/qiskit/test/mock/backends/quito/__init__.py index 26e7a660a2e5..566c991d0900 100644 --- a/qiskit/test/mock/backends/quito/__init__.py +++ b/qiskit/test/mock/backends/quito/__init__.py @@ -12,5 +12,6 @@ """Mock quito backend""" +from .fake_quito import FakeQuitoV2 from .fake_quito import FakeQuito from .fake_quito import FakeLegacyQuito diff --git a/qiskit/test/mock/backends/quito/fake_quito.py b/qiskit/test/mock/backends/quito/fake_quito.py index 5e9509b8b26b..af51260c6c8c 100644 --- a/qiskit/test/mock/backends/quito/fake_quito.py +++ b/qiskit/test/mock/backends/quito/fake_quito.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeQuitoV2(fake_backend.FakeBackendV2): + """A fake 5 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_quito.json" + props_filename = "props_quito.json" + defs_filename = "defs_quito.json" + backend_name = "fake_quito_v2" class FakeQuito(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/rochester/__init__.py b/qiskit/test/mock/backends/rochester/__init__.py index a7fc86a399e4..ad89890bc715 100644 --- a/qiskit/test/mock/backends/rochester/__init__.py +++ b/qiskit/test/mock/backends/rochester/__init__.py @@ -12,5 +12,6 @@ """Mock rochester backend""" +from .fake_rochester import FakeRochesterV2 from .fake_rochester import FakeRochester from .fake_rochester import FakeLegacyRochester diff --git a/qiskit/test/mock/backends/rochester/fake_rochester.py b/qiskit/test/mock/backends/rochester/fake_rochester.py index 73d4af291898..28e4169aeddb 100644 --- a/qiskit/test/mock/backends/rochester/fake_rochester.py +++ b/qiskit/test/mock/backends/rochester/fake_rochester.py @@ -15,7 +15,16 @@ """ import os -from qiskit.test.mock import fake_qasm_backend +from qiskit.test.mock import fake_qasm_backend, fake_backend + + +class FakeRochesterV2(fake_backend.FakeBackendV2): + """A fake Rochester backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_rochester.json" + props_filename = "props_rochester.json" + backend_name = "fake_rochester_v2" class FakeRochester(fake_qasm_backend.FakeQasmBackend): diff --git a/qiskit/test/mock/backends/rome/__init__.py b/qiskit/test/mock/backends/rome/__init__.py index 678fd5cefb8c..e0f2f3c76488 100644 --- a/qiskit/test/mock/backends/rome/__init__.py +++ b/qiskit/test/mock/backends/rome/__init__.py @@ -12,5 +12,6 @@ """Mock rome backend""" +from .fake_rome import FakeRomeV2 from .fake_rome import FakeRome from .fake_rome import FakeLegacyRome diff --git a/qiskit/test/mock/backends/rome/fake_rome.py b/qiskit/test/mock/backends/rome/fake_rome.py index cabe791aba88..b39739333e1c 100644 --- a/qiskit/test/mock/backends/rome/fake_rome.py +++ b/qiskit/test/mock/backends/rome/fake_rome.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeRomeV2(fake_backend.FakeBackendV2): + """A fake 5 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_rome.json" + props_filename = "props_rome.json" + defs_filename = "defs_rome.json" + backend_name = "fake_rome_v2" class FakeRome(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/santiago/__init__.py b/qiskit/test/mock/backends/santiago/__init__.py index 2e8e6b55e717..f6e73c04b6c8 100644 --- a/qiskit/test/mock/backends/santiago/__init__.py +++ b/qiskit/test/mock/backends/santiago/__init__.py @@ -12,5 +12,6 @@ """Mock santiago backend""" +from .fake_santiago import FakeSantiagoV2 from .fake_santiago import FakeSantiago from .fake_santiago import FakeLegacySantiago diff --git a/qiskit/test/mock/backends/santiago/fake_santiago.py b/qiskit/test/mock/backends/santiago/fake_santiago.py index f25b630d760f..25de8f7ef6db 100644 --- a/qiskit/test/mock/backends/santiago/fake_santiago.py +++ b/qiskit/test/mock/backends/santiago/fake_santiago.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeSantiagoV2(fake_backend.FakeBackendV2): + """A fake Santiago backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_santiago.json" + props_filename = "props_santiago.json" + defs_filename = "defs_santiago.json" + backend_name = "fake_santiago_v2" class FakeSantiago(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/singapore/__init__.py b/qiskit/test/mock/backends/singapore/__init__.py index 4068b1897c32..ed72f84e8636 100644 --- a/qiskit/test/mock/backends/singapore/__init__.py +++ b/qiskit/test/mock/backends/singapore/__init__.py @@ -12,5 +12,6 @@ """Mock singapore backend""" +from .fake_singapore import FakeSingaporeV2 from .fake_singapore import FakeSingapore from .fake_singapore import FakeLegacySingapore diff --git a/qiskit/test/mock/backends/singapore/fake_singapore.py b/qiskit/test/mock/backends/singapore/fake_singapore.py index ce2e5e6817d5..afb7b023c7b2 100644 --- a/qiskit/test/mock/backends/singapore/fake_singapore.py +++ b/qiskit/test/mock/backends/singapore/fake_singapore.py @@ -15,7 +15,26 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeSingaporeV2(fake_backend.FakeBackendV2): + """A fake Singapore backend. + + 00 ↔ 01 ↔ 02 ↔ 03 ↔ 04 + ↕ ↕ + 05 ↔ 06 ↔ 07 ↔ 08 ↔ 09 + ↕ ↕ ↕ + 10 ↔ 11 ↔ 12 ↔ 13 ↔ 14 + ↕ ↕ + 15 ↔ 16 ↔ 17 ↔ 18 ↔ 19 + """ + + dirname = os.path.dirname(__file__) + conf_filename = "conf_singapore.json" + props_filename = "props_singapore.json" + defs_filename = "defs_singapore.json" + backend_name = "fake_singapore_v2" class FakeSingapore(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/sydney/__init__.py b/qiskit/test/mock/backends/sydney/__init__.py index 9a3a5441c985..c86b30026f73 100644 --- a/qiskit/test/mock/backends/sydney/__init__.py +++ b/qiskit/test/mock/backends/sydney/__init__.py @@ -12,5 +12,6 @@ """Mock sydney backend""" +from .fake_sydney import FakeSydneyV2 from .fake_sydney import FakeSydney from .fake_sydney import FakeLegacySydney diff --git a/qiskit/test/mock/backends/sydney/fake_sydney.py b/qiskit/test/mock/backends/sydney/fake_sydney.py index fbc1c3ef27d4..ec49344a6f05 100644 --- a/qiskit/test/mock/backends/sydney/fake_sydney.py +++ b/qiskit/test/mock/backends/sydney/fake_sydney.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeSydneyV2(fake_backend.FakeBackendV2): + """A fake 27 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_sydney.json" + props_filename = "props_sydney.json" + defs_filename = "defs_sydney.json" + backend_name = "fake_sydney_v2" class FakeSydney(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/toronto/__init__.py b/qiskit/test/mock/backends/toronto/__init__.py index 20fc29f6c2e9..f8acfc13cdc0 100644 --- a/qiskit/test/mock/backends/toronto/__init__.py +++ b/qiskit/test/mock/backends/toronto/__init__.py @@ -12,5 +12,6 @@ """Mock toronto backend""" +from .fake_toronto import FakeTorontoV2 from .fake_toronto import FakeToronto from .fake_toronto import FakeLegacyToronto diff --git a/qiskit/test/mock/backends/toronto/fake_toronto.py b/qiskit/test/mock/backends/toronto/fake_toronto.py index 45a7fff3d201..cf59b82b8200 100644 --- a/qiskit/test/mock/backends/toronto/fake_toronto.py +++ b/qiskit/test/mock/backends/toronto/fake_toronto.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeTorontoV2(fake_backend.FakeBackendV2): + """A fake 27 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_toronto.json" + props_filename = "props_toronto.json" + defs_filename = "defs_toronto.json" + backend_name = "fake_toronto_v2" class FakeToronto(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/valencia/__init__.py b/qiskit/test/mock/backends/valencia/__init__.py index de6985098408..b76a400b02a9 100644 --- a/qiskit/test/mock/backends/valencia/__init__.py +++ b/qiskit/test/mock/backends/valencia/__init__.py @@ -12,5 +12,6 @@ """Mock valencia backend""" +from .fake_valencia import FakeValenciaV2 from .fake_valencia import FakeValencia from .fake_valencia import FakeLegacyValencia diff --git a/qiskit/test/mock/backends/valencia/fake_valencia.py b/qiskit/test/mock/backends/valencia/fake_valencia.py index e3bf14ee2882..e8a0c1213fff 100644 --- a/qiskit/test/mock/backends/valencia/fake_valencia.py +++ b/qiskit/test/mock/backends/valencia/fake_valencia.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeValenciaV2(fake_backend.FakeBackendV2): + """A fake 5 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_valencia.json" + props_filename = "props_valencia.json" + defs_filename = "defs_valencia.json" + backend_name = "fake_valencia_v2" class FakeValencia(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/vigo/__init__.py b/qiskit/test/mock/backends/vigo/__init__.py index 46b8a2b90bb2..1efe30e2a2ac 100644 --- a/qiskit/test/mock/backends/vigo/__init__.py +++ b/qiskit/test/mock/backends/vigo/__init__.py @@ -12,5 +12,6 @@ """Mock vigo backend""" +from .fake_vigo import FakeVigoV2 from .fake_vigo import FakeVigo from .fake_vigo import FakeLegacyVigo diff --git a/qiskit/test/mock/backends/vigo/fake_vigo.py b/qiskit/test/mock/backends/vigo/fake_vigo.py index e366fde49396..3b33fc12443f 100644 --- a/qiskit/test/mock/backends/vigo/fake_vigo.py +++ b/qiskit/test/mock/backends/vigo/fake_vigo.py @@ -15,7 +15,21 @@ """ import os -from qiskit.test.mock import fake_qasm_backend +from qiskit.test.mock import fake_qasm_backend, fake_backend + + +class FakeVigoV2(fake_backend.FakeBackendV2): + """A fake 5 qubit backend. + + 0 ↔ 1 ↔ 3 ↔ 4 + ↕ + 2 + """ + + dirname = os.path.dirname(__file__) + conf_filename = "conf_vigo.json" + props_filename = "props_vigo.json" + backend_name = "fake_vigo_v2" class FakeVigo(fake_qasm_backend.FakeQasmBackend): diff --git a/qiskit/test/mock/backends/washington/__init__.py b/qiskit/test/mock/backends/washington/__init__.py index c15dbdba22f4..e1a9d0ef6d4b 100644 --- a/qiskit/test/mock/backends/washington/__init__.py +++ b/qiskit/test/mock/backends/washington/__init__.py @@ -14,4 +14,5 @@ Fake Washington backend (127 qubit). """ +from .fake_washington import FakeWashingtonV2 from .fake_washington import FakeWashington diff --git a/qiskit/test/mock/backends/washington/fake_washington.py b/qiskit/test/mock/backends/washington/fake_washington.py index 6a140e62d313..472c382dd641 100644 --- a/qiskit/test/mock/backends/washington/fake_washington.py +++ b/qiskit/test/mock/backends/washington/fake_washington.py @@ -15,7 +15,17 @@ """ import os -from qiskit.test.mock import fake_pulse_backend +from qiskit.test.mock import fake_pulse_backend, fake_backend + + +class FakeWashingtonV2(fake_backend.FakeBackendV2): + """A fake 127 qubit backend.""" + + dirname = os.path.dirname(__file__) + conf_filename = "conf_washington.json" + props_filename = "props_washington.json" + defs_filename = "defs_washington.json" + backend_name = "fake_washington_v2" class FakeWashington(fake_pulse_backend.FakePulseBackend): diff --git a/qiskit/test/mock/backends/yorktown/__init__.py b/qiskit/test/mock/backends/yorktown/__init__.py index f140dad625c1..e7486f0acd57 100644 --- a/qiskit/test/mock/backends/yorktown/__init__.py +++ b/qiskit/test/mock/backends/yorktown/__init__.py @@ -12,5 +12,6 @@ """Mock yorktown backend""" +from .fake_yorktown import FakeYorktownV2 from .fake_yorktown import FakeYorktown from .fake_yorktown import FakeLegacyYorktown diff --git a/qiskit/test/mock/backends/yorktown/fake_yorktown.py b/qiskit/test/mock/backends/yorktown/fake_yorktown.py index ebf641d04691..777081fcbee1 100644 --- a/qiskit/test/mock/backends/yorktown/fake_yorktown.py +++ b/qiskit/test/mock/backends/yorktown/fake_yorktown.py @@ -15,7 +15,23 @@ """ import os -from qiskit.test.mock import fake_qasm_backend +from qiskit.test.mock import fake_qasm_backend, fake_backend + + +class FakeYorktownV2(fake_backend.FakeBackendV2): + """A fake 5 qubit backend. + + 1 + / | + 0 - 2 - 3 + | / + 4 + """ + + dirname = os.path.dirname(__file__) + conf_filename = "conf_yorktown.json" + props_filename = "props_yorktown.json" + backend_name = "fake_yorktown_v2" class FakeYorktown(fake_qasm_backend.FakeQasmBackend): diff --git a/qiskit/test/mock/fake_backend.py b/qiskit/test/mock/fake_backend.py index b0e00ab7809c..c31430a5edf0 100644 --- a/qiskit/test/mock/fake_backend.py +++ b/qiskit/test/mock/fake_backend.py @@ -18,15 +18,29 @@ import uuid import warnings +import json +import os + +from typing import List, Union from qiskit import circuit from qiskit.providers.models import BackendProperties -from qiskit.providers import BackendV1, BaseBackend +from qiskit.providers import BackendV2, BackendV1, BaseBackend, QubitProperties from qiskit import pulse from qiskit.exceptions import QiskitError from qiskit.test.mock import fake_job +from qiskit.test.mock.utils.json_decoder import ( + decode_backend_configuration, + decode_backend_properties, + decode_pulse_defaults, +) +from qiskit.test.mock.utils.backend_converter import ( + convert_to_target, + qubit_props_from_props, +) from qiskit.utils import optionals as _optionals from qiskit.providers import basicaer +from qiskit.transpiler import Target class _Credentials: @@ -38,6 +52,298 @@ def __init__(self, token="123456", url="https://"): self.project = "project" +class FakeBackendV2(BackendV2): + """A fake backend class for testing and noisy simulation using real backend + snapshots. + + The class inherits :class:`~qiskit.providers.BackendV2` class. This version + differs from earlier :class:`~qiskit.test.mock.FakeBackend` (V1) class in a + few aspects. Firstly, configuration attribute no longer exsists. Instead, + attributes exposing equivalent required immutable properties of the backend + device are added. For example ``fake_backend.configuration().n_qubits`` is + accessible from ``fake_backend.num_qubits`` now. Secondly, this version + removes extra abstractions :class:`~qiskit.test.mock.FakeQasmBackend` and + :class:`~qiskit.test.mock.FakePulseBackend` that were present in V1. + """ + + # directory and file names for real backend snapshots. + dirname = None + conf_filename = None + props_filename = None + defs_filename = None + backend_name = None + + def __init__(self): + """FakeBackendV2 initializer.""" + self._conf_dict = self._get_conf_dict_from_json() + self._props_dict = self._set_props_dict_from_json() + self._defs_dict = self._set_defs_dict_from_json() + super().__init__( + provider=None, + name=self._conf_dict.get("backend_name"), + description=self._conf_dict.get("description"), + online_date=self._conf_dict.get("online_date"), + backend_version=self._conf_dict.get("backend_version"), + ) + self._target = convert_to_target( + conf_dict=self._conf_dict, + props_dict=self._props_dict, + defs_dict=self._defs_dict, + ) + self._qubit_properties = qubit_props_from_props(self._props_dict) + + def _get_conf_dict_from_json(self) -> dict: + if not self.conf_filename: + return None + conf_dict = self._load_json(self.conf_filename) + decode_backend_configuration(conf_dict) + conf_dict["backend_name"] = self.backend_name + return conf_dict + + def _set_props_dict_from_json(self) -> dict: + if not self.props_filename: + return None + props_dict = self._load_json(self.props_filename) + decode_backend_properties(props_dict) + return props_dict + + def _set_defs_dict_from_json(self) -> dict: + if not self.defs_filename: + return None + defs_dict = self._load_json(self.defs_filename) + decode_pulse_defaults(defs_dict) + return defs_dict + + def _load_json(self, filename: str) -> dict: + with open(os.path.join(self.dirname, filename)) as f_json: + the_json = json.load(f_json) + return the_json + + @property + def target(self) -> Target: + """A :class:`qiskit.transpiler.Target` object for the backend. + + :rtype: Target + """ + return self._target + + @property + def max_circuits(self): + return None + + @classmethod + def _default_options(cls): + """Return the default options + + This method will return a :class:`qiskit.providers.Options` + subclass object that will be used for the default options. These + should be the default parameters to use for the options of the + backend. + + Returns: + qiskit.providers.Options: A options object with + default values set + """ + if _optionals.HAS_AER: + from qiskit.providers import aer + + return aer.QasmSimulator._default_options() + else: + return basicaer.QasmSimulatorPy._default_options() + + @property + def dtm(self) -> float: + """Return the system time resolution of output signals + + Returns: + dtm: The output signal timestep in seconds. + """ + return self._conf_dict.get("dtm") + + @property + def meas_map(self) -> List[List[int]]: + """Return the grouping of measurements which are multiplexed + This is required to be implemented if the backend supports Pulse + scheduling. + + Returns: + meas_map: The grouping of measurements which are multiplexed + """ + return self._conf_dict.get("meas_map") + + def qubit_properties( + self, qubit: Union[int, List[int]] + ) -> Union[QubitProperties, List[QubitProperties]]: + """Return QubitProperties for a given qubit. + Args: + qubit: The qubit to get the + :class:`~qiskit.provider.QubitProperties` object for. This can + be a single integer for 1 qubit or a list of qubits and a list + of :class:`~qiskit.provider.QubitProperties` objects will be + returned in the same order + Returns: + qubit_properties: The :class:`~qiskit.provider.QubitProperties` + object for the specified qubit. If a list of qubits is provided a + list will be returned. If properties are missing for a qubit this + can be ``None``. + """ + if isinstance(qubit, int): # type: ignore[unreachable] + return self._qubit_properties.get(qubit) + if isinstance(qubit, List): + return [self._qubit_properties.get(q) for q in qubit] + return None + + def run(self, run_input, **options): + """Run on the fake backend using a simulator. + + This method runs circuit jobs (an individual or a list of QuantumCircuit + ) and pulse jobs (an individual or a list of Schedule or ScheduleBlock) + using BasicAer or Aer simulator and returns a + :class:`~qiskit.providers.Job` object. + + If qiskit-aer is installed, jobs will be run using AerSimulator with + noise model of the fake backend. Otherwise, jobs will be run using + BasicAer simulator without noise. + + Currently noisy simulation of a pulse job is not supported yet in + FakeBackendV2. + + Args: + run_input (QuantumCircuit or Schedule or ScheduleBlock or list): An + individual or a list of + :class:`~qiskit.circuits.QuantumCircuit, + :class:`~qiskit.pulse.ScheduleBlock`, or + :class:`~qiskit.pulse.Schedule` objects to run on the backend. + options: Any kwarg options to pass to the backend for running the + config. If a key is also present in the options + attribute/object then the expectation is that the value + specified will be used instead of what's set in the options + object. + Returns: + Job: The job object for the run + Raises: + QiskitError: If a pulse job is supplied and qiskit-aer is not + installed. + """ + circuits = run_input + pulse_job = None + if isinstance(circuits, (pulse.Schedule, pulse.ScheduleBlock)): + pulse_job = True + elif isinstance(circuits, circuit.QuantumCircuit): + pulse_job = False + elif isinstance(circuits, list): + if circuits: + if all(isinstance(x, (pulse.Schedule, pulse.ScheduleBlock)) for x in circuits): + pulse_job = True + elif all(isinstance(x, circuit.QuantumCircuit) for x in circuits): + pulse_job = False + if pulse_job is None: # submitted job is invalid + raise QiskitError( + "Invalid input object %s, must be either a " + "QuantumCircuit, Schedule, or a list of either" % circuits + ) + if pulse_job: # pulse job + raise QiskitError("Pulse simulation is currently not supported for V2 backends.") + # circuit job + if _optionals.HAS_AER: + from qiskit.providers import aer + + sim = aer.Aer.get_backend("qasm_simulator") + sim._options = self._options + if self._props_dict: + noise_model = self._get_noise_model_from_backend_v2() + job = sim.run(circuits, noise_model=noise_model, **options) + else: # simulate without noise + job = sim.run(circuits, **options) + else: + warnings.warn("Aer not found using BasicAer and no noise", RuntimeWarning) + sim = basicaer.BasicAer.get_backend("qasm_simulator") + job = sim.run(circuits, **options) + return job + + def _get_noise_model_from_backend_v2( + self, + gate_error=True, + readout_error=True, + thermal_relaxation=True, + temperature=0, + gate_lengths=None, + gate_length_units="ns", + standard_gates=None, + ): + """Build noise model from BackendV2. + + This is a temporary fix until qiskit-aer supports building noise model + from a BackendV2 object. + """ + + from qiskit.circuit import Delay + from qiskit.providers.exceptions import BackendPropertyError + from qiskit.providers.aer.noise import NoiseModel + from qiskit.providers.aer.noise.device.models import ( + _excited_population, + basic_device_gate_errors, + basic_device_readout_errors, + ) + from qiskit.providers.aer.noise.passes import RelaxationNoisePass + + properties = BackendProperties.from_dict(self._props_dict) + basis_gates = self.operation_names + num_qubits = self.num_qubits + dt = self.dt + + noise_model = NoiseModel(basis_gates=basis_gates) + + # Add single-qubit readout errors + if readout_error: + for qubits, error in basic_device_readout_errors(properties): + noise_model.add_readout_error(error, qubits) + + # Add gate errors + with warnings.catch_warnings(): + warnings.filterwarnings( + "ignore", + category=DeprecationWarning, + module="qiskit.providers.aer.noise.device.models", + ) + gate_errors = basic_device_gate_errors( + properties, + gate_error=gate_error, + thermal_relaxation=thermal_relaxation, + gate_lengths=gate_lengths, + gate_length_units=gate_length_units, + temperature=temperature, + standard_gates=standard_gates, + ) + for name, qubits, error in gate_errors: + noise_model.add_quantum_error(error, name, qubits) + + if thermal_relaxation: + # Add delay errors via RelaxationNiose pass + try: + excited_state_populations = [ + _excited_population(freq=properties.frequency(q), temperature=temperature) + for q in range(num_qubits) + ] + except BackendPropertyError: + excited_state_populations = None + try: + delay_pass = RelaxationNoisePass( + t1s=[properties.t1(q) for q in range(num_qubits)], + t2s=[properties.t2(q) for q in range(num_qubits)], + dt=dt, + op_types=Delay, + excited_state_populations=excited_state_populations, + ) + noise_model._custom_noise_passes.append(delay_pass) + except BackendPropertyError: + # Device does not have the required T1 or T2 information + # in its properties + pass + + return noise_model + + class FakeBackend(BackendV1): """This is a dummy backend just for testing purposes.""" diff --git a/qiskit/test/mock/fake_provider.py b/qiskit/test/mock/fake_provider.py index 2f2dde4b6c91..018425faa6c3 100644 --- a/qiskit/test/mock/fake_provider.py +++ b/qiskit/test/mock/fake_provider.py @@ -26,6 +26,114 @@ from .fake_openpulse_3q import FakeOpenPulse3Q +class FakeProviderFactory: + """Fake provider factory class.""" + + def __init__(self): + self.fake_provider = FakeProvider() + + def load_account(self): + """Fake load_account method to mirror the IBMQ provider.""" + pass + + def enable_account(self, *args, **kwargs): + """Fake enable_account method to mirror the IBMQ provider factory.""" + pass + + def disable_account(self): + """Fake disable_account method to mirror the IBMQ provider factory.""" + pass + + def save_account(self, *args, **kwargs): + """Fake save_account method to mirror the IBMQ provider factory.""" + pass + + @staticmethod + def delete_account(): + """Fake delete_account method to mirror the IBMQ provider factory.""" + pass + + def update_account(self, force=False): + """Fake update_account method to mirror the IBMQ provider factory.""" + pass + + def providers(self): + """Fake providers method to mirror the IBMQ provider.""" + return [self.fake_provider] + + def get_provider(self, hub=None, group=None, project=None): + """Fake get_provider method to mirror the IBMQ provider.""" + return self.fake_provider + + +class FakeProviderForBackendV2(ProviderV1): + """Dummy provider just for testing purposes. + + Only filtering backends by name is implemented. + This class contains fake V2 backends + """ + + def get_backend(self, name=None, **kwargs): + backend = self._backends[0] + if name: + filtered_backends = [backend for backend in self._backends if backend.name() == name] + if not filtered_backends: + raise QiskitBackendNotFoundError() + + backend = filtered_backends[0] + + return backend + + def backends(self, name=None, **kwargs): + return self._backends + + def __init__(self): + self._backends = [ + FakeAlmadenV2(), + FakeArmonkV2(), + FakeAthensV2(), + FakeBelemV2(), + FakeBoeblingenV2(), + FakeBogotaV2(), + FakeBrooklynV2(), + FakeBurlingtonV2(), + FakeCairoV2(), + FakeCambridgeV2(), + FakeCasablancaV2(), + FakeEssexV2(), + FakeGuadalupeV2(), + FakeHanoiV2(), + FakeJakartaV2(), + FakeJohannesburgV2(), + FakeKolkataV2(), + FakeLagosV2(), + FakeLimaV2(), + FakeLondonV2(), + FakeManhattanV2(), + FakeManilaV2(), + FakeMelbourneV2(), + FakeMontrealV2(), + FakeMumbaiV2(), + FakeNairobiV2(), + FakeOurenseV2(), + FakeParisV2(), + FakePoughkeepsieV2(), + FakeQuitoV2(), + FakeRochesterV2(), + FakeRomeV2(), + FakeSantiagoV2(), + FakeSingaporeV2(), + FakeSydneyV2(), + FakeTorontoV2(), + FakeValenciaV2(), + FakeVigoV2(), + FakeWashingtonV2(), + FakeYorktownV2(), + ] + + super().__init__() + + class FakeProvider(ProviderV1): """Dummy provider just for testing purposes. @@ -100,46 +208,6 @@ def __init__(self): super().__init__() -class FakeProviderFactory: - """Fake provider factory class.""" - - def __init__(self): - self.fake_provider = FakeProvider() - - def load_account(self): - """Fake load_account method to mirror the IBMQ provider.""" - pass - - def enable_account(self, *args, **kwargs): - """Fake enable_account method to mirror the IBMQ provider factory.""" - pass - - def disable_account(self): - """Fake disable_account method to mirror the IBMQ provider factory.""" - pass - - def save_account(self, *args, **kwargs): - """Fake save_account method to mirror the IBMQ provider factory.""" - pass - - @staticmethod - def delete_account(): - """Fake delete_account method to mirror the IBMQ provider factory.""" - pass - - def update_account(self, force=False): - """Fake update_account method to mirror the IBMQ provider factory.""" - pass - - def providers(self): - """Fake providers method to mirror the IBMQ provider.""" - return [self.fake_provider] - - def get_provider(self, hub=None, group=None, project=None): - """Fake get_provider method to mirror the IBMQ provider.""" - return self.fake_provider - - class FakeLegacyProvider(BaseProvider): """Dummy provider just for testing purposes. diff --git a/qiskit/test/mock/utils/__init__.py b/qiskit/test/mock/utils/__init__.py index 26a740172f76..8df029f1a537 100644 --- a/qiskit/test/mock/utils/__init__.py +++ b/qiskit/test/mock/utils/__init__.py @@ -13,5 +13,3 @@ """ Utils for test backends. """ - -from .configurable_backend import ConfigurableFakeBackend diff --git a/qiskit/test/mock/utils/backend_converter.py b/qiskit/test/mock/utils/backend_converter.py new file mode 100644 index 000000000000..db5cfb636e46 --- /dev/null +++ b/qiskit/test/mock/utils/backend_converter.py @@ -0,0 +1,143 @@ +# This code is part of Qiskit. +# +# (C) Copyright IBM 2022. +# +# 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. + +""" +Utilities for constructing Target object from configuration, properties and +pulse defaults json files +""" + +from qiskit.transpiler.target import Target, InstructionProperties +from qiskit.providers.backend import QubitProperties +from qiskit.utils.units import apply_prefix +from qiskit.circuit.library.standard_gates import IGate, SXGate, XGate, CXGate, RZGate +from qiskit.circuit.parameter import Parameter +from qiskit.circuit.gate import Gate +from qiskit.circuit.measure import Measure +from qiskit.circuit.reset import Reset +from qiskit.providers.models.pulsedefaults import PulseDefaults + + +def convert_to_target(conf_dict: dict, props_dict: dict = None, defs_dict: dict = None) -> Target: + """Uses configuration, properties and pulse defaults dicts + to construct and return Target class. + """ + name_mapping = { + "id": IGate(), + "sx": SXGate(), + "x": XGate(), + "cx": CXGate(), + "rz": RZGate(Parameter("λ")), + "reset": Reset(), + } + custom_gates = {} + target = Target() + # Parse from properties if it exsits + if props_dict is not None: + # Parse instructions + gates = {} + for gate in props_dict["gates"]: + name = gate["gate"] + if name in name_mapping: + if name not in gates: + gates[name] = {} + elif name not in custom_gates: + custom_gate = Gate(name, len(gate["qubits"]), []) + custom_gates[name] = custom_gate + gates[name] = {} + + qubits = tuple(gate["qubits"]) + gate_props = {} + for param in gate["parameters"]: + if param["name"] == "gate_error": + gate_props["error"] = param["value"] + if param["name"] == "gate_length": + gate_props["duration"] = apply_prefix(param["value"], param["unit"]) + gates[name][qubits] = InstructionProperties(**gate_props) + for gate, props in gates.items(): + if gate in name_mapping: + inst = name_mapping.get(gate) + else: + inst = custom_gates[gate] + target.add_instruction(inst, props) + # Create measurement instructions: + measure_props = {} + count = 0 + for qubit in props_dict["qubits"]: + qubit_prop = {} + for prop in qubit: + if prop["name"] == "readout_length": + qubit_prop["duration"] = apply_prefix(prop["value"], prop["unit"]) + if prop["name"] == "readout_error": + qubit_prop["error"] = prop["value"] + measure_props[(count,)] = InstructionProperties(**qubit_prop) + count += 1 + target.add_instruction(Measure(), measure_props) + # Parse from configuration because properties doesn't exist + else: + for gate in conf_dict["gates"]: + name = gate["name"] + gate_props = {tuple(x): None for x in gate["coupling_map"]} + if name in name_mapping: + target.add_instruction(name_mapping[name], gate_props) + else: + custom_gate = Gate(name, len(gate["coupling_map"][0]), []) + target.add_instruction(custom_gate, gate_props) + measure_props = {(n,): None for n in range(conf_dict["n_qubits"])} + target.add_instruction(Measure(), measure_props) + # parse global configuration properties + dt = conf_dict.get("dt") + if dt: + target.dt = dt + if "timing_constraints" in conf_dict: + target.granularity = conf_dict["timing_constraints"].get("granularity") + target.min_length = conf_dict["timing_constraints"].get("min_length") + target.pulse_alignment = conf_dict["timing_constraints"].get("pulse_alignment") + target.aquire_alignment = conf_dict["timing_constraints"].get("acquire_alignment") + # If pulse defaults exists use that as the source of truth + if defs_dict is not None: + # TODO remove the usage of PulseDefaults as it will be deprecated in the future + pulse_defs = PulseDefaults.from_dict(defs_dict) + inst_map = pulse_defs.instruction_schedule_map + for inst in inst_map.instructions: + for qarg in inst_map.qubits_with_instruction(inst): + sched = inst_map.get(inst, qarg) + if inst in target: + try: + qarg = tuple(qarg) + except TypeError: + qarg = (qarg,) + if inst == "measure": + for qubit in qarg: + target[inst][(qubit,)].calibration = sched + else: + target[inst][qarg].calibration = sched + return target + + +def qubit_props_from_props(properties: dict) -> dict: + """Returns a dictionary of `qiskit.providers.backend.QubitProperties` using + a backend properties dictionary created by loading props.json payload. + """ + count = 0 + qubit_props_dict = {} + for qubit in properties["qubits"]: + qubit_properties = {} + for prop_dict in qubit: + if prop_dict["name"] == "T1": + qubit_properties["t1"] = apply_prefix(prop_dict["value"], prop_dict["unit"]) + elif prop_dict["name"] == "T2": + qubit_properties["t2"] = apply_prefix(prop_dict["value"], prop_dict["unit"]) + elif prop_dict["name"] == "frequency": + qubit_properties["frequency"] = apply_prefix(prop_dict["value"], prop_dict["unit"]) + qubit_props_dict[count] = QubitProperties(**qubit_properties) + count += 1 + return qubit_props_dict diff --git a/releasenotes/notes/add-v2-mocked-backend-4ca2e4cfdf077c60.yaml b/releasenotes/notes/add-v2-mocked-backend-4ca2e4cfdf077c60.yaml new file mode 100644 index 000000000000..4febb234d67e --- /dev/null +++ b/releasenotes/notes/add-v2-mocked-backend-4ca2e4cfdf077c60.yaml @@ -0,0 +1,15 @@ +--- +features: + - | + Added :class:`~qiskit.test.mock.fake_backend.FakeBackendV2` that builds on + top of the new :class:`~qiskit.providers.backend.BackendV2` interface and + its associated :class:`~qiskit.transpiler.Target` using IBM Quantum + System snapshots json files (configuration, properties and pulse defaults). + + Added V2 versions of existing fake backends except for three old backends + (`Rueschlikon`, `Tenerfie` and `Tokyo`) that do not have snapshots files + available. + + These V2 fake backends will enable testing and development of new features + introduced by :class:`~qiskit.providers.backend.BackendV2` and + :class:`~qiskit.transpiler.Target` such as improving the transpiler. diff --git a/test/python/mock/test_configurable_backend.py b/test/python/mock/test_configurable_backend.py index 3e7070755776..0e47b9893322 100644 --- a/test/python/mock/test_configurable_backend.py +++ b/test/python/mock/test_configurable_backend.py @@ -12,7 +12,7 @@ """Test of configurable backend generation.""" from qiskit.test import QiskitTestCase -from qiskit.test.mock.utils import ConfigurableFakeBackend +from qiskit.test.mock.utils.configurable_backend import ConfigurableFakeBackend class TestConfigurableFakeBackend(QiskitTestCase): diff --git a/test/python/mock/test_fake_backends.py b/test/python/mock/test_fake_backends.py index 4dc1633571e4..79bd4405916b 100644 --- a/test/python/mock/test_fake_backends.py +++ b/test/python/mock/test_fake_backends.py @@ -18,7 +18,7 @@ from qiskit.pulse import Schedule from qiskit.qobj import PulseQobj from qiskit.test import QiskitTestCase -from qiskit.test.mock.utils import ConfigurableFakeBackend +from qiskit.test.mock.utils.configurable_backend import ConfigurableFakeBackend from qiskit.test.mock import FakeAthens from qiskit.utils import optionals diff --git a/test/python/providers/test_fake_backends.py b/test/python/providers/test_fake_backends.py index 3734063e7277..4e11de426d04 100644 --- a/test/python/providers/test_fake_backends.py +++ b/test/python/providers/test_fake_backends.py @@ -24,10 +24,10 @@ from qiskit.exceptions import QiskitError from qiskit.execute_function import execute from qiskit.test.base import QiskitTestCase -from qiskit.test.mock import FakeProvider, FakeLegacyProvider +from qiskit.test.mock import FakeProviderForBackendV2, FakeProvider, FakeLegacyProvider from qiskit.utils import optionals - +FAKE_PROVIDER_FOR_BACKEND_V2 = FakeProviderForBackendV2() FAKE_PROVIDER = FakeProvider() FAKE_LEGACY_PROVIDER = FakeLegacyProvider() @@ -46,6 +46,25 @@ def setUpClass(cls): cls.circuit.x(1) cls.circuit.measure_all() + @combine( + backend=[be for be in FAKE_PROVIDER_FOR_BACKEND_V2.backends() if be.num_qubits > 1], + optimization_level=[0, 1, 2, 3], + ) + def test_circuit_on_fake_backend_v2(self, backend, optimization_level): + if not optionals.HAS_AER and backend.num_qubits > 20: + self.skipTest("Unable to run fake_backend %s without qiskit-aer" % backend.backend_name) + job = execute( + self.circuit, + backend, + optimization_level=optimization_level, + seed_simulator=42, + seed_transpiler=42, + ) + result = job.result() + counts = result.get_counts() + max_count = max(counts.items(), key=operator.itemgetter(1))[0] + self.assertEqual(max_count, "11") + @combine( backend=[be for be in FAKE_PROVIDER.backends() if be.configuration().num_qubits > 1], optimization_level=[0, 1, 2, 3], diff --git a/test/python/pulse/test_builder.py b/test/python/pulse/test_builder.py index 712289fb0d8d..f2a93e45b559 100644 --- a/test/python/pulse/test_builder.py +++ b/test/python/pulse/test_builder.py @@ -22,7 +22,9 @@ from qiskit.pulse.transforms import target_qobj_transform from qiskit.test import QiskitTestCase from qiskit.test.mock import FakeOpenPulse2Q -from qiskit.test.mock.utils import ConfigurableFakeBackend as ConfigurableBackend +from qiskit.test.mock.utils.configurable_backend import ( + ConfigurableFakeBackend as ConfigurableBackend, +) from qiskit.pulse import library, instructions