Skip to content

Commit

Permalink
Add Exact TN to docs (#1021)
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-72893]

**Description of the Change:**

**Benefits:**

**Possible Drawbacks:**

**Related GitHub Issues:**

---------

Co-authored-by: ringo-but-quantum <[email protected]>
Co-authored-by: Ali Asadi <[email protected]>
Co-authored-by: ANTH0NY <[email protected]>
  • Loading branch information
4 people authored Dec 13, 2024
1 parent 954a6e7 commit e9a3b80
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@

### Documentation

* Add the exact tensor network to the Lightning-Tensor docs.
[(#1021)](https://github.com/PennyLaneAI/pennylane-lightning/pull/1021)

* Update Lightning-Tensor installation docs and usage suggestions.
[(#979)](https://github.com/PennyLaneAI/pennylane-lightning/pull/979)

Expand Down
41 changes: 23 additions & 18 deletions doc/lightning_tensor/device.rst
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
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. 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 ``lightning.tensor`` device is a tensor network simulator, supporting both the Matrix Product State (MPS) and Exact Tensor Network methods. 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:
The ``lightning.tensor`` device defaults to the Matrix Product State (MPS) method, and can be loaded using:

.. code-block:: python
import pennylane as qml
dev = qml.device("lightning.tensor", wires=100)
By default, the device represents the quantum state approximated as a Matrix Product State (MPS).
By default, the device approximates the quantum state using an MPS.
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.
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>`__.
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 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. 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 ``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.

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

.. code-block:: python
import pennylane as qml
import numpy as np
num_qubits = 100
Expand All @@ -41,7 +33,21 @@ Users also have the flexibility to customize these parameters according to their
dev = qml.device("lightning.tensor", wires=num_qubits, method="mps", **device_kwargs_mps)
The ``lightning.tensor`` device allows users to get quantum circuit gradients using the ``parameter-shift`` method. This can be enabled at the PennyLane ``QNode`` level with:
Users can also run the ``lightning.tensor`` device in the **Exact Tensor Network** mode by setting the ``method`` argument to ``"tn"``:

.. code-block:: python
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 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.

.. note:: Currently only single-wire :class:`~pennylane.Hermitian` observables are supported. You can use :func:`~pennylane.pauli_decompose` on smaller matrices to obtain a compatible Pauli decomposition in the meantime.

The ``lightning.tensor`` device allows users to get quantum circuit gradients using the :func:`~pennylane.gradients.param_shift` method. This can be enabled at the PennyLane :class:`~pennylane.QNode` level with:

.. code-block:: python
Expand All @@ -59,7 +65,7 @@ Note that as ``lightning.tensor`` cannot be cleaned up like other state-vector d
Operations and observables support
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The "lightning.tensor" supports all gate operations supported by PennyLane.
The ``lightning.tensor`` supports all gate operations supported by PennyLane, with the exception of :class:`~pennylane.StatePrep`, which is *not supported* by the *Exact Tensor Network* method.

**Supported operations:**

Expand Down Expand Up @@ -128,9 +134,9 @@ The "lightning.tensor" supports all gate operations supported by PennyLane.

**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`` since ``lightning.tensor`` only supports 1-wire Hermitian observables.
The ``lightning.tensor`` supports all observables supported by the Lightning state-vector simulators, besides :class:`~pennylane.SparseHamiltonian`, :class:`~pennylane.Projector` and limited support to :class:`~pennylane.ops.op_math.Sum`, :class:`~pennylane.ops.op_math.Prod` since ``lightning.tensor`` only supports 1-wire :class:`~pennylane.Hermitian` observables.

Users can not create a ``Hamiltonian`` or ``Prod`` observable from ``Hamiltonian`` observables.
Users cannot create a :class:`~pennylane.ops.op_math.Sum` observable or a :class:`~pennylane.ops.op_math.Prod` observable from :class:`~pennylane.ops.op_math.Sum` observables.



Expand All @@ -143,7 +149,6 @@ Users can not create a ``Hamiltonian`` or ``Prod`` observable from ``Hamiltonian

~pennylane.ops.op_math.Exp
~pennylane.Hadamard
~pennylane.Hamiltonian
~pennylane.Hermitian
~pennylane.Identity
~pennylane.PauliX
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.40.0-dev35"
__version__ = "0.40.0-dev36"

0 comments on commit e9a3b80

Please sign in to comment.