pennylane
pennylane copied to clipboard
[BUG] Declare incompatibility with pennylane-lightning versions
Expected behavior
When installing a specific version of pennylane and pennylane-lightning with pip I expect them to "just work".
Actual behavior
When I pip install pennylane v0.32 like this pip install pennylane==0.32 pennylane-lightning
, I end up with
Successfully installed pennylane-0.32.0 pennylane-lightning-0.33.1
which is expected since in setup.py
PL 0.32 declares that it needs:
"pennylane-lightning>=0.32",
and pennylane-lightning 0.33.1 also claims to be compatible with PL 0.32 in it's setup.py:
requirements = [
"pennylane>=0.32",
]
However, if I then try to use pennylane-lightning, I get:
>>> import pennylane as qml
>>> qml.device("lightning.qubit", wires=2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/[...]/pennylane/pennylane/__init__.py", line 336, in device
plugin_device_class = plugin_devices[name].load()
File "/home/[...]/lib/python3.10/site-packages/pkg_resources/__init__.py", line 2518, in load
return self.resolve()
File "/home/[...]/lib/python3.10/site-packages/pkg_resources/__init__.py", line 2524, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/home/[...]/lib/python3.10/site-packages/pennylane_lightning/lightning_qubit/__init__.py", line 17, in <module>
from .lightning_qubit import LightningQubit
File "/home/[...]/lib/python3.10/site-packages/pennylane_lightning/lightning_qubit/lightning_qubit.py", line 23, in <module>
from pennylane_lightning.core.lightning_base import (
File "/home/[...]/lib/python3.10/site-packages/pennylane_lightning/core/lightning_base.py", line 30, in <module>
from pennylane.devices import DefaultQubitLegacy
ImportError: cannot import name 'DefaultQubitLegacy' from 'pennylane.devices' (/home/[...]/pennylane/pennylane/devices/__init__.py)
Manually downgrading pip install -U pennylane-lightning==0.32
fixes the problem.
But this makes it hard to test my code in a CI pipeline with different PL versions. It would be awesome if an effort could be made to ensure that incompatibilities between pennylane and pennylane-lightning versions could always be declared correctly. Thanks!
Additional information
No response
Source code
No response
Tracebacks
No response
System information
Not needed in this case.
Existing GitHub issues
- [X] I have searched existing GitHub issues to make sure the issue does not already exist.
Thanks @cvjjm! This has always been a tricky one to manage during release, because we have pennylane
and pennylane-lightning
being co-dependent. We're discussing how to better manage this, but for now as you point out it's probably best to do
pip install pennylane==0.32 pennylane-lightning==0.32
That being said, we did a big performance fix in v0.33.1
, so if possible it'd be great for you to upgrade to v0.33
or v0.34
.
Wouldn't it be quire easy to declare in pennylane-lighthing 0.33 that it is no longer compatible with PL 0.32 by changing one line in it's setup.py as follows:
requirements = [
"pennylane>=0.33",
]
And, yes, I understand that it is always preferred to use the latest version, but testing our rather extensive code stack against a range of PL version has lead to the discovery of several noteworthy (performance) regressions and bugs, so I would definitely appreciate if all old versions could still be installed in a straight forward way.
Is pip install pennylane==${version} pennylane-lightning==${version%.*}
going to work for every minor version, i.e. for ${version}
in 0.29.1, 0.30.0, 0.31.0, 0.32.0, .... ?
Hey @cvjjm That should work. The bugfix release version number (Z.Y.X) should be fine for all minor release versions of pennylane (Z.Y). In this case, assuming you are giving the full pennylane version (Z.Y.X) string you can use pennylane-lightning~=${version}
and it should pull in the latest version at that release number.
For example, assuming you want a release of PennyLane in the interval 0.[21, 34].0, and the associated latest version of Lightning with each release, you can do the following:
#!/bin/bash
for min_ver in $(seq 21 34); do
python -m venv pyenv_${min_ver};
source ./pyenv_${min_ver}/bin/activate;
python -m pip install pennylane==0.${min_ver}.0 pennylane-lightning~=0.${min_ver}.0
deactivate
done
Feel free to let us know if you need any additional help here.
Thanks! This is useful.
I still consider it a bug that pennylane-lighthing 0.33 does not declare that is is incompatible with pennylane < 0.33.
Hey @cvjjm, I think you're right and we're thinking about how to make it better in the future 👍