Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement unified docs for Lightning Qubit and Kokkos #473

Merged
merged 68 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
1dc3ff6
Create a new single repository structure and merge Lightning Qubit an…
AmintorDusko Aug 15, 2023
2355a1b
remove benchmarks CI actions for now
AmintorDusko Aug 15, 2023
edaa636
update _version.py location on actions
AmintorDusko Aug 15, 2023
d2d77c7
update changelog
AmintorDusko Aug 15, 2023
baa8a2a
update version
AmintorDusko Aug 15, 2023
39b8f12
update action python version
AmintorDusko Aug 15, 2023
7dea907
pleasing CodeFactor
AmintorDusko Aug 15, 2023
4f13e40
remove doc/code/api
AmintorDusko Aug 16, 2023
06f7d9c
ignore doc/code/api
AmintorDusko Aug 16, 2023
85cecca
update wheels build actions
AmintorDusko Aug 16, 2023
818672a
add coverage test
AmintorDusko Aug 16, 2023
80fb3de
add developer tools to check coverage
AmintorDusko Aug 16, 2023
ce6bcd6
update changelog
AmintorDusko Aug 16, 2023
7651bfd
fix broken actions
AmintorDusko Aug 16, 2023
2388378
update test linux
AmintorDusko Aug 16, 2023
97ff515
update upload pypi action name
AmintorDusko Aug 16, 2023
f7af491
update testing configuration strategy
AmintorDusko Aug 17, 2023
a5f76e5
fix tests without binary
AmintorDusko Aug 17, 2023
e5d4bd6
fix tests without binary
AmintorDusko Aug 17, 2023
90117ac
fix tests without binary
AmintorDusko Aug 17, 2023
2b8be88
build wheels for LKokkos but do not push to pypi
AmintorDusko Aug 17, 2023
eb4690a
expand QuantumScriptSerializer testing
AmintorDusko Aug 17, 2023
33896d1
pin pennylane back to what should be
AmintorDusko Aug 17, 2023
3b46388
now, really pinning pennylane back to what should be
AmintorDusko Aug 17, 2023
63eb76b
docs initial push
AmintorDusko Aug 17, 2023
7b6f230
pin pennylane back
AmintorDusko Aug 17, 2023
4741f61
Merge branch 'merge/monorepo' into add/docs
AmintorDusko Aug 18, 2023
1edb74b
add lighning_qubit and lightning_kokkos packages to the automodapi
AmintorDusko Aug 18, 2023
0f159d8
break CIs
AmintorDusko Aug 18, 2023
efc1578
wrong PR, sorry, lol
AmintorDusko Aug 18, 2023
11b8b7d
break CIs
AmintorDusko Aug 18, 2023
28ba3c8
unbreak my CIs... :notes:
AmintorDusko Aug 18, 2023
2f7ef02
adjust test precision
AmintorDusko Aug 18, 2023
3276a11
uninstall pennylane-lightning before testing LightningKokkos
AmintorDusko Aug 18, 2023
a54ec05
fix wheels
AmintorDusko Aug 18, 2023
e3b1f8a
change uninstall pennylane-lightning to install new pennylane-lightni…
AmintorDusko Aug 18, 2023
f9d643c
fix if statement
AmintorDusko Aug 18, 2023
7780e6f
No longer in-place modify input to `apply` (#474)
albi3ro Aug 18, 2023
200a45b
include jax data type
AmintorDusko Aug 18, 2023
5ff5fb5
configure jax precision and test tolerance properly
AmintorDusko Aug 18, 2023
b0839df
format
AmintorDusko Aug 18, 2023
cfbe6b6
Merge branch 'master' into merge/monorepo
AmintorDusko Aug 21, 2023
6985280
Merge branch 'merge/monorepo' into add/docs
AmintorDusko Aug 21, 2023
e27bba4
update dev version
AmintorDusko Aug 21, 2023
1d26c4f
update avx docs
AmintorDusko Aug 21, 2023
83b0630
add Lightning image
AmintorDusko Aug 21, 2023
5057fbd
add Lightning image file
AmintorDusko Aug 21, 2023
090b6e0
update Plugin name to Lightning
AmintorDusko Aug 21, 2023
d39cf0f
merge master
AmintorDusko Aug 21, 2023
1eb2187
Fix merge
AmintorDusko Aug 21, 2023
1cdaf11
more fixing to merge
AmintorDusko Aug 21, 2023
2d9ecea
Merge branch 'master' into add/docs
AmintorDusko Aug 21, 2023
0e769d0
Auto update version
github-actions[bot] Aug 21, 2023
536ffd1
fix bin files
AmintorDusko Aug 21, 2023
604a2c7
fix lightning kokkos docs
AmintorDusko Aug 22, 2023
87db29b
install the lightning_kokkos backend
AmintorDusko Aug 22, 2023
290560c
remove about title
AmintorDusko Aug 22, 2023
31789d6
Update Python on readthedocs action
AmintorDusko Aug 22, 2023
839ca09
fix PYPI Readme rendering
AmintorDusko Aug 23, 2023
ca31a91
Auto update version
github-actions[bot] Aug 23, 2023
abb3ef7
Merge branch 'master' into add/docs
AmintorDusko Aug 23, 2023
4aac51a
Content and structural changes coming from review suggestions
AmintorDusko Aug 23, 2023
4a88ae9
update lightning kokkos installation guidelines
AmintorDusko Aug 23, 2023
34e667f
Update lists of 'Supported operations and observables' in device docs.
vincentmr Aug 24, 2023
21c6acd
Fix Exp Prod SProd Sum links in doc.
vincentmr Aug 24, 2023
f153ffe
review suggestions and some small fixes
AmintorDusko Aug 24, 2023
3fab64c
Fix couple formatting typos.
vincentmr Aug 24, 2023
cd1bf52
Add changelog and more typo fixes
AmintorDusko Aug 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
### Breaking changes

### Improvements

* Merge Lightning Qubit and Lightning Kokkos backends in the new repository.
[(#472)] (https://github.com/PennyLaneAI/pennylane-lightning/pull/472)

* Integrated new unified docs for Lightning Kokkos and Lightning Qubit packages.
[(#473)] (https://github.com/PennyLaneAI/pennylane-lightning/pull/473)

### Documentation

### Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
uses: actions/checkout@v3

- name: Run formatter
run: ./bin/format --check --cfversion 14 ./pennylane_lightning/src
run: ./bin/format --check --cfversion 14 ./pennylane_lightning/core/src

build_and_cache_Kokkos:
name: "Build and cache Kokkos"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wheel_noarch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ jobs:
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
repository-url: https://test.pypi.org/legacy/
4 changes: 3 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ python:
build:
os: ubuntu-22.04
tools:
python: "3.8"
python: "3.9"
apt_packages:
- cmake
- build-essential
Expand All @@ -25,3 +25,5 @@ build:
jobs:
pre_install:
- echo "setuptools~=66.0\npip~=22.0" >> ci_build_requirements.txt
post_install:
- PL_BACKEND="lightning_kokkos" pip install -e . -vv
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,11 @@ ifdef target
cmake --build ./BuildTidy $(VERBOSE) --target $(target)
else
cmake --build ./BuildTidy $(VERBOSE)
endif
endif

docs:
$(MAKE) -C doc html

.PHONY : clean-docs
clean-docs:
$(MAKE) -C doc clean
135 changes: 109 additions & 26 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PennyLane-Lightning Plugin
##########################
Lightning Plugins
#################

.. image:: https://img.shields.io/github/actions/workflow/status/PennyLaneAI/pennylane-lightning/tests_linux.yml?branch=master&label=Test%20%28Linux%29&style=flat-square
:alt: Linux x86_64 tests (branch)
Expand Down Expand Up @@ -35,33 +35,34 @@ PennyLane-Lightning Plugin

.. header-start-inclusion-marker-do-not-remove

The PennyLane-Lightning plugin provides fast state-vector simulators written in C++.
The Lightning plugin ecosystem provides fast state-vector simulators written in C++.

`PennyLane <https://docs.pennylane.ai>`_ is a cross-platform Python library for quantum machine
learning, automatic differentiation, and optimization of hybrid quantum-classical computations.
PennyLane supports Python 3.9 and above.

.. header-end-inclusion-marker-do-not-remove


Features
========

* Combine PennyLane-Lightning's high performance simulators with PennyLane's
* Combine Lightning's high performance simulators with PennyLane's
automatic differentiation and optimization.

.. installation-start-inclusion-marker-do-not-remove
.. installation_LQubit-start-inclusion-marker-do-not-remove


Installation
============
Lightning Qubit installation
============================

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

.. code-block:: console

$ pip install pennylane-lightning

To build PennyLane-Lightning from source you can run
To build Lightning from source you can run

.. code-block:: console

Expand Down Expand Up @@ -109,18 +110,6 @@ or with ``build_ext`` and the ``--define`` flag as follows:
$ python3 setup.py develop


GPU support
-----------
AmintorDusko marked this conversation as resolved.
Show resolved Hide resolved

For GPU support, `PennyLane-Lightning-GPU <https://github.com/PennyLaneAI/pennylane-lightning-gpu>`_
can be installed by providing the optional ``[gpu]`` tag:

.. code-block:: console

$ pip install pennylane-lightning[gpu]

For more information, please refer to the PennyLane Lightning GPU `documentation <https://docs.pennylane.ai/projects/lightning-gpu>`_.

Testing
-------

Expand Down Expand Up @@ -168,7 +157,7 @@ Other supported options are
Compile on Windows with MSVC
----------------------------

You can also compile Pennylane-Lightning on Windows using
You can also compile Lightning on Windows using
`Microsoft Visual C++ <https://visualstudio.microsoft.com/vs/features/cplusplus/>`_ compiler.
You need `cmake <https://cmake.org/download/>`_ and appropriate Python environment
(e.g. using `Anaconda <https://www.anaconda.com/>`_).
Expand All @@ -193,16 +182,110 @@ Then a common command will work.
Note that OpenMP and BLAS are disabled in this setting.


.. installation-end-inclusion-marker-do-not-remove
.. installation_LQubit-end-inclusion-marker-do-not-remove


.. installation_LKokkos-start-inclusion-marker-do-not-remove

Lightning Kokkos installation
=============================

We suggest first installing Kokkos with the wanted configuration following the instructions found in the `Kokkos documentation <https://kokkos.github.io/kokkos-core-wiki/building.html>`_.
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``.

.. code-block:: console

CMAKE_ARGS="-DKokkos_ENABLE_OPENMP=ON" PL_BACKEND="lightning_kokkos" python -m pip install .

AmintorDusko marked this conversation as resolved.
Show resolved Hide resolved
or for an editable ``pip`` installation with:

.. code-block:: console

CMAKE_ARGS="-DKokkos_ENABLE_OPENMP=ON" PL_BACKEND="lightning_kokkos" python -m pip install -e .

Alternatively, you can install the Python interface with:

.. code-block:: console

CMAKE_ARGS="-DKokkos_ENABLE_OPENMP=ON" PL_BACKEND="lightning_kokkos" python setup.py build_ext
python setup.py bdist_wheel
pip install ./dist/PennyLane*.whl --force-reinstall

To build the plugin directly with CMake:

.. code-block:: console

cmake -B build -DKokkos_ENABLE_OPENMP=ON -DPLKOKKOS_BUILD_TESTS=ON -DPL_BACKEND=lightning_kokkos -G Ninja
cmake --build build

Supported backend options are "SERIAL", "OPENMP", "THREADS", "HIP" and "CUDA" and the corresponding build options are ``-DKokkos_ENABLE_XXX=ON``, where ``XXX`` needs be replaced by the backend name, for instance ``OPENMP``.
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 <https://github.com/kokkos/kokkos/wiki/Macros#architectures>`_.
Note that "THREADS" backend is not recommended since `Kokkos <https://github.com/kokkos/kokkos-core-wiki/blob/17f08a6483937c26e14ec3c93a2aa40e4ce081ce/docs/source/ProgrammingGuide/Initialization.md?plain=1#L67>`_ does not guarantee its safety.

AmintorDusko marked this conversation as resolved.
Show resolved Hide resolved

Testing
=======

To test with the ROCm stack using a manylinux2014 container we must first mount the repository into the container:

.. code-block:: console

docker run -v `pwd`:/io -it quay.io/pypa/manylinux2014_x86_64 bash

Next, within the container, we install the ROCm software stack:

.. code-block:: console

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 <https://github.com/kokkos/kokkos/blob/master/Makefile.kokkos>`_.

.. code-block:: console

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:

.. code-block:: console

CMAKE_ARGS="-DKokkos_ENABLE_HIP=ON -DKokkos_ARCH_VEGA90A=ON" PL_BACKEND="lightning_kokkos" python -m pip install -e .

.. installation_LKokkos-end-inclusion-marker-do-not-remove

Please refer to the `plugin documentation <https://docs.pennylane.ai/projects/lightning/>`_ as
well as to the `PennyLane documentation <https://docs.pennylane.ai/>`_ for further reference.


GPU support
-----------

For GPU support, `PennyLane-Lightning-GPU <https://github.com/PennyLaneAI/pennylane-lightning-gpu>`_
can be installed by providing the optional ``[gpu]`` tag:

.. code-block:: console

$ pip install pennylane-lightning[gpu]

For more information, please refer to the PennyLane Lightning GPU `documentation <https://docs.pennylane.ai/projects/lightning-gpu>`_.

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

One can also build the Lightning image using Docker:

.. code-block:: console

Expand Down Expand Up @@ -237,9 +320,9 @@ Please make your best effort to comply with `black` and `pylint` before using di
Authors
=======

PennyLane-Lightning is the work of `many contributors <https://github.com/PennyLaneAI/pennylane-lightning/graphs/contributors>`_.
Lightning is the work of `many contributors <https://github.com/PennyLaneAI/pennylane-lightning/graphs/contributors>`_.

If you are doing research using PennyLane and PennyLane-Lightning, please cite `our paper <https://arxiv.org/abs/1811.04968>`_:
If you are doing research using PennyLane and Lightning, please cite `our paper <https://arxiv.org/abs/1811.04968>`_:

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,
Expand Down
34 changes: 34 additions & 0 deletions bin/cpp-files
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/python3

import argparse
import json
import sys

from utils import get_cpp_files


if __name__ == '__main__':
"""
This program output a json list of all C++ source files.
"""
parser = argparse.ArgumentParser(
description="Output C/C++ files in json list"
)
parser.add_argument(
"--header-only", action='store_true', dest='header_only', help="whether only include header files"
)
parser.add_argument(
"paths", nargs="+", metavar="DIR", help="paths to the root source directories"
)
parser.add_argument(
"--exclude-dirs", dest="exclude_dirs", nargs="*", metavar="DIR", help="paths exclude from"
)

args = parser.parse_args()

files = set(get_cpp_files(args.paths, header_only = args.header_only))
if args.exclude_dirs:
files_excludes = set(get_cpp_files(args.exclude_dirs, header_only = args.header_only))
files -= files_excludes

json.dump(list(files), sys.stdout)
5 changes: 3 additions & 2 deletions bin/format
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import argparse
import json
import re
import shutil
import subprocess
import sys
from cpp_files import get_cpp_files
from utils import get_cpp_files

CLANG_FMT_BIN = "clang-format"
CLANG_FMT_STYLE_CFG = {
Expand Down Expand Up @@ -125,4 +126,4 @@ if __name__ == "__main__":
else:
ret = fmt(args, cf_cmd)

sys.exit(int(ret > 0))
sys.exit(int(ret > 0))
2 changes: 1 addition & 1 deletion bin/cpp_files.py → bin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ def get_cpp_files(paths, ignore_patterns=None, use_gitignore=True, header_only=F
files = set()
for path in paths:
files |= get_cpp_files_from_path(path, ignore_patterns, use_gitignore, header_only)
return list(files)
return list(files)
Binary file added doc/_static/pennylane_lightning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 0 additions & 21 deletions doc/avx_kernels/build_system.rst

This file was deleted.

10 changes: 5 additions & 5 deletions doc/benchmark.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ You can benchmark different gate implementations inside the project.
Then you can benchmark all gate operations in all kernels by running the script.

.. code-block:: console

$ ./benchmarks/benchmark_all.sh

The results will be recorded in ``bench_result.json`` file.
You can then plot the results for a specific gate with
You can then plot the results for a specific gate with

.. code-block:: console

$ ./benchmarks/plot_gate_benchmark.py ./bench_result.json

It will create a plot for each gate operation comparing performance of kernels and floating point types. The plots can be found in ``plots`` subdirectory.

One can also choose a specific datatype by providing an option:

.. code-block:: console

$ ./benchmarks/plot_gate_benchmark.py --precision float ./bench_result.json # Results for std::complex<float>
$ ./benchmarks/plot_gate_benchmark.py --precision double ./bench_result.json # Results for std::complex<double>


Currently, we have two different kernels in ``Pennylane-Lightning`` named ``PI`` and ``LM``. For difference between two kernels, see the documents :cpp:class:`Pennylane::Gates::GateImplementationsPI` and :cpp:class:`Pennylane::Gates::GateImplementationsLM`.
Currently, we have two different kernels in ``Lightning Qubit`` named ``PI`` and ``LM``. For difference between two kernels, see the documents :cpp:class:`Pennylane::Gates::GateImplementationsPI` and :cpp:class:`Pennylane::Gates::GateImplementationsLM`.

Here are some example plots:

Expand Down
Loading
Loading