-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### 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! - [x] 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:** Add `lightning.tensor` documentation. The requirement of this doc is `Basic documentation and developer-facing notes` [SC-62441] **Description of the Change:** **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:** --------- Co-authored-by: ringo-but-quantum <[email protected]> Co-authored-by: Mudit Pandey <[email protected]> Co-authored-by: Vincent Michaud-Rioux <[email protected]> Co-authored-by: Ali Asadi <[email protected]> Co-authored-by: Vincent Michaud-Rioux <[email protected]> Co-authored-by: Amintor Dusko <[email protected]> Co-authored-by: Korbinian Kottmann <[email protected]> Co-authored-by: Pietropaolo Frisoni <[email protected]>
- Loading branch information
1 parent
f15665c
commit 52710ff
Showing
12 changed files
with
288 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
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. | ||
|
||
A ``lightning.tensor`` device can be loaded simply 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). | ||
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. | ||
|
||
The ``lightning.tensor`` device dispatches all operations to be performed on a CUDA-capable GPU of generation SM 7.0 (Volta) | ||
and greater. | ||
|
||
.. 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>`__. | ||
|
||
Users also have the flexibility to customize these parameters according to their specific needs with: | ||
|
||
.. code-block:: python | ||
import pennylane as qml | ||
import numpy as np | ||
num_qubits = 100 | ||
device_kwargs_mps = { | ||
"max_bond_dim": 64, | ||
"cutoff": 1e-10, | ||
"cutoff_mode": "abs", | ||
} | ||
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: | ||
|
||
.. code-block:: python | ||
@qml.qnode(dev, diff_method="parameter-shift") | ||
def circuit(params): | ||
... | ||
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. | ||
|
||
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. | ||
|
||
**Supported operations:** | ||
|
||
.. raw:: html | ||
|
||
<div class="summary-table"> | ||
|
||
.. autosummary:: | ||
:nosignatures: | ||
|
||
~pennylane.BasisState | ||
~pennylane.BlockEncode | ||
~pennylane.CNOT | ||
~pennylane.ControlledPhaseShift | ||
~pennylane.ControlledQubitUnitary | ||
~pennylane.CRot | ||
~pennylane.CRX | ||
~pennylane.CRY | ||
~pennylane.CRZ | ||
~pennylane.CSWAP | ||
~pennylane.CY | ||
~pennylane.CZ | ||
~pennylane.DiagonalQubitUnitary | ||
~pennylane.DoubleExcitation | ||
~pennylane.ECR | ||
~pennylane.Hadamard | ||
~pennylane.Identity | ||
~pennylane.IsingXX | ||
~pennylane.IsingXY | ||
~pennylane.IsingYY | ||
~pennylane.IsingZZ | ||
~pennylane.ISWAP | ||
~pennylane.OrbitalRotation | ||
~pennylane.PauliX | ||
~pennylane.PauliY | ||
~pennylane.PauliZ | ||
~pennylane.PhaseShift | ||
~pennylane.PSWAP | ||
~pennylane.QFT | ||
~pennylane.QubitCarry | ||
~pennylane.QubitSum | ||
~pennylane.QubitUnitary | ||
~pennylane.Rot | ||
~pennylane.RX | ||
~pennylane.RY | ||
~pennylane.RZ | ||
~pennylane.S | ||
~pennylane.SingleExcitation | ||
~pennylane.SingleExcitationMinus | ||
~pennylane.SingleExcitationPlus | ||
~pennylane.SISWAP | ||
~pennylane.SQISW | ||
~pennylane.SWAP | ||
~pennylane.SX | ||
~pennylane.T | ||
~pennylane.Toffoli | ||
|
||
.. raw:: html | ||
|
||
</div> | ||
|
||
**Unsupported operations:** | ||
|
||
.. raw:: html | ||
|
||
<div class="summary-table"> | ||
|
||
.. autosummary:: | ||
:nosignatures: | ||
|
||
~pennylane.StatePrep | ||
~pennylane.QubitStateVector | ||
~pennylane.DoubleExcitationMinus | ||
~pennylane.DoubleExcitationPlus | ||
~pennylane.GlobalPhase | ||
|
||
.. 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``. | ||
|
||
Users can not create a ``Hamiltonian`` or ``Prod`` observable from ``Hamiltonian`` observables. | ||
|
||
|
||
|
||
.. raw:: html | ||
|
||
<div class="summary-table"> | ||
|
||
.. autosummary:: | ||
:nosignatures: | ||
|
||
~pennylane.ops.op_math.Exp | ||
~pennylane.Hadamard | ||
~pennylane.Hamiltonian | ||
~pennylane.Hermitian | ||
~pennylane.Identity | ||
~pennylane.PauliX | ||
~pennylane.PauliY | ||
~pennylane.PauliZ | ||
~pennylane.ops.op_math.Prod | ||
~pennylane.ops.op_math.SProd | ||
~pennylane.ops.op_math.Sum | ||
|
||
.. raw:: html | ||
|
||
</div> | ||
|
||
**Unsupported observables:** | ||
|
||
.. raw:: html | ||
|
||
<div class="summary-table"> | ||
|
||
.. autosummary:: | ||
:nosignatures: | ||
|
||
~pennylane.SparseHamiltonian | ||
~pennylane.Projector | ||
|
||
.. raw:: html | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.. include:: ../../README.rst | ||
:start-after: installation_LTensor-start-inclusion-marker-do-not-remove | ||
:end-before: installation_LTensor-end-inclusion-marker-do-not-remove |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
lightning_tensor | ||
================ | ||
|
||
.. automodapi:: pennylane_lightning.lightning_tensor | ||
:no-heading: | ||
:include-all-objects: | ||
|
||
.. raw:: html | ||
|
||
<div style='clear:both'></div> | ||
</br> | ||
|
||
Directly importing the device class: | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. code-block:: python3 | ||
from pennylane_lightning.lightning_tensor import LightningTensor | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ | |
Version number (major.minor.patch[-label]) | ||
""" | ||
|
||
__version__ = "0.37.0-dev35" | ||
__version__ = "0.37.0-dev36" |
Oops, something went wrong.