microsoft.QuantumSimulator cannot import name 'Device' from 'pennylane'

Hi,

Plugin Installation:

pip install azure-quantum 
pip install pennylane-qsharp

Documentation reference:

Code:

import pennylane as qml

# Qiskit simulator is correct
# dev = qml.device('qiskit.aer', wires=2) # OK It's correct

# Microsoft simulator is KO
dev = qml.device('microsoft.QuantumSimulator', wires=2) # KO 
print(dev)

Error message:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[6], line 7
      1 import pennylane as qml
      3 # Qiskit simulator is correct
      4 # dev = qml.device('qiskit.aer', wires=2) # OK It's correct
      5 
      6 # Microsoft simulator is KO
----> 7 dev = qml.device('microsoft.QuantumSimulator', wires=2) # KO 
      8 print(dev)

File c:\Users\ernes\OneDrive\Documents\Formation\Logiciels\VScode\.pennylane_env\Lib\site-packages\pennylane\devices\device_constructor.py:243, in device(name, *args, **kwargs)
    240 options.update(kwargs)
    242 # loads the device class
--> 243 plugin_device_class = plugin_devices[name].load()
    245 def _safe_specifier_set(version_str):
    246     """Safely create a SpecifierSet from a version string."""

File ~\AppData\Local\Programs\Python\Python313\Lib\importlib\metadata\__init__.py:179, in EntryPoint.load(self)
    174 """Load the entry point from its definition. If only a module
    175 is indicated by the value, return that module. Otherwise,
    176 return the named object.
    177 """
    178 match = cast(Match, self.pattern.match(self.value))
--> 179 module = import_module(match.group('module'))
...
     46 open Microsoft.Quantum.Measurement;
   (...)     59 }}
     60 """

ImportError: cannot import name 'Device' from 'pennylane' (c:\Users\...\OneDrive\Documents\Formation\Logiciels\VScode\.pennylane_env\Lib\site-packages\pennylane\__init__.py)

Any help?

Hi @quantumel,

Unfortunately this plugin no longer works with the latest PennyLane versions. Are you able to use a native PennyLane simulator or a different plugin such as the PennyLane-Qiskit plugin or the PennyLane-Braket plugin? You can find the different PennyLane simulators, with a short description of when to use them, in our Performance page.

Thanks. I just tried different plugins. Anyway, it works on the Azure Quantum Simulator. So it’s fine.

Thanks for letting us know @quantumel !
Just to make sure I understand, are you still using PennyLane on the simulator? Or are you using Q# directly?