Skip to content

Commit

Permalink
Update lightning.tensor docs (#909)
Browse files Browse the repository at this point in the history
### Before submitting

Please complete the following checklist when submitting a PR:

- [ ] All new features must include a unit test.
If you've fixed a bug or added code that should be tested, add a test to
the
      [`tests`](../tests) directory!

- [ ] All new functions and code must be clearly commented and
documented.
If you do make documentation changes, make sure that the docs build and
      render correctly by running `make docs`.

- [ ] Ensure that the test suite passes, by running `make test`.

- [x] Add a new entry to the `.github/CHANGELOG.md` file, summarizing
the
      change, and including a link back to the PR.

- [x] Ensure that code is properly formatted by running `make format`. 

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


------------------------------------------------------------------------------------------------------------

**Context:**

[SC-65786] and [SC-68333]

**Description of the Change:**

**Benefits:**

**Possible Drawbacks:**

**Related GitHub Issues:**

---------

Co-authored-by: ringo-but-quantum <[email protected]>
Co-authored-by: Thomas Germain <[email protected]>
Co-authored-by: Korbinian Kottmann <[email protected]>
Co-authored-by: Amintor Dusko <[email protected]>
  • Loading branch information
5 people authored Sep 20, 2024
1 parent 05ee305 commit f833461
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@

### Documentation

* Update ``lightning.tensor`` documentation to include all the new features added since pull request #756. The new features are: 1, Finite-shot measurements; 2. Expval-base quantities; 3. Support for ``qml.state()`` and ``qml.stateprep()``; 4. Support for all gates support via Matrix Product Operator (MPO).
[(#909)](https://github.com/PennyLaneAI/pennylane-lightning/pull/909)

### Bug fixes

* Bug fix for analytic `probs` in the `lightning.tensor` C++ layer.
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET "11" CACHE STRING "Minimum OS X deployment versi
set(CMAKE_CXX_STANDARD 20) # At least C++20 is required

project(pennylane_lightning
DESCRIPTION "C++ suite of state-vector simulators bindings for PennyLane. "
DESCRIPTION "C++ suite of state-vector and tensor network simulators bindings for PennyLane. "
LANGUAGES CXX
)

Expand Down
5 changes: 2 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Lightning Plugins

.. header-start-inclusion-marker-do-not-remove
The Lightning plugin ecosystem provides fast state-vector simulators written in C++.
The Lightning plugin ecosystem provides fast state-vector and tensor network 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.
Expand All @@ -49,8 +49,7 @@ 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://docs.amd.com/projects/HIP/en/docs-5.3.0/index.html>`_ 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). This device is designed to simulate large-scale quantum circuits using tensor networks. For small circuits, state-vector simulator plugins may be more suitable. The supported method is Matrix Product State (MPS). This device does not currently support finite shots. Currently, the supported measurement types are expectation values and the supported differentiation methods are ``parameter-shift`` and ``finite-diff``. Note that only 1,2-wire gates and gates that can be decomposed by PennyLane into 1,2-wire gates are supported.

* ``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 method is Matrix Product State (MPS).
.. header-end-inclusion-marker-do-not-remove
The following table summarizes the supported platforms and the primary installation mode:
Expand Down
46 changes: 15 additions & 31 deletions doc/lightning_tensor/device.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Lightning Tensor device
=======================

The ``lightning.tensor`` device is a tensor network simulator device. The device is built on top of the `cutensornet <https://docs.nvidia.com/cuda/cuquantum/latest/cutensornet/index.html>`__ from the NVIDIA cuQuantum SDK, enabling GPU-accelerated simulation of quantum tensor network evolution.
The ``lightning.tensor`` device is a tensor network simulator device. The device is built on top of the `cutensornet <https://docs.nvidia.com/cuda/cuquantum/latest/cutensornet/index.html>`__ from the NVIDIA cuQuantum SDK, enabling GPU-accelerated simulation of quantum tensor network evolution. This device is designed to simulate large-scale quantum circuits using tensor networks. For small circuits, state-vector simulator plugins may be more suitable.

A ``lightning.tensor`` device can be loaded simply using:

Expand All @@ -14,17 +14,15 @@ By default, the device represents the quantum state approximated as a Matrix Pro
The default setup for the MPS tensor network approximation is:
- ``max_bond_dim`` (maximum bond dimension) defaults to ``128`` .
- ``cutoff`` (singular value truncation threshold) defaults to ``0`` .
- ``cutoff_mode`` (singular value truncation mode) defaults to ``abs`` , considering the absolute values of the singular values; Alternatively, users can opt to set ``cutoff_mode`` to ``rel`` to consider the relative values of the singular values.
- ``cutoff_mode`` (singular value truncation mode) defaults to ``abs`` , considering the absolute values of the singular values; Alternatively, users can opt to set ``cutoff_mode`` to ``rel`` to consider the relative values of the singular values.
Note that the ``cutensornet`` will automatically determine the reduced extent of the bond dimension based on the lowest among the multiple truncation cutoffs (``max_bond_dim``, ``cutoff-abs`` and ``cutoff-rel``). For more details on how the ``cutoff`` works, please check it out the `cuQuantum documentation <https://docs.nvidia.com/cuda/cuquantum/latest/cutensornet/api/types.html#cutensornettensorsvdconfigattributes-t>`__.

The ``lightning.tensor`` device dispatches all operations to be performed on a CUDA-capable GPU of generation SM 7.0 (Volta)
and greater.
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).

.. note::
Given the inherent parallelism of GPUs, simulations with intensive parallel computation, such as those with larger maximum
bond dimensions, stand to gain the most from the computational power offered by GPU and those simulations can benifit from the
``lightning.tensor`` device. It's worth noting that if the bond dimension used in the simulation is small, the ``lightning.tensor``
device with ``MPS`` running a GPU may perform slower compared to a ``default.tensor`` device with ``MPS`` running on a CPU. For more details
on how bond dimension affects the simulation performance, please refer to the ``Approximate Tensor Network Methods`` section in the `cuQuantum SDK <https://developer.nvidia.com/cuquantum-sdk>`__.
The ``lightning.tensor`` device is designed for expectation value calculations. Measurements of ``qml.probs()`` or ``qml.state()`` return dense vectors of dimension :math:`2^{n_\text{qubits}}`, so they should only be used for small systems.

.. note:: ``qml.Hermitian`` is currently only supported for single wires. You can use ``qml.pauli_decompose`` on smaller matrices to obtain a compatible Pauli decomposition in the meantime. As a result, it is advisable to disable ``new_opmath`` for the ``lightning.tensor`` device to prevent the implicit conversion of Pauli words to multi-wire Hermitian observables. This limitation will be addressed once multi-wires Hermitian observables can be supported with ``cutensornet``.

Users also have the flexibility to customize these parameters according to their specific needs with:

Expand Down Expand Up @@ -58,7 +56,7 @@ Check out the :doc:`/lightning_tensor/installation` guide for more information.
Operations and observables support
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The "lightning.tensor" supports 1- and 2-wire gate operations and all other operations that can be decomposed to that by PennyLane.
The "lightning.tensor" supports all gate operations supported by PennyLane.

**Supported operations:**

Expand All @@ -70,6 +68,7 @@ The "lightning.tensor" supports 1- and 2-wire gate operations and all other oper
:nosignatures:

~pennylane.BasisState
~pennylane.BlockEncode
~pennylane.CNOT
~pennylane.ControlledPhaseShift
~pennylane.ControlledQubitUnitary
Expand All @@ -82,7 +81,10 @@ The "lightning.tensor" supports 1- and 2-wire gate operations and all other oper
~pennylane.CZ
~pennylane.DiagonalQubitUnitary
~pennylane.DoubleExcitation
~pennylane.DoubleExcitationMinus
~pennylane.DoubleExcitationPlus
~pennylane.ECR
~pennylane.GlobalPhase
~pennylane.Hadamard
~pennylane.Identity
~pennylane.IsingXX
Expand All @@ -98,6 +100,7 @@ The "lightning.tensor" supports 1- and 2-wire gate operations and all other oper
~pennylane.PSWAP
~pennylane.QFT
~pennylane.QubitCarry
~pennylane.QubitStateVector
~pennylane.QubitSum
~pennylane.QubitUnitary
~pennylane.Rot
Expand All @@ -108,6 +111,7 @@ The "lightning.tensor" supports 1- and 2-wire gate operations and all other oper
~pennylane.SingleExcitation
~pennylane.SingleExcitationMinus
~pennylane.SingleExcitationPlus
~pennylane.StatePrep
~pennylane.SISWAP
~pennylane.SQISW
~pennylane.SWAP
Expand All @@ -119,30 +123,10 @@ The "lightning.tensor" supports 1- and 2-wire gate operations and all other oper

</div>

**Unsupported operations:**

.. raw:: html

<div class="summary-table">

.. autosummary::
:nosignatures:

~pennylane.StatePrep
~pennylane.QubitStateVector
~pennylane.DoubleExcitationMinus
~pennylane.DoubleExcitationPlus
~pennylane.GlobalPhase
~pennylane.BlockEncode


.. raw:: html

</div>

**Supported observables:**

The ``lightning.tensor`` supports all observables supported by the Lightning state-vector simulators, besides ``qml.SparseHamiltonian``, ``qml.Projector`` and limited support to ``qml.Hamiltonian``, ``qml.Prod``.
The ``lightning.tensor`` supports all observables supported by the Lightning state-vector simulators, besides ``qml.SparseHamiltonian``, ``qml.Projector`` and limited support to ``qml.Hamiltonian``, ``qml.Prod`` since ``lightning.tensor`` only supports 1-wire Hermitian observables.

Users can not create a ``Hamiltonian`` or ``Prod`` observable from ``Hamiltonian`` observables.

Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.39.0-dev28"
__version__ = "0.39.0-dev29"

0 comments on commit f833461

Please sign in to comment.