Pennylane-lightning installation and error/warning

Hello,

I tried to install and use lightning.qubit on a Linux cluster machine. I used this command to install pennylane-lightning:
pip install pennylane-lightning

When I run the following python code:

import os
os.environ[“OMP_NUM_THREADS”] = “2”
import pennylane as qml
dev = qml.device(“lightning.qubit”, wires=2)
print(‘the end’)

I encountered this warning:

/path_to_conda/.conda/envs/penny3/lib/python3.11/site-packages/pennylane_lightning/lightning_qubit.py:707: UserWarning: Pre-compiled binaries for lightning.qubit are not available. Falling back to using the Python-based default.qubit implementation. To manually compile from source, follow the instructions at https://pennylane-lightning.readthedocs.io/en/latest/installation.html.
warn(

I tried two qml versions (0.25.1 and 0.26.0 as detailed below); both had the same problem shown above. How can I fix the problem to use lightning.qubit instead of falling back to default.qubit? I assume the former can run faster than the latter on 20+ qubit circuits. Thanks!

BTW, I tried to use the following two ways described at the link given above to install pennylane_lightning but was not successful (use the 0.26.0 PennyLane shown below).

git clone https://github.com/PennyLaneAI/pennylane-lightning.git
cd pennylane-lightning
pip install -r requirements.txt
pip install -e .

cmake -S. -B build
cmake --build build


qml.about()

Name: PennyLane
Version: 0.25.1
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: :…
Author:
Author-email:
License: Apache License 2.0
Location: /path_to_conda/.conda/envs/penny3/lib/python3.11/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, retworkx, scipy, semantic-version, toml
Required-by: PennyLane-Lightning

Platform info: Linux-4.18.0-193.28.1.el8_2.x86_64-x86_64-with-glibc2.28
Python version: 3.11.0
Numpy version: 1.23.4
Scipy version: 1.9.3
Installed devices:

  • lightning.qubit (PennyLane-Lightning-0.25.1)
  • default.gaussian (PennyLane-0.25.1)
  • default.mixed (PennyLane-0.25.1)
  • default.qubit (PennyLane-0.25.1)
  • default.qubit.autograd (PennyLane-0.25.1)
  • default.qubit.jax (PennyLane-0.25.1)
  • default.qubit.tf (PennyLane-0.25.1)
  • default.qubit.torch (PennyLane-0.25.1)
  • default.qutrit (PennyLane-0.25.1)

qml.about()
Name: PennyLane
Version: 0.26.0
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: …
Author:
Author-email:
License: Apache License 2.0
Location: /path_to_conda/.conda/envs/penny3/lib/python3.11/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, retworkx, scipy, semantic-version, toml
Required-by: PennyLane-Lightning

Platform info: Linux-4.18.0-193.28.1.el8_2.x86_64-x86_64-with-glibc2.28
Python version: 3.11.0
Numpy version: 1.23.4
Scipy version: 1.9.3
Installed devices:

  • lightning.qubit (PennyLane-Lightning-0.26.1)
  • default.gaussian (PennyLane-0.26.0)
  • default.mixed (PennyLane-0.26.0)
  • default.qubit (PennyLane-0.26.0)
  • default.qubit.autograd (PennyLane-0.26.0)
  • default.qubit.jax (PennyLane-0.26.0)
  • default.qubit.tf (PennyLane-0.26.0)
  • default.qubit.torch (PennyLane-0.26.0)
  • default.qutrit (PennyLane-0.26.0)

Hi @Jim,

Welcome to the Forum!

It will still be hard to simulate anything over 20 qubits even with lightning.qubit, but it will be better than using default.qubit . Lightning.qubit comes pre-installed with PennyLane so you can use it without needing a separate installation. I can reproduce your problem with Python 3.11 and I don’t get the warning anymore with Python 3.10. If you try the following does your problem get fixed?

Create a new conda environment with:
conda create --name name_of_your_environment python=3.10
Activate the environment:
conda activate name_of_your_environment
Install PennyLane
pip install pennylane

This should be sufficient for successfully running your code.

Please let us know if this solves your issue!

1 Like

To complement my previous answer,

We do state in our GitHub repository that we only support Python versions 3.7-3.10 so changing your Python version should fix your problem.

Please confirm with us though if this fixes the issue for you.

1 Like

Wow, indeed, this worked! So, installation is not at all as difficult as I thought yesterday. I should have asked earlier. Indeed I didnot notice the version not including 3.11 but this teaches me to pay more attentions to versions given in GitHub! Thanks a lot, Catalina!

No problem @Jim! I’m glad you could fix your problem!

Enjoy using PennyLane!

1 Like

Thank you so much @CatalinaAlbornoz. We do enjoy it so far.

1 Like