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 all 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
83 changes: 39 additions & 44 deletions README.rst

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions doc/lightning_gpu/device.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ Supported operations and observables
~pennylane.PauliZ
~pennylane.PhaseShift
~pennylane.PSWAP
~pennylane.QFT
~pennylane.QubitCarry
~pennylane.QubitSum
~pennylane.QubitUnitary
Expand Down Expand Up @@ -142,7 +141,7 @@ Each problem is unique, so it can often be best to choose the default behaviour

**Multi-GPU/multi-node support:**

The ``lightning.gpu`` device allows users to leverage the computational power of many GPUs sitting on separate nodes for running large-scale simulations.
The ``lightning.gpu`` device allows users to leverage the computational power of many GPUs distributed across multiple nodes for running large-scale simulations.
LuisAlfredoNu marked this conversation as resolved.
Show resolved Hide resolved
Provided that NVIDIA ``cuQuantum`` libraries, a ``CUDA-aware MPI`` library and ``mpi4py`` are properly installed and the path to the ``libmpi.so`` is
added to the ``LD_LIBRARY_PATH`` environment variable, the following requirements should be met to enable multi-node and multi-GPU simulations:

Expand Down Expand Up @@ -282,4 +281,4 @@ To enable the memory-optimized adjoint method with MPI support, ``batch_obs`` sh
For the adjoint method, each MPI process will provide the overall simulation results.

.. note::
The observable ``Projector``` does not have support with the multi-GPU backend.
The observable ``Projector`` does not have support with the multi-GPU backend.
1 change: 0 additions & 1 deletion doc/lightning_kokkos/device.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ Supported operations and observables
~pennylane.PauliZ
~pennylane.PhaseShift
~pennylane.PSWAP
~pennylane.QFT
~pennylane.QubitCarry
~pennylane.QubitSum
~pennylane.QubitUnitary
Expand Down
1 change: 0 additions & 1 deletion doc/lightning_qubit/device.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ Supported operations and observables
~pennylane.PauliZ
~pennylane.PhaseShift
~pennylane.PSWAP
~pennylane.QFT
~pennylane.QubitCarry
~pennylane.QubitSum
~pennylane.QubitUnitary
Expand Down
15 changes: 7 additions & 8 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, 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.
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>`__ library 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 defaults to the Matrix Product State (MPS) method, and can be loaded using:

Expand All @@ -15,7 +15,7 @@ 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 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`` or ``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>`__.

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

Expand All @@ -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,15 +57,15 @@ 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 ``lightning.tensor`` cannot be cleaned up like other state-vector devices since 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.

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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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.
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 @@ -107,7 +107,6 @@ The ``lightning.tensor`` supports all gate operations supported by PennyLane, wi
~pennylane.PauliZ
~pennylane.PhaseShift
~pennylane.PSWAP
~pennylane.QFT
~pennylane.QubitCarry
~pennylane.QubitSum
~pennylane.QubitUnitary
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-rc2"
__version__ = "0.40.0-rc3"
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
10 changes: 6 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 @@
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,9 @@
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(

Check warning on line 180 in pennylane_lightning/lightning_tensor/_tensornet.py

View check run for this annotation

Codecov / codecov/patch

pennylane_lightning/lightning_tensor/_tensornet.py#L180

Added line #L180 was not covered by tests
f"The method {self._method} is not supported. Only supported methods are mps or tn."
)

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

@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