workbench_algorithms.experimental.subroutines.mps_prep
Imports for experimental MPS preparation.
HouseholderMPSLoading
Bases: Qubrick
Qubrick for loading the MPS on a quantum computer, based on HouseholderUnitarySynthesis.
compute
Compute circuit for loading an MPS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prep_reg
|
Qubits
|
Register where we are to prepare the desired state. |
required |
data
|
MPSPrepData
|
Dataclass encoding the specification of the MPS. |
required |
ctrl
|
Qubits
|
Control qubit. |
0
|
Note
- Ref: see PRXQuantum.5.040339
HouseholderUnitarySynthesis
Bases: Qubrick
Qubrick synthesizing an isometry using the Householder-based decomposition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inverse_state_prep
|
Qubrick
|
state preperation protocol to utilise. |
None
|
merge_qroms
|
Bool
|
choice to utilise QROM merging between two consecutive column loading on same physical site |
False
|
**kwargs
|
dict[str, Any]
|
Other arguments to pass to the init. |
{}
|
Note
- Ref: see PRXQuantum.5.040339
- Currently the QRE is inaccurate due to compute of the daggered LKS state prep acting oddly.
- QROM merging will only be accurate for sufficient b_of_p in rotation angles.
compute
Compute function for the Householder-based synthesis of a given isometry matrix isometry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
virtual_reg
|
Qubits
|
Virtual reg used in synthesis. Must have
dimension at least |
required |
physical_reg
|
Qubits
|
Physical reg used in synthesis. |
required |
data
|
HouseHolderUnitarySynthesisData
|
Dataclass containing unitary synthesis info, including:
- isometry ([list, numpy]): The isometry matrix to be synthesized.
- bits_of_precision (int): The bit-precision used in the state preparation subroutines.
- physical_dimension (None, int): If |
required |
ctrl
|
Qubits
|
Control qubit. |
0
|
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 |
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_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
|
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
|
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.
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 |