Lightning Tensor device

The lightning.tensor device is a tensor network simulator device. 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.

A lightning.tensor device can be loaded simply using:

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.

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.

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 \(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:

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:

@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.

Supported operations:

BasisState

Prepares a single computational basis state.

BlockEncode

Construct a unitary \(U(A)\) such that an arbitrary matrix \(A\) is encoded in the top-left block.

CNOT

The controlled-NOT operator

ControlledPhaseShift

A qubit controlled phase shift.

ControlledQubitUnitary

Apply an arbitrary fixed unitary to wires with control from the control_wires.

CRot

The controlled-Rot operator

CRX

The controlled-RX operator

CRY

The controlled-RY operator

CRZ

The controlled-RZ operator

CSWAP

The controlled-swap operator

CY

The controlled-Y operator

CZ

The controlled-Z operator

DiagonalQubitUnitary

Apply an arbitrary diagonal unitary matrix with a dimension that is a power of two.

DoubleExcitation

Double excitation rotation.

DoubleExcitationMinus

Double excitation rotation with negative phase-shift outside the rotation subspace.

DoubleExcitationPlus

Double excitation rotation with positive phase-shift outside the rotation subspace.

ECR

An echoed RZX(pi/2) gate.

GlobalPhase

A global phase operation that multiplies all components of the state by \(e^{-i \phi}\).

Hadamard

The Hadamard operator

Identity

The Identity operator

IsingXX

Ising XX coupling gate

IsingXY

Ising (XX + YY) coupling gate

IsingYY

Ising YY coupling gate

IsingZZ

Ising ZZ coupling gate

ISWAP

The i-swap operator

OrbitalRotation

Spin-adapted spatial orbital rotation.

PauliX

The Pauli X operator

PauliY

The Pauli Y operator

PauliZ

The Pauli Z operator

PhaseShift

Arbitrary single qubit local phase shift

PSWAP

Phase SWAP gate

QFT

Apply a quantum Fourier transform (QFT).

QubitCarry

Apply the QubitCarry operation to four input wires.

QubitStateVector

QubitSum

Apply a QubitSum operation on three input wires.

QubitUnitary

Apply an arbitrary unitary matrix with a dimension that is a power of two.

Rot

Arbitrary single qubit rotation

RX

The single qubit X rotation

RY

The single qubit Y rotation

RZ

The single qubit Z rotation

S

The single-qubit phase gate

SingleExcitation

Single excitation rotation.

SingleExcitationMinus

Single excitation rotation with negative phase-shift outside the rotation subspace.

SingleExcitationPlus

Single excitation rotation with positive phase-shift outside the rotation subspace.

StatePrep

Prepare subsystems using the given ket vector in the computational basis.

SISWAP

The square root of i-swap operator.

SQISW

alias of SISWAP

SWAP

The swap operator

SX

The single-qubit Square-Root X operator.

T

The single-qubit T gate

Toffoli

Toffoli (controlled-controlled-X) gate.

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.

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

Exp

A symbolic operator representing the exponential of a operator.

Hadamard

The Hadamard operator

Hamiltonian

alias of LinearCombination

Hermitian

An arbitrary Hermitian observable.

Identity

The Identity operator

PauliX

The Pauli X operator

PauliY

The Pauli Y operator

PauliZ

The Pauli Z operator

Prod

Symbolic operator representing the product of operators.

SProd

Arithmetic operator representing the scalar product of an operator with the given scalar.

Sum

Symbolic operator representing the sum of operators.

Unsupported observables:

SparseHamiltonian

A Hamiltonian represented directly as a sparse matrix in Compressed Sparse Row (CSR) format.

Projector

Observable corresponding to the state projector \(P=\ket{\phi}\bra{\phi}\).