Skip to content

Commit 13c6890

Browse files
Merge pull request #97 from ColibrITD-SAS/feat-qiskit-device-noisemodel
IBM Simulated device + Shots/Precision fix + IBM Noisy Expectation Value + Upgrade packages
2 parents 3c58d5c + 2476f36 commit 13c6890

15 files changed

+384
-150
lines changed

docs/execution.rst

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ Devices
2323

2424
.. automodule:: mpqp.execution.devices
2525

26+
.. _SimulatedDevices:
27+
28+
Simulated Devices
29+
-----------------
30+
31+
.. automodule:: mpqp.execution.simulated_devices
32+
2633
Running a circuit
2734
-----------------
2835

docs/noise.rst

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ We strongly encourage the user to have a look at the
1313
details about the manipulation, usage, and simulation of noise models are
1414
presented.
1515

16+
For more details on how to use noise models taken from real hardware, you can
17+
look at :ref:`SimulatedDevices`.
18+
1619
.. code-block:: python
1720
:class: import
1821

docs/resources/job-device_compat.csv

+6-12
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,22 @@ IBM ,AER_SIMULATOR ,✓ ,✓ ,✓
33
IBM ,AER_SIMULATOR_STATEVECTOR ,✓ ,✓ ,✓ ,✓
44
IBM ,AER_SIMULATOR_DENSITY_MATRIX ,✓ , ,✓ ,✓
55
IBM ,AER_SIMULATOR_STABILIZER ,✓ , ,✓ ,✓
6-
IBM ,AER_SIMULATOR_EXTENDED_STABILIZER ,✓ ,✓ , ,✓
6+
IBM ,AER_SIMULATOR_EXTENDED_STABILIZER ,✓ ,✓ , ,
77
IBM ,AER_SIMULATOR_MATRIX_PRODUCT_STATE,✓ ,✓ ,✓ ,✓
88
IBM ,IBM_BRISBANE ,✓ , ,✓ ,
9-
IBM ,IBM_OSAKA ,✓ , ,✓ ,
10-
IBM ,IBM_KYOTO ,✓ , ,✓ ,
119
IBM ,IBM_SHERBROOKE ,✓ , ,✓ ,
1210
IBM ,IBM_KYIV ,✓ , ,✓ ,
1311
IBM ,IBM_NAZCA ,✓ , ,✓ ,
14-
IBM ,IBM_CUSCO ,✓ , ,✓ ,
15-
IBM ,IBM_ITHACA ,✓ , ,✓ ,
1612
IBM ,IBM_TORINO ,✓ , ,✓ ,
1713
IBM ,IBM_QUEBEC ,✓ , ,✓ ,
1814
IBM ,IBM_KAWASAKI ,✓ , ,✓ ,
1915
IBM ,IBM_CLEVELAND ,✓ , ,✓ ,
20-
IBM ,IBM_CAIRO ,✓ , ,✓ ,
21-
IBM ,IBM_HANOI ,✓ , ,✓ ,
22-
IBM ,IBM_ALGIERS ,✓ , ,✓ ,
23-
IBM ,IBM_KOLKATA ,✓ , ,✓ ,
24-
IBM ,IBM_MUMBAI ,✓ , ,✓ ,
2516
IBM ,IBM_PEEKSKILL ,✓ , ,✓ ,
26-
IBM ,IBM_RANDOM_SMALL_DEVICE ,✓ , ,✓ ,
27-
IBM ,IBM_SMALL_DEVICES_LEAST_BUSY ,✓ , ,✓ ,
17+
IBM ,IBM_RENSSELAER ,✓ , ,✓ ,
18+
IBM ,IBM_BRUSSELS ,✓ , ,✓ ,
19+
IBM ,IBM_STRASBOURG ,✓ , ,✓ ,
20+
IBM ,IBM_FEZ ,✓ , ,✓ ,
21+
IBM ,IBM_LEAST_BUSY ,✓ , ,✓ ,
2822
Atos ,MYQLM_PYLINALG ,✓ ,✓ ,✓ ,✓
2923
Atos ,MYQLM_CLINALG ,✓ ,✓ ,✓ ,✓
3024
Atos ,QLM_LINALG ,✓ ,✓ ,✓ ,✓

