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 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:
import pennylane as qml
dev = qml.device("lightning.tensor", wires=100)
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 to128
.
cutoff
(singular value truncation threshold) defaults to0
.
cutoff_mode
(singular value truncation mode) defaults toabs
, considering the absolute values of the singular values; Alternatively, users can opt to setcutoff_mode
torel
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.
Users also have the flexibility to customize MPS parameters according to their specific needs with:
import pennylane as qml
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)
Users can also run the lightning.tensor
device in the Exact Tensor Network mode by setting the method
argument to "tn"
:
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 probs()
or state()
return dense vectors of dimension \(2^{\text{n_qubits}}\), so they should only be used for small systems.
Note
Currently only single-wire Hermitian
observables are supported. You can use 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 param_shift()
method. This can be enabled at the PennyLane QNode
level with:
@qml.qnode(dev, diff_method="parameter-shift")
def circuit(params):
...
Check out the Lightning-Tensor installation guide for more information.
See also
DefaultTensor 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.
Operations and observables support¶
The lightning.tensor
supports all gate operations supported by PennyLane, with the exception of StatePrep
, which is not supported by the Exact Tensor Network method.
Supported operations:
Prepares a single computational basis state. |
|
Construct a unitary \(U(A)\) such that an arbitrary matrix \(A\) is encoded in the top-left block. |
|
The controlled-NOT operator |
|
A qubit controlled phase shift. |
|
Apply an arbitrary fixed unitary to |
|
The controlled-Rot operator |
|
The controlled-RX operator |
|
The controlled-RY operator |
|
The controlled-RZ operator |
|
The controlled-swap operator |
|
The controlled-Y operator |
|
The controlled-Z operator |
|
Apply an arbitrary diagonal unitary matrix with a dimension that is a power of two. |
|
Double excitation rotation. |
|
Double excitation rotation with negative phase-shift outside the rotation subspace. |
|
Double excitation rotation with positive phase-shift outside the rotation subspace. |
|
An echoed RZX(\(\pi/2\)) gate. |
|
A global phase operation that multiplies all components of the state by \(e^{-i \phi}\). |
|
The Hadamard operator |
|
The Identity operator |
|
Ising XX coupling gate |
|
Ising (XX + YY) coupling gate |
|
Ising YY coupling gate |
|
Ising ZZ coupling gate |
|
The i-swap operator |
|
Spin-adapted spatial orbital rotation. |
|
The Pauli X operator |
|
The Pauli Y operator |
|
The Pauli Z operator |
|
Arbitrary single qubit local phase shift |
|
Phase SWAP gate |
|
Apply a quantum Fourier transform (QFT). |
|
Apply the |
|
Apply a |
|
Apply an arbitrary unitary matrix with a dimension that is a power of two. |
|
Arbitrary single qubit rotation |
|
The single qubit X rotation |
|
The single qubit Y rotation |
|
The single qubit Z rotation |
|
The single-qubit phase gate |
|
Single excitation rotation. |
|
Single excitation rotation with negative phase-shift outside the rotation subspace. |
|
Single excitation rotation with positive phase-shift outside the rotation subspace. |
|
Prepare subsystems using the given ket vector in the computational basis. |
|
The square root of i-swap operator. |
|
alias of |
|
The swap operator |
|
The single-qubit Square-Root X operator. |
|
The single-qubit T gate |
|
Toffoli (controlled-controlled-X) gate. |
Supported observables:
The lightning.tensor
supports all observables supported by the Lightning state-vector simulators, besides SparseHamiltonian
, Projector
and limited support to Sum
, Prod
since lightning.tensor
only supports 1-wire Hermitian
observables.
Users cannot create a Sum
observable or a Prod
observable from Sum
observables.
A symbolic operator representing the exponential of a operator. |
|
The Hadamard operator |
|
An arbitrary Hermitian observable. |
|
The Identity operator |
|
The Pauli X operator |
|
The Pauli Y operator |
|
The Pauli Z operator |
|
Symbolic operator representing the product of operators. |
|
Arithmetic operator representing the scalar product of an operator with the given scalar. |
|
Symbolic operator representing the sum of operators. |
Unsupported observables:
A Hamiltonian represented directly as a sparse matrix in Compressed Sparse Row (CSR) format. |
|
Observable corresponding to the state projector \(P=\ket{\phi}\bra{\phi}\). |