PennyLaneAI / pennylane-rigetti

This PennyLane plugin allows the Rigetti Forest QPUs, QVM, and wavefunction simulator to optimize quantum circuits.
https://docs.pennylane.ai/projects/rigetti
BSD 3-Clause "New" or "Revised" License
37 stars 28 forks source link

Pennylane Forest plugin #76

Open zohimchandani opened 3 years ago

zohimchandani commented 3 years ago

Wondering if the forest plugin is still supported? I have installed the pennylane-forest plugin and trying to run the following code:


dev = qml.device("forest.qvm", device="4q-qvm")

@qml.qnode(dev)
def qnn(data, theta):

    tree_tensor_network(data, theta)

    return qml.expval(qml.PauliZ(7))

but keep getting:


DeviceError: Device does not exist. Make sure the required plugin is installed.
---------------------------------------------------------------------------
DeviceError                               Traceback (most recent call last)
/var/folders/cx/22y072mx1gjcqtb64f6gq8_00000gq/T/ipykernel_1478/2809175344.py in <module>
      3 # dev = qml.device('forest.numpy_wavefunction', wires=num_wires, shots = 1000)
      4 
----> 5 dev = qml.device("forest.qvm", device="4q-qvm")
      6 
      7 @qml.qnode(dev)

~/Desktop/Rigetti /Code/qnns_pennylane_aca /qnns_pennylane/lib/python3.9/site-packages/pennylane/__init__.py in device(name, *args, **kwargs)
    259         return plugin_device_class(*args, **options)
    260 
--> 261     raise DeviceError("Device does not exist. Make sure the required plugin is installed.")
    262 
    263 

DeviceError: Device does not exist. Make sure the required plugin is installed.
zohimchandani commented 3 years ago

A little update on my previous issue:

import pennylane as qml
dev = qml.device('forest.qvm', device='Aspen-8')
dev.num_wires
ModuleNotFoundError: No module named 'pyquil.api._base_connection'
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-10-f39dd0975b54> in <module>
      1 import pennylane as qml
----> 2 dev = qml.device('forest.qvm', device='Aspen-8')
      3 dev.num_wires

/usr/local/lib/python3.9/site-packages/pennylane/__init__.py in device(name, *args, **kwargs)
    246 
    247         # loads the device class
--> 248         plugin_device_class = plugin_devices[name].load()
    249 
    250         if Version(version()) not in Spec(plugin_device_class.pennylane_requires):

/usr/local/lib/python3.9/site-packages/pkg_resources/__init__.py in load(self, require, *args, **kwargs)
   2448         if require:
   2449             self.require(*args, **kwargs)
-> 2450         return self.resolve()
   2451 
   2452     def resolve(self):

/usr/local/lib/python3.9/site-packages/pkg_resources/__init__.py in resolve(self)
   2454         Resolve the entry point from its module and attrs.
   2455         """
-> 2456         module = __import__(self.module_name, fromlist=['__name__'], level=0)
   2457         try:
   2458             return functools.reduce(getattr, self.attrs, module)

/usr/local/lib/python3.9/site-packages/pennylane_forest/__init__.py in <module>
      4 """
      5 from .ops import CPHASE, ISWAP, PSWAP
----> 6 from .qvm import QVMDevice
      7 from .wavefunction import WavefunctionDevice
      8 from .numpy_wavefunction import NumpyWavefunctionDevice

/usr/local/lib/python3.9/site-packages/pennylane_forest/qvm.py in <module>
     31 
     32 from ._version import __version__
---> 33 from .device import ForestDevice
     34 
     35 

/usr/local/lib/python3.9/site-packages/pennylane_forest/device.py in <module>
     37 
     38 from pyquil import Program
---> 39 from pyquil.api._base_connection import ForestConnection
     40 from pyquil.api._config import PyquilConfig
     41 

ModuleNotFoundError: No module named 'pyquil.api._base_connection'

If this is something to do with the qvm and quilc compilers running on a terminal in the background then I already do have those running.

(qnns_pl) zohim@Zohims-MBP qnns_pennylane_aca_2 % quilc --version
1.23.0 [e6c0939]
(qnns_pl) zohim@Zohims-MBP qnns_pennylane_aca_2 % qvm --version
1.17.1 [cf3f91f]
(qnns_pl) zohim@Zohims-MBP qnns_pennylane_aca_2 % python -c "import pyquil; print(pyquil.__version__)"
3.0.0
rmoyard commented 3 years ago

Hey @zohimchandani thank you for your feedback, we know that the Forest plugin is experiencing some problems lately. We are investigating those and will shortly come back to you!

antalszava commented 3 years ago

Hi @zohimchandani, it looks like this has to do with the latest version of PyQuil. Many breaking changes have been introduced in that version, e.g., 'pyquil.api._base_connection' has been deprecated.

The latest version of PyQuil with which PennyLane-Forest works as is seems to be 2.28.3. We're looking into incorporating the API changes (#78). Likely, this process will take time. Until then, would suggest downgrading PyQuil locally with pip install pyquil==2.28.2.

antalszava commented 3 years ago

With https://github.com/PennyLaneAI/pennylane-forest/pull/77 merged, will remove the Bug label here. The master branch depends on a PyQuil version that still works well with the plugin.