Skip to main content

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

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:

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-Kokkos-0.31.0.tar.gz (86.2 kB view hashes)

Uploaded Source

Built Distributions

PennyLane_Lightning_Kokkos-0.31.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (867.5 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

PennyLane_Lightning_Kokkos-0.31.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (868.0 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

PennyLane_Lightning_Kokkos-0.31.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (867.7 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

PennyLane_Lightning_Kokkos-0.31.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (867.6 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ 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