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

QA docs #1035

Merged
merged 31 commits into from
Jan 10, 2025
Merged

QA docs #1035

Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9cd7a5b
update tn docs
josephleekl Jan 9, 2025
d94d894
add LT
LuisAlfredoNu Jan 9, 2025
95f88dd
update LG LK docstring
josephleekl Jan 9, 2025
908ac98
update LG LK
josephleekl Jan 9, 2025
eec6f7c
solve death links
LuisAlfredoNu Jan 9, 2025
640b9d0
update changelog
josephleekl Jan 9, 2025
0dc655a
update README
LuisAlfredoNu Jan 9, 2025
40c67ba
hightlinth names
LuisAlfredoNu Jan 9, 2025
73af3a5
update CI badge
josephleekl Jan 9, 2025
457a83b
Merge branch 'tn-doc-update' of github.com:PennyLaneAI/pennylane-ligh…
josephleekl Jan 9, 2025
e9b624e
windows test badge
josephleekl Jan 9, 2025
b494a72
LT docs
LuisAlfredoNu Jan 9, 2025
1e34bc7
Merge branch 'tn-doc-update' of github.com:PennyLaneAI/pennylane-ligh…
LuisAlfredoNu Jan 9, 2025
f2a787d
update LQ installation instruction
josephleekl Jan 9, 2025
5086fff
solve render issue
LuisAlfredoNu Jan 9, 2025
6db1ad6
Merge branch 'tn-doc-update' of github.com:PennyLaneAI/pennylane-ligh…
LuisAlfredoNu Jan 9, 2025
3a0a4b9
update readme
josephleekl Jan 9, 2025
ca4729c
Merge branch 'tn-doc-update' of github.com:PennyLaneAI/pennylane-ligh…
josephleekl Jan 9, 2025
a944d0d
change max bond dim
LuisAlfredoNu Jan 9, 2025
9a53074
Merge branch 'tn-doc-update' of github.com:PennyLaneAI/pennylane-ligh…
LuisAlfredoNu Jan 9, 2025
8ce05c5
Merge branch 'v0.40.0_docs' into tn-doc-update
LuisAlfredoNu Jan 9, 2025
5a57cdb
update readme
josephleekl Jan 9, 2025
f4abc96
appply format
LuisAlfredoNu Jan 9, 2025
03655cc
add cuda python dependencies
josephleekl Jan 9, 2025
ca2a028
alfredo fix
josephleekl Jan 9, 2025
b83700a
update README cuda libs
josephleekl Jan 9, 2025
245e164
fix readme
josephleekl Jan 9, 2025
df47ec0
update doc devices
josephleekl Jan 9, 2025
dd1b1c5
update rc version to 3
josephleekl Jan 9, 2025
62ebadf
Shuli's comments
LuisAlfredoNu Jan 9, 2025
de56347
gates list double check
LuisAlfredoNu Jan 10, 2025
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
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@

### Documentation

