-
Notifications
You must be signed in to change notification settings - Fork 11
Fix simulated devices #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
c5a9928
589313e
1c750a5
c09dfea
77e60e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,9 @@ | |
| from enum import Enum, auto | ||
|
|
||
| from mpqp.core.instruction.gates import Gate | ||
| from mpqp.core.instruction.gates.native_gates import * | ||
| from mpqp.environment.env_manager import get_env_variable | ||
| import warnings | ||
|
|
||
|
|
||
| class AvailableDevice(Enum): | ||
|
|
@@ -90,7 +92,13 @@ def supports_observable(self) -> bool: | |
| def supports_observable_ideal(self) -> bool: | ||
| pass | ||
|
|
||
| def incompatible_gate(self) -> set[type[Gate]]: | ||
| def compatible_gate(self, native_set: bool = False) -> set[type[Gate]]: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This means that each time we add a gate to MPQP (which is not that often I admit) we have to remember to update each time all the compatible gates ?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No because more often than not we're going to transpile the circuit so we won't have forbidden gates by themselves. |
||
| """Returns the set of gates supported by the devices. | ||
|
|
||
| Args: | ||
| native_set: If True returns the set of gates of the device without any transpilation. | ||
| (For example: optimization_level=0 on Qiskit or Verbatim box on Braket) | ||
| """ | ||
| return set() | ||
|
|
||
|
|
||
|
|
@@ -111,29 +119,23 @@ class IBMDevice(AvailableDevice): | |
| AER_SIMULATOR_EXTENDED_STABILIZER = "extended_stabilizer" | ||
| AER_SIMULATOR_MATRIX_PRODUCT_STATE = "matrix_product_state" | ||
|
|
||
| IBM_SHERBROOKE = "ibm_sherbrooke" | ||
| IBM_BRISBANE = "ibm_brisbane" | ||
| IBM_KYIV = "ibm_kyiv" | ||
|
|
||
| IBM_FEZ = "ibm_fez" | ||
| IBM_RENSSELAER = "ibm_rensselaer" | ||
| IBM_BRUSSELS = "ibm_brussels" | ||
| IBM_KAWASAKI = "ibm_kawasaki" | ||
| IBM_QUEBEC = "ibm_quebec" | ||
| IBM_TORINO = "ibm_torino" | ||
| IBM_NAZCA = "ibm_nazca" | ||
| IBM_STRASBOURG = "ibm_strasbourg" | ||
|
|
||
| # RETIRED - IBM_OSAKA = "ibm_osaka" | ||
| # RETIRED - IBM_KYOTO = "ibm_kyoto" | ||
| # RETIRED - IBM_CUSCO = "ibm_cusco" | ||
| # RETIRED - IBM_ITHACA = "ibm_ithaca" | ||
|
|
||
| # NightHawk chips | ||
| IBM_BOSTON = "ibm_boston" | ||
| IBM_KINGSTON = "ibm_kingston" | ||
| IBM_PITTSBURGH = "ibm_pittsburgh" | ||
| IBM_FEZ = "ibm_fez" | ||
| IBM_MARRAKESH = "ibm_marrakesh" | ||
| IBM_AACHEN = "IBM_AACHEN" | ||
|
|
||
| # Heron chips | ||
| IBM_MIAMI = "ibm_miami" | ||
| IBM_BERLIN = "ibm_berlin" | ||
|
|
||
| IBM_CLEVELAND = "ibm_cleveland" | ||
| # RETIRED - IBM_CAIRO = "ibm_cairo" | ||
| # RETIRED - IBM_HANOI = "ibm_hanoi" | ||
| # RETIRED - IBM_ALGIERS = "ibm_algiers" | ||
| # RETIRED - IBM_KOLKATA = "ibm_kolkata" | ||
| # RETIRED - IBM_MUMBAI = "ibm_mumbai" | ||
| IBM_PEEKSKILL = "ibm_peekskill" | ||
|
|
||
| IBM_LEAST_BUSY = "ibm_least_busy" | ||
|
|
@@ -184,17 +186,28 @@ def supports_observable_ideal(self) -> bool: | |
| IBMDevice.AER_SIMULATOR_STATEVECTOR, | ||
| IBMDevice.AER_SIMULATOR_DENSITY_MATRIX, | ||
| IBMDevice.AER_SIMULATOR_STABILIZER, | ||
| # IBMDevice.AER_SIMULATOR_EXTENDED_STABILIZER, | ||
| IBMDevice.AER_SIMULATOR_MATRIX_PRODUCT_STATE, | ||
| } | ||
|
|
||
| def incompatible_gate(self) -> set[type[Gate]]: | ||
| from mpqp.core.instruction.gates import TOF, CRk, P, Rk, Rx, Ry, Rz, T, U | ||
|
|
||
| def compatible_gate(self, native_set: bool = False) -> set[type[Gate]]: | ||
| if self == IBMDevice.AER_SIMULATOR_STABILIZER: | ||
| return {CRk, P, Rk, Rx, Ry, Rz, T, TOF, U} | ||
| warnings.warn( | ||
| UserWarning( | ||
| f"For {self} the gates Rx, Ry and Rz are allowed but only at angles 0, π, π/2 and 3*π/2" | ||
| ) | ||
| ) | ||
| return {Rx, Ry, Rz, X, Y, Z, H, CNOT, CZ, S, S_dagger, SWAP} | ||
| elif self == IBMDevice.AER_SIMULATOR_EXTENDED_STABILIZER: | ||
| return {Rx, Rz} | ||
| warnings.warn( | ||
| UserWarning( | ||
| f"For {self} the gates Rx, Ry and Rz are allowed but only at angles 0, π, π/2 and 3*π/2" | ||
| ) | ||
| ) | ||
| return {Rx, Ry, Rz, X, Y, Z, H, CNOT, CZ, S, S_dagger, SWAP} | ||
| elif self in IBM_CHIPS_HERON: | ||
| return {CZ, Id, Rx, Rz, X} # add Rzz | ||
| elif self in IBM_CHIPS_NIGHTHAWK: | ||
| return {CZ, Id, Rx, Rz, X} | ||
| else: | ||
| return set() | ||
|
|
||
|
|
@@ -512,3 +525,14 @@ def supports_observable(self) -> bool: | |
|
|
||
| def supports_observable_ideal(self) -> bool: | ||
| return False | ||
|
|
||
|
|
||
| IBM_CHIPS_HERON = [IBMDevice.IBM_MIAMI, IBMDevice.IBM_BERLIN] | ||
| IBM_CHIPS_NIGHTHAWK = [ | ||
| IBMDevice.IBM_BOSTON, | ||
| IBMDevice.IBM_KINGSTON, | ||
| IBMDevice.IBM_PITTSBURGH, | ||
| IBMDevice.IBM_FEZ, | ||
| IBMDevice.IBM_MARRAKESH, | ||
| IBMDevice.IBM_AACHEN, | ||
| ] | ||
|
Comment on lines
+530
to
+538
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A bit original to do it like this compared to the rest of devices?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could have a method but chips family like is more often done by IBM.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea was to avoid instantiating a list the first time we import the file, but here it is not that a big deal |
||
Uh oh!
There was an error while loading. Please reload this page.