state#

Quantum states

Classes

DistributedQubitState(nqubit)

A quantum state of n qubits distributed between w nodes.

MatrixProductState([nsite, state, chi, ...])

A matrix product state (MPS) for quantum systems.

QubitState([nqubit, state, den_mat])

A quantum state of n qubits, including both pure states and density matrices.

class DistributedQubitState(nqubit: int)[source]#

Bases: Module

A quantum state of n qubits distributed between w nodes.

Parameters:

nqubit (int) – The number of qubits in the state.

reset()[source]#

Reset the state to the vacuum state.

class MatrixProductState(nsite: int = 1, state: str | list[Tensor] | list[int] = 'zeros', chi: int | None = None, qudit: int = 2, normalize: bool = True)[source]#

Bases: Module

A matrix product state (MPS) for quantum systems.

A matrix product state is a way of representing a quantum state as a product of local tensors. Each tensor has one physical index and one or two bond indices. The physical index corresponds to the local Hilbert space dimension of the qudit, while the bond indices correspond to the entanglement between qudits.

Parameters:
  • nsite (int) – The number of sites of the MPS. Default: 1

  • state (str | list[Tensor] | list[int]) – The representation of the MPS. If 'zeros' or 'vac', the MPS is initialized to the all-zero state. If a list of tensors, the MPS is initialized to the given tensors. The tensors must have the correct shape and dtype. If a list of integers, the MPS is initialized to the corresponding basis state. Default: 'zeros'

  • chi (int | None) – The maximum bond dimension of the MPS. Default: None (which means 10 * nsite)

  • qudit (int) – The local Hilbert space dimension of each qudit. Default: 2

  • normalize (bool) – Whether to normalize the MPS after each operation. Default: True

apply_mpo(mpo: list[Tensor], sites: list[int]) None[source]#

Use TEBD algorithm to contract tensors (contract local states with local operators), i.e.,

>>>          a
>>>          |
>>>    i-----O-----j            a
>>>          |        ->        |
>>>          b             ik---X---jl
>>>          |
>>>    k-----T-----l
center_orthogonalization(c: int, dc: int = -1, normalize: bool = False) None[source]#

Get the center-orthogonalization form of the MPS with center c.

check_center_orthogonality(prt: bool = False) list[Tensor][source]#

Check if the MPS is in center-orthogonal form.

forward() None[source]#

Pass.

full_tensor() Tensor[source]#

Get the full tensor product of the state.

inner(tensors: list[Tensor] | MatrixProductState, form: str = 'norm') Tensor | list[Tensor][source]#

Get the inner product with another matrix product state.

normalize_central_tensor() None[source]#

Normalize the center tensor.

orthogonalize_left2right(site: int, dc: int = -1, normalize: bool = False) None[source]#

Orthogonalize the tensor at site and update the next one at site + 1.

It uses the QR decomposition or SVD, i.e., \(T = UR\) for the QR decomposition and \(T = USV^{\dagger} = UR\) for SVD. The tensor at site is replaced by \(U\). The tensor at site + 1 is updated by \(R\).

Parameters:
  • site (int) – The site of tensor to be orthogonalized.

  • dc (int) – Keep the first dc singular values after truncation. Default: -1 (which means no truncation)

  • normalize (bool) – Whether to normalize the tensor \(R\). Default: False

orthogonalize_n1_n2(n1: int, n2: int, dc: int, normalize: bool) None[source]#

Orthogonalize the MPS from site n1 to site n2.

orthogonalize_right2left(site: int, dc: int = -1, normalize: bool = False) None[source]#

Orthogonalize the tensor at site and update the next one at site - 1.

It uses the QR decomposition or SVD, i.e., \(T^{\dagger} = QR\) for the QR decomposition, which gives \(T = R^{\dagger}Q^{\dagger} = LV^{\dagger}\), and \(T = USV^{\dagger} = LV^{\dagger}\) for SVD. The tensor at site is replaced by \(V^{\dagger}\). The tensor at site - 1 is updated by \(L\).

Parameters:
  • site (int) – The site of tensor to be orthogonalized.

  • dc (int) – Keep the first dc singular values after truncation. Default: -1 (which means no truncation)

  • normalize (bool) – Whether to normalize the tensor \(L\). Default: False

set_tensors(state: str | list[Tensor] | list[int]) None[source]#

Set the tensors of the matrix product state.

property tensors: list[Tensor]#

Get the tensors of the matrix product state.

Note

This output is provided for reading only. Please modify the tensors through buffers.

class QubitState(nqubit: int = 1, state: Any = 'zeros', den_mat: bool = False)[source]#

Bases: Module

A quantum state of n qubits, including both pure states and density matrices.

Parameters:
  • nqubit (int) – The number of qubits in the state. Default: 1

  • state (Any) – The representation of the state. It can be one of the following strings: 'zeros', 'equal', 'entangle', 'GHZ', or 'ghz'. Alternatively, it can be a tensor that represents a custom state vector or density matrix. Default: 'zeros'

  • den_mat (bool) – Whether the state is a density matrix or not. Default: False

forward() None[source]#

Pass.