Pennylane (Xanadu)
PennyLane is a cross-platform Python library for differentiable programming of quantum computers, similar to TensorFlow and PyTorch for classical computation. It facilitates the training of variational quantum circuits.
Project Website
Visit the official project website (https://pennylane.ai/) for the latest updates and their vast community resources as tutorials, videos, cookbook and many more to learn and use PennyLane.
License
PennyLane is released under the permissive free software license Apache 2.0. Refer to the LICENSE file for further details.
Version
As of March 10th 2024, the current stable version is 0.35. The PennyLane software library is in active development and new versions with features and bugfixes are released every few months. Latest releases can be retrieved from their GitHub repository (https://github.com/PennyLaneAI/pennylane) or installed from the PyPi repository with pip.
Hardware Plugins
PennyLane is designed from the ground to be hardware and device agnostic, allowing quantum functions to be easily dispatched to different quantum devices. It currently supports compilation on quantum devices such as AQT, Honeywell, IonQ or Rigetti.
Software Plugins
PennyLane further supports plugins that facilitates quantum software development. They can be divided into two main categories:
Quantum Machine Learning / AI Plugins
PennyLane connects to some of the popular machine learning and optimisation libraries via interfaces, enabling numerical objects to be passed as parameters to the quantum circuit. Currently, the four supported frameworks are NumPy, PyTorch, TensorFlow, JAX.
Documentation on using the interfaces: https://docs.pennylane.ai/en/stable/introduction/interfaces.html
Quantum Software Frameworks and Quantum Simulator Plugins
PennyLane also provides plugins for quantum software frameworks and circuit simulators. Notable supported frameworks are Qiskit, Amazon Braket, Cirq, Microsoft QDK, Qulacs, Quantum Inspire, ProjectQ or Orquestra.
HPC Components
PennyLane has several components that can accelerate quantum jobs. Here is the list of some of the components:
Catalyst Compiler
Catalyst is a Just-in-Time (JIT) compiler for hybrid quantum-classical programs, currently under heavy development.
Please refer to the documentation page to build and install Catalyst: https://docs.pennylane.ai/projects/catalyst/en/stable/dev/installation.html
HPC Tools
PennyLane enables acceleration via its execution object called the device. Different devices can enable various high performance tools. Some examples are listed below:
Simulators | Properties | Supported By (Refer to 7.2 for installing the individual plug-ins) |
---|---|---|
lightning.qubit |
|
|
lightning.gpu |
|
|
lightning.kokkos |
|
|
default.qubit |
|
|
default.mixed |
|
|
Installation & Deployment
Supported HPC Systems
SuperMUC-NG, Linux Cluster, Eviden Qaptiva, AI Systems
Getting access to SuperMUC-NG: https://doku.lrz.de/access-and-login-to-supermuc-ng-11482471.html
Getting access to Linux Cluster: https://doku.lrz.de/linux-cluster-10745672.html
Getting access to Eviden Qaptiva: https://doku.lrz.de/atos-qlm-10745934.html
Getting access to AI Systems: https://doku.lrz.de/3-access-and-getting-started-10746642.html
Installation
PennyLane requires Python version 3.9 and above.
Linux Cluster / Eviden Qaptiva
Pennylane is globally installed in Eviden Qaptiva.
To install the latest package version with pip:
# install the latest released version of PennyLane pip install pennylane --upgrade
Alternatively, PennyLane can be installed from source:
# download and install the latest source code from GitHub git clone https://github.com/PennyLaneAI/pennylane.git cd pennylane pip install -e .
To install additional plugins, please refer to PennyLane's installation page: https://pennylane.ai/install/Here are some examples:
# Select one or more quantum frameworks above to install the PennyLane plugins. pip install pennylane-lightning pennylane-lightning[gpu] pennylane-sf # Select one or more ML libraries above to install them to work with PennyLane. pip install autograd tensorflow
SuperMUC-NG
Step 1:
First thing to be done, is to install a new python version on SuperMUC-NG, since for pennylane python3.9>= is needed.
Installing a new python version in SNG using spack
# Select one or more quantum frameworks above to install the PennyLane plugins. spack info python # or the exact python version you want to use spack install python@3.9.7 # Check the location to the installed interpreter, and use the path whenever you generate a virtual environment for the installed python version. spack location -i python@3.9.7 spack load python@3.9.7
Step 2:
In SNG, the firewall, prevents any outgoing connections. Therefore in order to install additional python packages (pip/git). To circumvent this reverse tunneling is needed. More information could be found here: https://doku.lrz.de/faq-installing-your-own-applications-on-supermug-ng-internet-access-from-supermuc-ng-10746066.html
AI Systems
Pennylane's lightning-GPU plugin allows the use of GPU for circuit simulations and other operations regarding quantum computation.
The LRZ AI Systems run jobs within containers. In particular, the Enroot container provided by NVIDIA is used. The details on how to build the container can be found here: https://doku.lrz.de/4-introduction-to-enroot-the-software-stack-provider-for-the-lrz-ai-systems-10746639.html (TODO: could you share if you had any documentation from it? De Pascale, Marco )
Example Usage
# import pennylane as qml from pennylane import numpy as np dev = qml.device("lightning.qubit", wires=3) # Defining backend @qml.qnode(dev, interface="autograd") def circuit(params): # |psi_0>: state preparation qml.RY(np.pi / 4, wires=0) qml.RY(np.pi / 3, wires=1) qml.RY(np.pi / 7, wires=2) # V0(theta0, theta1): Parametrized layer 0 qml.RZ(params[0], wires=0) qml.RZ(params[1], wires=1) # W1: non-parametrized gates qml.CNOT(wires=[0, 1]) qml.CNOT(wires=[1, 2]) return qml.expval(qml.PauliY(0)) # Measurement / Expectation Value params = np.array([0.432, -0.123, 0.543, 0.233]) print(circuit(params))