* Update and improve README and documentations.
[(#1035)](https://github.com/PennyLaneAI/pennylane-lightning/pull/1035)

* Add the exact tensor network to the `README.rst` and update link to `HIP`.
[(#1034)](https://github.com/PennyLaneAI/pennylane-lightning/pull/1034)

Expand Down
35 changes: 16 additions & 19 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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)
:target: https://github.com/PennyLaneAI/pennylane-lightning/actions/workflows/tests_linux.yml
josephleekl marked this conversation as resolved.
Show resolved Hide resolved
.. image:: https://img.shields.io/github/actions/workflow/status/PennyLaneAI/pennylane-lightning/tests_linux_cpp.yml?branch=master&label=Test%20%28Linux%20C%2B%2B%29&style=flat-square
:alt: Linux x86_64 C++ tests (branch)
:target: https://github.com/PennyLaneAI/pennylane-lightning/actions/workflows/tests_linux_cpp.yml

.. image:: https://img.shields.io/github/actions/workflow/status/PennyLaneAI/pennylane-lightning/tests_windows.yml?branch=master&label=Test%20%28Windows%29&style=flat-square
:alt: Windows tests (branch)
:target: https://github.com/PennyLaneAI/pennylane-lightning/actions/workflows/tests_windows.yml
josephleekl marked this conversation as resolved.
Show resolved Hide resolved
.. image:: https://img.shields.io/github/actions/workflow/status/PennyLaneAI/pennylane-lightning/tests_windows_cpp.yml?branch=master&label=Test%20%28Windows%20C%2B%2B%29&style=flat-square
:alt: Windows C++ tests (branch)
:target: https://github.com/PennyLaneAI/pennylane-lightning/actions/workflows/tests_windows_cpp.yml

.. image:: https://img.shields.io/github/actions/workflow/status/PennyLaneAI/pennylane-lightning/.github/workflows/wheel_linux_x86_64.yml?branch=master&logo=github&style=flat-square
:alt: Linux x86_64 wheel builds (branch)
Expand Down Expand Up @@ -46,10 +46,10 @@ Features

PennyLane-Lightning high performance simulators include the following backends:

* ``lightning.qubit``: is a fast state-vector simulator written in C++.
* ``lightning.gpu``: is a state-vector simulator based on the `NVIDIA cuQuantum SDK <https://developer.nvidia.com/cuquantum-sdk>`_. It notably implements a distributed state-vector simulator based on MPI.
* ``lightning.kokkos``: is a state-vector simulator written with `Kokkos <https://kokkos.github.io/kokkos-core-wiki/index.html>`_. It can exploit the inherent parallelism of modern processing units supporting the `OpenMP <https://www.openmp.org/>`_, `CUDA <https://developer.nvidia.com/cuda-toolkit>`_ or `HIP <https://rocm.docs.amd.com/projects/HIP/en/latest/>`_ programming models.
* ``lightning.tensor``: is a tensor network simulator based on the `NVIDIA cuQuantum SDK <https://developer.nvidia.com/cuquantum-sdk>`_ (requires NVIDIA GPUs with SM 7.0 or greater). The supported methods are Matrix Product State (MPS) and Exact Tensor Network(TN).
* ``lightning.qubit``: a fast state-vector simulator written in C++.
* ``lightning.gpu``: a state-vector simulator based on the `NVIDIA cuQuantum SDK <https://developer.nvidia.com/cuquantum-sdk>`_. It notably implements a distributed state-vector simulator based on MPI.
LuisAlfredoNu marked this conversation as resolved.
Show resolved Hide resolved
* ``lightning.kokkos``: a state-vector simulator written with `Kokkos <https://kokkos.github.io/kokkos-core-wiki/index.html>`_. It can exploit the inherent parallelism of modern processing units supporting the `OpenMP <https://www.openmp.org/>`_, `CUDA <https://developer.nvidia.com/cuda-toolkit>`_ or `HIP <https://rocm.docs.amd.com/projects/HIP/en/latest/>`_ programming models.
* ``lightning.tensor``: a tensor network simulator based on the `NVIDIA cuQuantum SDK <https://developer.nvidia.com/cuquantum-sdk>`_ (requires NVIDIA GPUs with SM 7.0 or greater). The supported methods are Matrix Product State (MPS) and Exact Tensor Network (ExactTN).

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

Expand Down Expand Up @@ -87,7 +87,7 @@ Install from source

.. note::

The below contains instructions for installing Lightning-Qubit ***from source***. For most cases, *this is not required* and one can simply use the installation instructions at `pennylane.ai/install <https://pennylane.ai/install>`__.
The section below contains instructions for installing Lightning-Qubit ***from source***. For most cases, *this is not required* and one can simply use the installation instructions at `pennylane.ai/install <https://pennylane.ai/install>`__.
If those instructions do not work for you, or you have a more complex build environment that requires building from source, then consider reading on.

To build Lightning plugins from source you can run
Expand All @@ -97,7 +97,7 @@ To build Lightning plugins from source you can run
PL_BACKEND=${PL_BACKEND} pip install pybind11 pennylane-lightning --no-binary :all:

where ``${PL_BACKEND}`` can be ``lightning_qubit`` (default), ``lightning_gpu``, ``lightning_kokkos``, or ``lightning_tensor``.
The `pybind11 <https://pybind11.readthedocs.io/en/stable/>`_ library is required to bind the C++ functionality to Python.
The `pybind11 <https://pybind11.readthedocs.io/en/stable/>`_ library is required to bind the C++ functionality to Python. If installing Lightning-GPU, Lightning-Tensor, or Lightning-Kokkos, additional dependencies may be required. We recommend referring to the respective guides for `Lightning-GPU installation <https://docs.pennylane.ai/projects/lightning/en/stable/lightning_gpu/installation.html>`_, `Lightning-Tensor installation <https://docs.pennylane.ai/projects/lightning/en/stable/lightning_tensor/installation.html>`_, and `Lightning-Kokkos installation <https://docs.pennylane.ai/projects/lightning/en/stable/lightning_kokkos/installation.html>`_.

A C++ compiler such as ``g++``, ``clang++``, or ``MSVC`` is required.
On Debian-based systems, this can be installed via ``apt``:
Expand All @@ -113,9 +113,6 @@ On MacOS, we recommend using the latest version of ``clang++`` and ``libomp``:

brew install llvm libomp

The Lightning-GPU backend has several dependencies (e.g. ``CUDA``, ``custatevec-cu12``, etc.), and hence we recommend referring to `Lightning-GPU installation <https://docs.pennylane.ai/projects/lightning/en/stable/lightning_gpu/installation.html>`_ section.
Similarly, for Lightning-Kokkos it is recommended to configure and install Kokkos independently as prescribed in the `Lightning-Kokkos installation <https://docs.pennylane.ai/projects/lightning/en/stable/lightning_kokkos/installation.html>`_ section.

Development installation
========================

Expand Down Expand Up @@ -181,7 +178,7 @@ Test the Python code with:

make test-python device=${PL.DEVICE}

where ``${PL.DEVICE}`` differ from ``${PL_BACKEND}`` by replacing the underscore by a dot. And can be
where ``${PL.DEVICE}`` differ from ``${PL_BACKEND}`` by replacing the underscore by a dot. Options for ``${PL.DEVICE}`` are

- ``lightning.qubit`` (default)
- ``lightning.gpu``
Expand Down Expand Up @@ -217,7 +214,7 @@ Install Lightning-GPU from source

The below contains instructions for installing Lightning-GPU ***from source***. For most cases, *this is not required* and one can simply use the installation instructions at `pennylane.ai/install <https://pennylane.ai/install/#high-performance-computing-and-gpus>`__. If those instructions do not work for you, or you have a more complex build environment that requires building from source, then consider reading on.

To install Lightning-GPU from the package sources using the direct SDK path, Lightning-Qubit should be install before Lightning-GPU (compilation is not necessary):
To install Lightning-GPU from source, Lightning-Qubit needs to be 'installed' by ``pip`` before Lightning-GPU (compilation is not necessary):

.. code-block:: bash

Expand Down Expand Up @@ -252,7 +249,7 @@ Install Lightning-GPU with MPI
``CUDA-aware MPI`` allows data exchange between GPU memory spaces of different nodes without the need for CPU-mediated transfers.
Both the ``MPICH`` and ``OpenMPI`` libraries are supported, provided they are compiled with CUDA support.
It is recommended to install the ``NVIDIA cuQuantum SDK`` and ``mpi4py`` Python package within ``pip`` or ``conda`` inside a virtual environment.
Please consult the `cuQuantum SDK`_ , `mpi4py <https://mpi4py.readthedocs.io/en/stable/install.html>`_,
Please consult the `cuQuantum SDK <https://developer.nvidia.com/cuquantum-sdk>`_ , `mpi4py <https://mpi4py.readthedocs.io/en/stable/install.html>`_,
LuisAlfredoNu marked this conversation as resolved.
Show resolved Hide resolved
`MPICH <https://www.mpich.org/static/downloads/4.1.1/mpich-4.1.1-README.txt>`_, or `OpenMPI <https://www.open-mpi.org/faq/?category=buildcuda>`_ install guide for more information.

**Before installing Lightning-GPU with MPI support using the direct SDK path, please ensure that:**
Expand Down Expand Up @@ -379,7 +376,7 @@ The supported backend options are
- ``HIP``
- ``CUDA``

and the corresponding build options are ``-DKokkos_ENABLE_XXX=ON``, where ``XXX`` needs be replaced by the backend name, for instance ``OPENMP``.
and the corresponding build options are ``-DKokkos_ENABLE_XYZ=ON``, where ``XYZ`` 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.
Expand Down
8 changes: 4 additions & 4 deletions doc/lightning_tensor/device.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ Users can also run the ``lightning.tensor`` device in the **Exact Tensor Network
import pennylane as qml
dev = qml.device("lightning.tensor", wires=100, method="tn")

The lightning.tensor device dispatches all operations to be performed on a CUDA-capable GPU of generation SM 7.0+ (Volta and later)
and greater. This device supports both exact and finite shots measurements. Currently, the supported differentiation methods are parameter-shift and finite-diff. Note that the MPS backend of ``lightning.tensor`` supports multi-wire gates via Matrix Product Operators (MPO).
The ``lightning.tensor`` device dispatches all operations to be performed on a CUDA-capable GPU of generation SM 7.0+
and greater (Volta and later). This device supports both exact and finite shots measurements. Currently, the supported differentiation methods are parameter-shift and finite-diff. Note that the MPS backend of ``lightning.tensor`` supports multi-wire gates via Matrix Product Operators (MPO).

The ``lightning.tensor`` device is designed for expectation value calculations. Measurements of :func:`~pennylane.probs` or :func:`~pennylane.state` return dense vectors of dimension :math:`2^{\text{n_qubits}}`, so they should only be used for small systems.

Expand All @@ -57,10 +57,10 @@ The ``lightning.tensor`` device allows users to get quantum circuit gradients us

Check out the :doc:`/lightning_tensor/installation` guide for more information.

.. seealso:: `DefaultTensor <https://docs.pennylane.ai/en/latest/code/api/pennylane.devices.default_tensor.DefaultTensor.html>`__ for a CPU only tensor network simulator device.

Note that as ``lightning.tensor`` cannot be cleaned up like other state-vector devices because the data is attached to the graph. It is recommended to create a new ``lightning.tensor`` device per circuit to ensure resources are correctly handled.

.. seealso:: `DefaultTensor <https://docs.pennylane.ai/en/latest/code/api/pennylane.devices.default_tensor.DefaultTensor.html>`__ for a CPU only tensor network simulator device.
LuisAlfredoNu marked this conversation as resolved.
Show resolved Hide resolved


Operations and observables support
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/lightning_gpu/lightning_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def check_gpu_resources() -> None:
class LightningGPU(LightningBase):
"""PennyLane Lightning GPU device.

A device that interfaces with C++ to perform fast linear algebra calculations.
A device that interfaces with C++ to perform fast linear algebra calculations on GPUs using `custatevec`.

Use of this device requires pre-built binaries or compilation from source. Check out the
:doc:`/lightning_gpu/installation` guide for more details.
Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/lightning_kokkos/lightning_kokkos.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def _kokkos_configuration():
class LightningKokkos(LightningBase):
"""PennyLane Lightning Kokkos device.

A device that interfaces with C++ to perform fast linear algebra calculations.
A device that interfaces with C++ to perform fast linear algebra calculations on CPUs or GPUs using `Kokkos`.

Use of this device requires pre-built binaries or compilation from source. Check out the
:doc:`/lightning_kokkos/installation` guide for more details.
Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/lightning_tensor/_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _measurement_dtype(self):

def state_diagonalizing_gates(self, measurementprocess: StateMeasurement) -> TensorLike:
"""Apply a measurement to state when the measurement process has an observable with diagonalizing gates.
This method is bypassing the measurement process to default.qubit implementation.
This method bypasses default.qubit's implementation of the measurement process.

Args:
measurementprocess (StateMeasurement): measurement to apply to the state
Expand Down
8 changes: 4 additions & 4 deletions pennylane_lightning/lightning_tensor/_tensornet.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ class LightningTensorNet:
be described but the larger the memory requirements. Note that GPUs are ill-suited (i.e. less
competitive compared with CPUs) for simulating circuits with low bond dimensions and/or circuit
layers with a single or few gates because the arithmetic intensity is lower.
cutoff (float): The threshold used to truncate the singular values of the MPS tensors. The default is 0.
cutoff_mode (str): Singular value truncation mode for MPS tensors. The options are ``"rel"`` and ``"abs"``. The default is ``"abs"``.
cutoff (float): The threshold used to truncate the singular values of the MPS tensors. Default is 0.
cutoff_mode (str): Singular value truncation mode for MPS tensors. Options:[``"rel"``, ``"abs"`` (default)].
"""

# pylint: disable=too-many-arguments, too-many-positional-arguments
Expand Down Expand Up @@ -177,7 +177,7 @@ def __init__(
elif self._method == "tn":
self._tensornet = self._tensornet_dtype()(self._num_wires)
else:
raise DeviceError(f"The method {self._method} is not supported.")
raise DeviceError(f"The method {self._method} is not supported. Only supported methods are mps or tn.")

@property
def dtype(self):
Expand All @@ -191,7 +191,7 @@ def device_name(self):

@property
def num_wires(self):
"""Number of wires addressed on this device"""
"""Returns the number of wires addressed on this device"""
return self._num_wires

@property
Expand Down
18 changes: 9 additions & 9 deletions pennylane_lightning/lightning_tensor/lightning_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,30 +216,30 @@ class LightningTensor(Device):
A device to perform tensor network operations on a quantum circuit.

This device is designed to simulate large-scale quantum circuits using tensor network methods. For
small circuits, other devices like ``lightning.qubit``, ``lightning.gpu``or ``lightning.kokkos`` are
small circuits, other devices like ``lightning.qubit``, ``lightning.gpu`` or ``lightning.kokkos`` are
recommended.

Currently, the Matrix Product State (MPS) and the Exact Tensor Network method are supported as implemented in the ``cutensornet`` backend.
Currently, the Matrix Product State (MPS) and the Exact Tensor Network methods are supported as implemented in the ``cutensornet`` backend.

Args:
wires (int): The number of wires to initialize the device with.
Defaults to ``None`` if not specified.
shots (int): Measurements are performed drawing ``shots`` times from a discrete random variable distribution associated with a state vector and an observable. Defaults to ``None`` if not specified. Setting
to ``None`` results in computing statistics like expectation values and
variances analytically.
method (str): Supported method. The supported methods are ``"mps"`` (Matrix Product State) and ``"tn"`` (Tensor Network).
method (str): Supported method. The supported methods are ``"mps"`` (Matrix Product State) (default) and ``"tn"`` (Exact Tensor Network).
c_dtype: Datatypes for the tensor representation. Must be one of
``numpy.complex64`` or ``numpy.complex128``. Default is ``numpy.complex128``.
Keyword Args:
max_bond_dim (int): The maximum bond dimension to be used in the MPS simulation. Default is 128.
max_bond_dim (int): (Only for ``method=mps``) The maximum bond dimension to be used in the MPS simulation. Default is 128.
The accuracy of the wavefunction representation comes with a memory tradeoff which can be
tuned with `max_bond_dim`. The larger the internal bond dimension, the more entanglement can
be described but the larger the memory requirements. Note that GPUs are ill-suited (i.e. less
competitive compared with CPUs) for simulating circuits with low bond dimensions and/or circuit
layers with a single or few gates because the arithmetic intensity is lower.
cutoff (float): The threshold used to truncate the singular values of the MPS tensors. The default is 0.
cutoff_mode (str): Singular value truncation mode for MPS tensors. The options are ``"rel"`` and ``"abs"``. The default is ``"abs"``.
backend (str): Supported backend. Currently, only ``cutensornet`` is supported.
cutoff (float): (Only for ``method=mps``) The threshold used to truncate the singular values of the MPS tensors. The default is 0.
cutoff_mode (str): (Only for ``method=mps``) Singular value truncation mode for MPS tensors. The options are ``"rel"`` and ``"abs"``. Default is ``"abs"``.
backend (str): Supported backend. Currently, only ``cutensornet`` is supported. Default is ``cutensornet``.

**Example for the MPS method**

Expand All @@ -249,7 +249,7 @@ class LightningTensor(Device):

num_qubits = 100

dev = qml.device("lightning.tensor", wires=num_qubits)
dev = qml.device("lightning.tensor", wires=num_qubits, max_bond_dim=32)

@qml.qnode(dev)
def circuit(num_qubits):
Expand All @@ -270,7 +270,7 @@ def circuit(num_qubits):

num_qubits = 100

dev = qml.device("lightning.tensor", wires=num_qubits)
dev = qml.device("lightning.tensor", wires=num_qubits, method="tn")

@qml.qnode(dev)
def circuit(num_qubits):
Expand Down
Loading