PennyLane-Lightning-Kokkos plugin
Project description
The PennyLane-Lightning-Kokkos plugin provides a fast state-vector simulator written in C++. It enables parallel execution with various parallel backends, including C++ threads, OpenMP, CUDA, ROCM/HIP and SYCL via the Kokkos library. For more details, have a look at our blog post.
PennyLane is a cross-platform Python library for quantum machine learning, automatic differentiation, and optimization of hybrid quantum-classical computations.
Installation
We suggest first installing Kokkos with the wanted configuration following the instruction found in the Kokkos documentation. Next, append the install location to CMAKE_PREFIX_PATH. If an installation is not found, our builder will install it from scratch nevertheless.
The simplest way to install PennyLane-Lightning-Kokkos (OpenMP backend) is using pip.
CMAKE_ARGS="-DKokkos_ENABLE_OPENMP=ON" python -m pip install .
or for an editable pip installation with:
CMAKE_ARGS="-DKokkos_ENABLE_OPENMP=ON" python -m pip install -e .
Alternatively, you can install the python interface with:
CMAKE_ARGS="-DKokkos_ENABLE_OPENMP=ON" python setup.py build_ext
python setup.py bdist_wheel
pip install ./dist/PennyLane*.whl --force-reinstall
To build the plugin directly with CMake:
cmake -B build -DKokkos_ENABLE_OPENMP=ON -DPLKOKKOS_BUILD_TESTS=ON -G Ninja
cmake --build build
Supported backend options are “SERIAL”, “OPENMP”, “THREADS”, “HIP” and “CUDA” and the corresponding build switches are -DKokkos_ENABLE_BACKEND=ON, where one needs to replace BACKEND. One can activate simultaneously one serial, one parallel CPU host (e.g. “OPENMP”, “THREADS”) and one parallel GPU device backend (e.g. “HIP”, “CUDA”), but not two of any category at the same time. For “HIP” and “CUDA”, the appropriate software stacks are required to enable compilation and subsequent use. Similarly, the CMake option -DKokkos_ARCH_{...}=ON must also be specified to target a given architecture. A list of the architectures is found on the Kokkos wiki. Note that “THREADS” backend is not recommended since Kokkos does not guarantee its safety.
Testing
To test with the ROCm stack using a manylinux2014 container we must first mount the repository into the container:
docker run -v `pwd`:/io -it quay.io/pypa/manylinux2014_x86_64 bash
Next, within the container, we install the ROCm software stack:
yum install -y https://repo.radeon.com/amdgpu-install/21.40.2/rhel/7.9/amdgpu-install-21.40.2.40502-1.el7.noarch.rpm
amdgpu-install --usecase=hiplibsdk,rocm --no-dkms
We next build the test-suite, with a given AMD GPU target in mind, as listed here.
cd /io
export PATH=$PATH:/opt/rocm/bin/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rocm/lib
export CXX=/opt/rocm/hip/bin/hipcc
cmake -B build -DCMAKE_CXX_COMPILER=/opt/rocm/hip/bin/hipcc -DKokkos_ENABLE_HIP=ON -DPLKOKKOS_BUILD_TESTS=ON -DKokkos_ARCH_VEGA90A=ON
cmake --build build --verbose
We may now leave the container, and run the built test-suite on a machine with access to the targeted GPU.
For a system with access to the ROCm stack outside of a manylinux container, an editable pip installation can be built and installed as:
CMAKE_ARGS="-DKokkos_ENABLE_HIP=ON -DKokkos_ARCH_VEGA90A=ON" python -m pip install -e .
Support
Source Code: https://github.com/PennyLaneAI/pennylane-lightning-kokkos
Issue Tracker: https://github.com/PennyLaneAI/pennylane-lightning-kokkos/issues
PennyLane Forum: https://discuss.pennylane.ai
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-Kokkos plugin is free and open source, released under the Apache License, Version 2.0. The PennyLane-Lightning-Kokkos plugin makes use of the Kokkos library, which is held to their own respective licenses.
Acknowledgements
The PennyLane Lightning Kokkos plugin makes use of the following libraries and tools, which are under their own respective licenses:
pybind11: https://github.com/pybind/pybind11
Kokkos Core: https://github.com/kokkos/kokkos
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for PennyLane-Lightning-Kokkos-0.32.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d527772d25c321af2a0c221bfbb18cc29d724a8f16c8611be54d3711981c7ad |
|
MD5 | b5c920a5ecdc24508d198a9043743561 |
|
BLAKE2b-256 | 3881e93a2c37e7360737e91024c8611dd122f6ebbaccbe54e416946b275d3b25 |
Hashes for PennyLane_Lightning_Kokkos-0.32.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51a1219788a60cbd19f0c17c4944befe95500944add9fb4d2353cf60fa945e7a |
|
MD5 | 8797fd91f9136fa1518659c92c9fc252 |
|
BLAKE2b-256 | 323db6bf3b5d55f6879a2f6911bb39a5c8ea3283a02c5e7867fd2b354624824f |
Hashes for PennyLane_Lightning_Kokkos-0.32.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57509288cccbdb0d291f81cb5e28014e6797116e4fd7139e34f7505ac20fa9da |
|
MD5 | 61d6cb94040cf041e0e4311187ab1b6b |
|
BLAKE2b-256 | 6d580106463fa3bbadb2a774bf23b3902cdaa392be2fa27b100bbdeadbc95dde |
Hashes for PennyLane_Lightning_Kokkos-0.32.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38f3065b07d8d86602f29047e7d85772d1e59b362e9347e51aef55fad554c7dd |
|
MD5 | 8ebb6325dd05e72d2c93f28771e92c7f |
|
BLAKE2b-256 | c2703ca0ab404695dc542bb55ca147b4a2817b815500bd7f4448c36ceba15a39 |