MatrixProductOperator#

class cuquantum.densitymat.MatrixProductOperator(
tensor_data,
hilbert_space_dims,
bond_dims,
callbacks=None,
gradient_callbacks=None,
)[source]#

Matrix product operator (MPO) defined by a chain of tensors acting on a tensor product Hilbert space.

Each site tensor has up to 4 modes with the following ordering (Fortran contiguous):

  • Leftmost site (i=0): (phys_ket, bond_right, phys_bra)

  • Interior sites: (bond_left, phys_ket, bond_right, phys_bra)

  • Rightmost site (i=N-1): (bond_left, phys_ket, phys_bra)

Here phys_ket and phys_bra have the extent of the local Hilbert space dimension at that site, while bond_left and bond_right have the extents of the corresponding bond dimensions.

Parameters:
  • tensor_data – A list of GPU data buffers (cp.ndarray), one per site tensor of the MPO. Each tensor must be Fortran contiguous.

  • hilbert_space_dims – A tuple of the local Hilbert space dimensions.

  • bond_dims – A tuple of the bond dimensions between adjacent sites. For open boundary conditions, the length must be equal to len(hilbert_space_dims) - 1.

  • callbacks – An optional list of GPUCallback instances (or None entries), one per site tensor.

  • gradient_callbacks – An optional list of GPUCallback instances (or None entries), one per site tensor.

Examples

>>> import cupy as cp
>>> from cuquantum.densitymat import WorkStream, MatrixProductOperator

Construct an MPO for a 3-site system with local dimension 2 and bond dimension 4

>>> hilbert_space_dims = (2, 2, 2)
>>> bond_dims = (4, 4)
>>> tensors = [
...     cp.zeros((2, 4, 2), dtype="complex128", order="F"),    # left boundary:  (d_ket, bond_R, d_bra)
...     cp.zeros((4, 2, 4, 2), dtype="complex128", order="F"), # bulk:           (bond_L, d_ket, bond_R, d_bra)
...     cp.zeros((4, 2, 2), dtype="complex128", order="F"),    # right boundary: (bond_L, d_ket, d_bra)
... ]
>>> mpo = MatrixProductOperator(tensors, hilbert_space_dims, bond_dims)

Methods

__init__(
tensor_data: List[ndarray],
hilbert_space_dims: Sequence[int],
bond_dims: Sequence[int],
callbacks: List[GPUCallback | None] | None = None,
gradient_callbacks: List[GPUCallback | None] | None = None,
) None[source]#

Attributes

data#

The list of MPO tensor data buffers, one per site.

device_id#

Device ID of the tensor data.

has_gradient#

Whether any site tensor has a gradient callback.

num_sites#

Number of sites in the MPO.