qat.mps.mps.StateMPS

class qat.mps.mps.StateMPS(tensor_list: list = None, tensor_types: list = None)

MPS class.

Conventions:
  • tensors are with indices (b, a, a’) with b external index

    and a, a’ internal (bond) indices

  • dimension of external index is D. Defaults to D=2 (qubits)

  • dimension chi of internal index is free and may depend on bond index

  • left-most and right-most tensors are of shapes (D, 1, chi) and (D, chi, 1)

  • other tensors have shapes (D, chi1, chi2)

Parameters
  • tensor_list (list(np.ndarray)) – list of tensors

  • tensor_types (list(Normalization)) – type (L, N or R) of tensor

tensor_list

list of tensors

Type

list(np.ndarray)

tensor_types

type (L, N or R) of tensor

Type

list(Normalization)

contract(max_qubit_memory_limit: int = 30) ndarray

Contract the MPS into its statevector representation.

Parameters

max_qubit_memory_limit (int, optional) – Limits the size of the MPS to be contracted to a specific number of qubit to avoid memory issues. Default to 30.

Returns

The statevector.

Return type

np.ndarray

expectation_value(obs, index_list: Optional[List[int]] = None) double complex

Compute the expectation value of an observable/operator.

The operator can be given as an instance of Observable or of StateMPO. If an MPO is given with less tensors than in the MPS, a list of indices must be given too.

The canonical form of the MPS, even if partial, is taken into account to lower computational cost.

Parameters

obs (Observable or StateMPO) – The operator to compute.

Optional argument:

index_list (list<ind>): indices on which to contract the MPO

Returns

Expectation value for given operator.

Return type

complex

get_memory_used() float

Compute memory used by the tensor network in megabytes (MB).

Returns

Number of MB used

Return type

float

static load(filepath: str)

Load the MPS from an NPZ file.

Parameters

filepath (str) – Path of the NPZ file.

norm() float

Compute the norm \(||\psi|| = \sqrt(|{\langle}self|self{\rangle}|)\) with \(\psi\) the state in MPS representation.

sample(state_index: int) float

Get probability of input state.

Parameters

state_index (int) – State index LSB ordered (0 = |00…00>, 1 = |00…01>, …etc)

Returns

Probability of the realisation of input state index.

Return type

float

save(filepath: str)

Save the MPS to the disk as NumPy NPZ file.

Parameters

filepath (str) – Path where the NPZ file will be saved.