MPSPureState#

class cuquantum.densitymat.MPSPureState(ctx, hilbert_space_dims, bond_dims, batch_size, dtype)[source]#

Pure state in MPS (Matrix Product State) factorized representation.

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

  • Leftmost site (i=0): (phys, bond_right)

  • Interior sites: (bond_left, phys, bond_right)

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

Here phys has 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.

A storage buffer needs to be attached via the attach_storage() method or allocated via the allocate_storage() method. The appropriate sizes for the storage buffers as well as information on the storage layout are available in the local_info attribute.

Parameters:
  • ctx – The execution context, which contains information on device ID, logging and blocking/non-blocking execution.

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

  • bond_dims – A tuple of the bond dimensions. For open boundary conditions, the length must be equal to the number of space modes minus one.

  • batch_size – Batch dimension of the state.

  • dtype – Numeric data type of the state’s coefficients.

Examples

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

To create an MPSPureState of batch size 1 and double-precision complex data type

>>> ctx = WorkStream(stream=cp.cuda.Stream())
>>> hilbert_space_dims = (2, 2, 2)
>>> bond_dims = (4, 4)
>>> psi = MPSPureState(ctx, hilbert_space_dims, bond_dims, 1, "complex128")
>>> psi.allocate_storage()

Methods

__init__(
ctx: WorkStream,
hilbert_space_dims: Sequence[int],
bond_dims: Sequence[int],
batch_size: int,
dtype: str,
) None[source]#

Initialize a pure state in MPS factorized representation.

allocate_storage() None[source]#

Allocate appropriately sized data buffers and attach them to the state.

attach_storage(data: List[ndarray]) None[source]#

Attach data buffers to the state, one per component.

Parameters:

data – A list of data buffers, one per MPS component tensor.

Note

Each data buffer needs to match the corresponding component’s expected size and data type. All buffers need to be Fortran contiguous and located on the same device as the WorkStream passed to the __init__ function.

clone(
bufs: List[ndarray],
) FactorizedState[source]#

Clone the state with new data buffers.

Parameters:

bufs – A list of data buffers, one per MPS component tensor.

Returns:

A state with same metadata as the original state and new data buffers.

inner_product(other) ndarray[source]#

Compute the inner product(s) between two states.

Parameters:

other – The other state to compute inner product with.

Returns:

An array of inner product(s) of length batch_size.

inplace_accumulate(
other,
factors: Number | Sequence | ndarray | ndarray = 1,
) None[source]#

Inplace accumulate another state scaled by factor(s) into this state.

Parameters:
  • other – The other state to be scaled and accumulated into this state.

  • factors – Scalar factor(s) used in scaling other. If a single number is provided, scale all batched states in other by the same factor. Defaults to 1.

inplace_scale(
factors: Number | Sequence | ndarray | ndarray,
) None[source]#

Scale the state by scalar factor(s).

Parameters:

factors – Scalar factor(s) used in scaling the state. If a single number is provided, scale all batched states by the same factor.

norm() ndarray[source]#

Compute the squared Frobenius norm(s) of the state.

Returns:

An array of squared Frobenius norm(s) of length batch_size.

trace() ndarray[source]#

Compute the trace(s) of the state.

Returns:

An array of trace(s) of length batch_size.

Attributes

local_info#

Local storage buffer dimensions and mode offsets for each component.

Returns:

A list of (mode_extents, mode_offsets) tuples, one per component.

Return type:

List[Tuple[Tuple[int], Tuple[int]]]

storage#

The state’s local storage buffers, one per MPS component tensor.

Returns:

A list of the state’s local storage buffers.

Return type:

List[cp.ndarray]

storage_sizes#

Storage buffer sizes in number of elements of data type dtype, one per component.

Returns:

Storage buffer sizes in number of elements of data type dtype.

Return type:

List[int]