workbench_algorithms.experimental.subroutines.mps_prep.mps_utils
Utility functions for MPS loading.
HouseHolderUnitarySynthesisData
dataclass
HouseHolderUnitarySynthesisData(
isometry: [list, np.ndarray],
bits_of_precision: int,
physical_dim: [int, None],
)
Data for specifying a Householder unitary synthesis.
Only meant to be a container for a couple of attributes for the sake of simplifying the compute signature of the HouseHolderUnitarySynthesis Qubrick.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
isometry
|
[list, numpy]
|
The isometry matrix to be synthesized. |
required |
bits_of_precision
|
int
|
the number of precision bits to use in synthesizing each column of unitary matrix (per site) |
required |
physical_dim
|
(None, int)
|
If |
required |
MPSPrepData
dataclass
Data for specifying a matrix product state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mps_tensors
|
Iterable
|
MPS tensors from DMRG calculations |
required |
bits_of_precision
|
int
|
the number of precision bits to use in synthesizing each column of unitary matrix (per site) |
required |
Note
- Input MPS tensors need to be reshaped to be fed into a loading circuit
ceillog
Ceiling log.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s
|
float
|
value to which to take ceil log |
required |
split
Split a matrix M via SVD and keep only the bond_dim largest entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
M
|
array
|
Input array |
required |
d
|
int
|
Physical dimension |
required |
bond_dim
|
int
|
Bond dimension |
required |
splitleft
Split a matrix M via SVD and keep only the bond_dim largest entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
M
|
array
|
Input array |
required |
d
|
int
|
Physical dimension |
required |
bond_dim
|
int
|
Bond dimension |
required |
make_left_canonical
Make MPS tensors into left canonical form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mps
|
array
|
Input MPS tensors |
required |
reshape_last_tensor
Fuse the physical-bond indices of every MPS tensor into 2-D matrices and pad the final site.
The routine converts a left-canonical matrix-product state
mps = [A₀, A₁, …, A_{n−1}] where each tensor has shape
(χ_left, d, χ_right) into a list of two-dimensional arrays
[M₀, M₁, …, M_{n−1}] suitable for subsequent right-to-left
contractions or for a loader that expects this layout:
M₀– column vector of shape(d·χ₁, 1)obtained by squeezingA₀and fusing its physical (size d) and right-bond indices.Mᵢ– for each interior site1 ≤ i < n−1, a matrix of shape(d·χ_{i+1}, χᵢ)equal toAᵢ.reshape(χᵢ, d·χ_{i+1}).T.M_{n−1}– the last tensor, first reshaped/transposed as above ((d′, χ_last)) and then expanded to(d′·χ_last, χ_last)by insertingχ_last − 1rows of zeros between successive physical rows. This zero-padding ensures that each physical basis block starts at an address that is an integer multiple of the virtual bond dimension, which is required by downstream loading routines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mps
|
list[ndarray]
|
List of n left-canonical MPS tensors with
shapes |
required |
Returns:
| Type | Description |
|---|---|
list[ndarray]
|
List |
Notes
The transformation leaves the (virtual) bond dimensions unchanged and
does not alter the represented many-body quantum state; it merely
repackages the tensors to match the memory layout expected by other
utilities in this module, e.g. :pyfunc:reconstruct_state.
find_physical_locations
Find basis state indices corresponding to the physical registers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mps
|
list
|
List of MPS tensors |
required |
get_random_tensor
get_random_tensor(
shape: tuple,
is_complex: bool,
random_number_generator: np.random.Generator
| None = None,
)
Get random MPS tensor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
tuple
|
Shape of tensor |
required |
is_complex
|
bool
|
If True, elements of tensors are complex |
required |
random_number_generator
|
Generator | None
|
Generator for the random numbers used in the mps. If not passed, a new generator will be instantiated using the default numpy seed. |
None
|
get_random_mps
get_random_mps(
d: int,
n: int,
maxbond: int,
is_complex: bool,
random_number_generator: np.random.Generator
| None = None,
)
Get random MPS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
int
|
Physical dimension |
required |
n
|
int
|
Number of sites |
required |
maxbond
|
int
|
Max bond dimension |
required |
is_complex
|
bool
|
If True, returns MPS tensors with complex values |
required |
random_number_generator
|
Generator | None
|
Generator for the random numbers used in the mps. If not passed, a new generator will be instantiated using the default numpy seed. |
None
|