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
physhas the extent of the local Hilbert space dimension at that site, whilebond_leftandbond_righthave the extents of the corresponding bond dimensions.A storage buffer needs to be attached via the
attach_storage()method or allocated via theallocate_storage()method. The appropriate sizes for the storage buffers as well as information on the storage layout are available in thelocal_infoattribute.- 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
MPSPureStateof 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,
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
WorkStreampassed to the__init__function.
- clone( ) 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( ) 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 inotherby the same factor. Defaults to 1.
- inplace_scale( ) 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.
- 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]