mpqp/all.py

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
IBMDevice,
2525
AZUREDevice,
2626
)
27+
from .execution.simulated_devices import IBMSimulatedDevice
2728
from .execution.remote_handler import get_all_job_ids
2829
from .execution.vqa import Optimizer, minimize
2930
from .gates import (
@@ -69,6 +70,8 @@
6970
from .measures import Z as Zop
7071
from .noise import AmplitudeDamping, BitFlip, Depolarizing, PhaseDamping
7172
from .qasm import open_qasm_file_conversion_2_to_3, open_qasm_hard_includes
73+
from .tools.circuit import random_circuit
74+
from .tools.display import pprint
7275

7376
theta, k = symbols("θ k")
7477
obs = Observable(np.array([[0, 1], [1, 0]]))

mpqp/execution/connection/ibm_connection.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
from getpass import getpass
22
from typing import TYPE_CHECKING
33

4+
from mpqp.execution.connection.env_manager import get_env_variable, save_env_variable
5+
from mpqp.execution.devices import IBMDevice
6+
from mpqp.tools.errors import IBMRemoteExecutionError
47
from termcolor import colored
58
from typeguard import typechecked
69

710
if TYPE_CHECKING:
811
from qiskit.providers.backend import BackendV2
912
from qiskit_ibm_runtime import QiskitRuntimeService
1013

11-
from mpqp.execution.connection.env_manager import get_env_variable, save_env_variable
12-
from mpqp.execution.devices import IBMDevice
13-
from mpqp.tools.errors import IBMRemoteExecutionError
1414

1515
Runtime_Service = None
1616

@@ -158,7 +158,7 @@ def get_backend(device: IBMDevice) -> "BackendV2":
158158
parameter.
159159
160160
Args:
161-
device: The IBMDevice to get from IBMQ provider.
161+
device: The IBMDevice to get from the qiskit Runtime service.
162162
163163
Returns:
164164
The requested backend.
@@ -175,15 +175,15 @@ def get_backend(device: IBMDevice) -> "BackendV2":
175175
176176
"""
177177
if not device.is_remote():
178-
raise ValueError("Expected a remote IBMQ device but got a local simulator.")
178+
raise ValueError("Expected a remote IBM device but got a local simulator.")
179179
from qiskit.providers.exceptions import QiskitBackendNotFoundError
180180

181181
service = get_QiskitRuntimeService()
182182

183183
try:
184184
if device == IBMDevice.IBM_LEAST_BUSY:
185185
return service.least_busy(operational=True)
186-
return service.get_backend(device.value)
186+
return service.backend(device.value)
187187
except QiskitBackendNotFoundError as err:
188188
raise IBMRemoteExecutionError(
189189
f"Requested device {device} not found. Verify if your instances "
@@ -209,6 +209,5 @@ def get_all_job_ids() -> list[str]:
209209
210210
"""
211211
if get_env_variable("IBM_CONFIGURED") == "True":
212-
return [job.job_id() for job in get_QiskitRuntimeService().jobs()]
213-
212+
return [job.job_id() for job in get_QiskitRuntimeService().jobs(limit=None)]
214213
return []

mpqp/execution/devices.py

+23-17
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,29 @@ class IBMDevice(AvailableDevice):
104104
AER_SIMULATOR_EXTENDED_STABILIZER = "extended_stabilizer"
105105
AER_SIMULATOR_MATRIX_PRODUCT_STATE = "matrix_product_state"
106106

107-
IBM_BRISBANE = "ibm_brisbane"
108-
IBM_OSAKA = "ibm_osaka"
109-
IBM_KYOTO = "ibm_kyoto"
110-
111107
IBM_SHERBROOKE = "ibm_sherbrooke"
108+
IBM_BRISBANE = "ibm_brisbane"
112109
IBM_KYIV = "ibm_kyiv"
113-
IBM_NAZCA = "ibm_nazca"
114-
IBM_CUSCO = "ibm_cusco"
115-
IBM_ITHACA = "ibm_ithaca"
116-
IBM_TORINO = "ibm_torino"
117-
IBM_QUEBEC = "ibm_quebec"
110+
111+
IBM_FEZ = "ibm_fez"
112+
IBM_RENSSELAER = "ibm_rensselaer"
113+
IBM_BRUSSELS = "ibm_brussels"
118114
IBM_KAWASAKI = "ibm_kawasaki"
115+
IBM_QUEBEC = "ibm_quebec"
116+
IBM_TORINO = "ibm_torino"
117+
IBM_NAZCA = "ibm_nazca"
118+
IBM_STRASBOURG = "ibm_strasbourg"
119+
120+
# RETIRED - IBM_OSAKA = "ibm_osaka"
121+
# RETIRED - IBM_KYOTO = "ibm_kyoto"
122+
# RETIRED - IBM_CUSCO = "ibm_cusco"
123+
# RETIRED - IBM_ITHACA = "ibm_ithaca"
119124
IBM_CLEVELAND = "ibm_cleveland"
120-
IBM_CAIRO = "ibm_cairo"
121-
IBM_HANOI = "ibm_hanoi"
122-
IBM_ALGIERS = "ibm_algiers"
123-
IBM_KOLKATA = "ibm_kolkata"
124-
IBM_MUMBAI = "ibm_mumbai"
125+
# RETIRED - IBM_CAIRO = "ibm_cairo"
126+
# RETIRED - IBM_HANOI = "ibm_hanoi"
127+
# RETIRED - IBM_ALGIERS = "ibm_algiers"
128+
# RETIRED - IBM_KOLKATA = "ibm_kolkata"
129+
# RETIRED - IBM_MUMBAI = "ibm_mumbai"
125130
IBM_PEEKSKILL = "ibm_peekskill"
126131

127132
IBM_LEAST_BUSY = "ibm_least_busy"
@@ -131,7 +136,6 @@ def is_remote(self) -> bool:
131136

132137
def is_gate_based(self) -> bool:
133138
return True
134-
# return self != IBMDevice.PULSE_SIMULATOR
135139

136140
def has_reduced_gate_set(self) -> bool:
137141
return self in {
@@ -163,15 +167,17 @@ def supports_state_vector(self) -> bool:
163167
}
164168

165169
def supports_observable(self) -> bool:
166-
return True
170+
return self not in {
171+
IBMDevice.AER_SIMULATOR_EXTENDED_STABILIZER,
172+
}
167173

168174
def supports_observable_ideal(self) -> bool:
169175
return self in {
170176
IBMDevice.AER_SIMULATOR,
171177
IBMDevice.AER_SIMULATOR_STATEVECTOR,
172178
IBMDevice.AER_SIMULATOR_DENSITY_MATRIX,
173179
IBMDevice.AER_SIMULATOR_STABILIZER,
174-
IBMDevice.AER_SIMULATOR_EXTENDED_STABILIZER,
180+
# IBMDevice.AER_SIMULATOR_EXTENDED_STABILIZER,
175181
IBMDevice.AER_SIMULATOR_MATRIX_PRODUCT_STATE,
176182
}
177183

0 commit comments

Comments
 (0)