Skip to main content

PennyLane-Lightning plugin

Project description

GitHub Workflow Status (branch) Codecov coverage CodeFactor Grade Read the Docs PyPI PyPI - Python Version

The PennyLane-Lightning plugin provides a fast state-vector simulator written in C++.

PennyLane is a cross-platform Python library for quantum machine learning, automatic differentiation, and optimization of hybrid quantum-classical computations.

Features

  • Combine PennyLane-Lightning’s high performance simulator with PennyLane’s automatic differentiation and optimization.

Installation

PennyLane-Lightning requires Python version 3.8 and above. It can be installed using pip:

$ pip install pennylane-lightning

To build PennyLane-Lightning from source you can run

$ pip install pybind11 pennylane-lightning --no-binary :all:

A C++ compiler such as g++, clang, or MSVC is required. On Debian-based systems, this can be installed via apt:

$ sudo apt install g++

The pybind11 library is also used for binding the C++ functionality to Python.

Alternatively, for development and testing, you can install by cloning the repository:

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

Note that subsequent calls to pip install -e . will use cached binaries stored in the build folder. Run make clean if you would like to recompile.

You can also pass cmake options with build_ext:

$ python3 setup.py build_ext -i --define="ENABLE_OPENMP=OFF;ENABLE_NATIVE=ON"

and install the compilied library with

$ python3 setup.py develop

GPU support

For GPU support, PennyLane-Lightning-GPU can be installed by providing the optional [gpu] tag:

$ pip install pennylane-lightning[gpu]

For more information, please refer to the PennyLane Lightning GPU documentation.

Testing

To test that the plugin is working correctly you can test the Python code within the cloned repository:

$ make test-python

while the C++ code can be tested with

$ make test-cpp

CMake Support

One can also build the plugin using CMake:

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

To test the C++ code:

$ mkdir build && cd build
$ cmake -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug ..
$ make

Other supported options are -DENABLE_WARNINGS=ON, -DENABLE_NATIVE=ON (for -march=native), -DENABLE_BLAS=ON, -DENABLE_OPENMP=ON, -DENABLE_KOKKOS=ON, and -DENABLE_CLANG_TIDY=ON.

Compile on Windows with MSVC

You can also compile Pennylane-Lightning on Windows using Microsoft Visual C++ compiler. You need cmake and appropriate Python environment (e.g. using Anaconda).

We recommend to use [x64 (or x86)] Native Tools Command Prompt for VS [version] for compiling the library. Be sure that cmake and python can be called within the prompt.

$ cmake --version
$ python --version

Then a common command will work.

$ pip install -r requirements.txt
$ pip install -e .

Note that OpenMP and BLAS are disabled in this setting.

Please refer to the plugin documentation as well as to the PennyLane documentation for further reference.

Docker Support

One can also build the Pennylane-Lightning image using Docker:

$ git clone https://github.com/PennyLaneAI/pennylane-lightning.git
$ cd pennylane-lightning
$ docker build -t lightning/base -f docker/Dockerfile .

Please refer to the PennyLane installation for detailed description about PennyLane Docker support.

Contributing

We welcome contributions - simply fork the repository of this plugin, and then make a pull request containing your contribution. All contributers to this plugin will be listed as authors on the releases.

We also encourage bug reports, suggestions for new features and enhancements, and even links to cool projects or applications built on PennyLane.

Authors

PennyLane-Lightning is the work of many contributors.

If you are doing research using PennyLane and PennyLane-Lightning, please cite our paper:

Ville Bergholm, Josh Izaac, Maria Schuld, Christian Gogolin, M. Sohaib Alam, Shahnawaz Ahmed, Juan Miguel Arrazola, Carsten Blank, Alain Delgado, Soran Jahangiri, Keri McKiernan, Johannes Jakob Meyer, Zeyue Niu, Antal Száva, and Nathan Killoran. PennyLane: Automatic differentiation of hybrid quantum-classical computations. 2018. arXiv:1811.04968

Support

If you are having issues, please let us know by posting the issue on our Github issue tracker, or by asking a question in the forum.

License

The PennyLane lightning plugin is free and open source, released under the Apache License, Version 2.0.

Acknowledgements

PennyLane Lightning makes use of the following libraries and tools, which are under their own respective licenses:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PennyLane-Lightning-0.28.0.tar.gz (21.2 kB view hashes)

Uploaded Source

Built Distributions

PennyLane_Lightning-0.28.0-py3-none-any.whl (227.2 kB view hashes)

Uploaded Python 3

PennyLane_Lightning-0.28.0-cp311-cp311-win_amd64.whl (4.5 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

PennyLane_Lightning-0.28.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.4 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

PennyLane_Lightning-0.28.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (12.7 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ppc64le

PennyLane_Lightning-0.28.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (12.5 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

PennyLane_Lightning-0.28.0-cp311-cp311-macosx_11_0_arm64.whl (897.6 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

PennyLane_Lightning-0.28.0-cp311-cp311-macosx_10_15_x86_64.whl (1.4 MB view hashes)

Uploaded CPython 3.11 macOS 10.15+ x86-64

PennyLane_Lightning-0.28.0-cp310-cp310-win_amd64.whl (4.5 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

PennyLane_Lightning-0.28.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.4 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

PennyLane_Lightning-0.28.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (12.7 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ppc64le

PennyLane_Lightning-0.28.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (12.5 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

PennyLane_Lightning-0.28.0-cp310-cp310-macosx_11_0_arm64.whl (897.6 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

PennyLane_Lightning-0.28.0-cp310-cp310-macosx_10_15_x86_64.whl (1.4 MB view hashes)

Uploaded CPython 3.10 macOS 10.15+ x86-64

PennyLane_Lightning-0.28.0-cp39-cp39-win_amd64.whl (4.5 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

PennyLane_Lightning-0.28.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.4 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

PennyLane_Lightning-0.28.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (12.7 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ppc64le

PennyLane_Lightning-0.28.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (12.5 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

PennyLane_Lightning-0.28.0-cp39-cp39-macosx_11_0_arm64.whl (897.5 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

PennyLane_Lightning-0.28.0-cp39-cp39-macosx_10_15_x86_64.whl (1.4 MB view hashes)

Uploaded CPython 3.9 macOS 10.15+ x86-64

PennyLane_Lightning-0.28.0-cp38-cp38-win_amd64.whl (4.5 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

PennyLane_Lightning-0.28.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.3 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

PennyLane_Lightning-0.28.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (12.7 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ppc64le

PennyLane_Lightning-0.28.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (12.4 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

PennyLane_Lightning-0.28.0-cp38-cp38-macosx_11_0_arm64.whl (897.5 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

PennyLane_Lightning-0.28.0-cp38-cp38-macosx_10_15_x86_64.whl (1.4 MB view hashes)

Uploaded CPython 3.8 macOS 10.15+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page