Introduction

mpnum is a Python library providing flexible tools to implement new numerical schemes based on matrix product states (MPS). It is available under the BSD license at mpnum on Github. So far, mpnum provides:

  • basic tools for various matrix product based representations, such as:
    • matrix product states (MPS), also known as tensor trains (TT)
    • matrix product operators (MPO)
    • local purification matrix product states (PMPS)
    • arbitrary matrix product arrays (MPA)
  • basic MPA operations: add, multiply, etc; compression (see compress(), SVD and variational)
  • computing ground states of MPOs (see mineig(), which computes smallest eigenvalues and eigenvectors of MPOs)
  • flexible tools to implement new schemes based on matrix product representations

Contributing

Contributions and pull requests for mpnum are very welcome. More information on modifying mpnum is at Extending mpnum.

Graphical notation for tensors

Our graphical notation for tensors is very similar to the graphical notation used by Schollwoeck [Sch11, e.g. Figure 38].

Basics

Tensor contractions are much easier to write down using figures. A simple case of of a tensor contraction is the product of two matrices:

\[C = A B^T\]

We represent this tensor contraction with the following figure:

_images/tensors_matrixproduct.png

Each of the tensors \(A\), \(B\) and \(C\) is represented by one box. All the tensors have two indices (as they are matrices), therefore there are two lines emerging from each box, called legs. Connected legs indicate a contraction. The relation between legs on the left and right hand sides of the equality sign is given by their position. In this figure, we specify the relation between the indices in a formula like \(B_{kl}\) and the individual lines in the figure by giving specifying the name of each index on each line.

In this simple case, the figure looks more complicated than the formula, but it contains complete information on how all indices of all tensors are connected. To be fair, we should mention the indices in the formula as well:

\[C_{ij} = \sum_{j} A_{ij} B_{kj}\]

Another simple example is the following product of two vectors and a matrix:

\[c = u^\dagger A v = \sum_{ij} u^*_i A_{ij} v_j\]

This formula is represented by the following figure:

_images/tensors_matrixelement.png

Matrix product states (MPS)

The matrix product state representation of a state \(\vert \psi \rangle\) on four subsystems is given by

\[\langle i j k l \vert \psi \rangle = \psi_{ijkl} = A_i B_j C_k D_l\]

where \(A_i \in \mathbb C^{1 \times D}\), \(B_j, C_k \in \mathbb C^{D \times D}\) and \(D_l \in \mathbb C^{D \times 1}\) (reference: e.g. [Sch11]; exact definition). This construction is also known as tensor train and it is given by the following simple figure:

_images/tensors_mps.png

We call \(\psi\) a global tensor and we call the MPS matrices \(A_i\), \(B_j\) etc. which are associated to a certain subsystem local tensors.

Very often, we can omit the labels of all the legs. The figure then becomes very simple:

_images/tensors_mps_no_names.png

As explained in the next paragraph on MPOs, we usually add dummy bonds of size 1 to our tensors:

_images/tensors_mps_no_names_with_dummies.png

Matrix product operators (MPO)

The matrix product operator representation of an operator \(\rho\) on three subsystems is given by

\[\langle i_1 i_2 i_3 \vert \rho \vert j_1 j_2 j_3 \rangle = \rho_{i_1i_2i_3,j_1j_2j_3} = A_{i_1j_1} B_{i_2j_2} C_{i_3j_3}\]

where the \(A_{i_1j_1}\) are row vectors, the \(B_{i_2j_2}\) are matrices and the \(C_{i_3j_3}\) are column vectors (reference: e.g. [Sch11]; exact definition). This is represented by the following figure:

_images/tensors_mpo.png

Be aware that the legs of \(\rho\) are not in the order \(i_1 i_2 i_3 j_1 j_2 j_3\) (called global order) which is expected from the expression \(\langle i_1 i_2 i_3 \vert \rho \vert j_1 j_2 j_3 \rangle\) and which is obtained by a simple reshape of the matrix \(\rho\) into a tensor. Instead, the order of the legs of \(\rho\) must match the order in the MPO construction, which is \(i_1 j_1 i_2 j_2 i_3 j_3\). We call this latter order local order. The functions global_to_local and local_to_global can convert tensors between the two orders.

In order to simplify the implementation, it is useful to introduce dummy bonds with index size 1 on the left and the right of the MPS or MPO chain:

_images/tensors_mpo_with_dummies.png

With these dummy bonds, all the tensors in the representation have exactly two bond indices.

It is useful to draw the physical column indices upward from the global and local tensors while leaving the physical row indices downward:

_images/tensors_mpo_updown.png

With this arrangement, we can nicely express a product of two MPOs:

_images/tensors_mpo_product.png

This figure tells us how to obtain the local tensors which represent the product: We have to compute new tensors as indicated by the shaded area. The figure also tells us that the bond dimension of the result is the product of the bond dimensions of the two individual MPO representations.

Local purification form MPS (PMPS)

The local purification from matrix product state representation (PMPS or LPMPS) is defined as follows:

_images/tensors_pmps.png

Here, all the \(i\) indices are actual sites and all the \(j\) indices are ancilla sites used for the purification (reference: e.g. [Cue13]; exact definition). The non-negative operator described by this representation is given by

\[\rho = \operatorname{tr}_{j_1j_2j_3}( \vert \psi \rangle \! \langle \psi \vert )\]

The following figure describes the relation:

_images/tensors_pmps_to_mpo.png

It also tells us how to convert a PMPS representation into an MPO representation and how the bond dimension changes: The MPO bond dimension is the square of the PMPS bond dimension.

Matrix product arrays

The library mpnum implements the class mpnum.mparray.MPArray which can be used for MPS, MPO, PMPS and other MPS-like representations. MPArray is short for matrix product array (MPA) and this class provides an MPS with an arbitrary number of physical legs at each site. Each physical leg can also have an arbitrary dimension. A corresponding figure could look like this:

_images/tensors_mpa.png

Next steps

The ipython notebook mpnum_intro.ipynb in the folder Notebooks provides an introduction on how to use mpnum for basic MPS, MPO and MPA operations. You can also view mpnum_intro.ipynb on Github.