Obtain (and sum) non-zero amplitudes of state vector from MPS

Hi, I know there is a way to extract the probability amplitudes of a state vector from its MPS representation (MPS and MPO Examples · ITensors.jl), but this requires inputting a sequence of integers corresponding to the component of the underlying tensor you want to find. I don’t know exactly which components I want to find, but I do want to find (for the purpose of summing) all the non-zero components i.e. I want to sum the amplitudes as opposed to the squared amplitudes. Most ways I can think of doing this seem to be exponentially costly. Is there a simple way of doing this?

Thank you very much, and thank you for the great work done for ITensor!

EDIT: On top of summing the amplitudes, I also need to define a state as follows. I am working with a spin 1/2 chain with N sites. Suppose it is in the superposition

\ket{\psi} = \sum_{\{\alpha\}} c_{\alpha} \ket{s_1, s_2, \dots, s_N}_{\alpha},

where \{\alpha\} is a fixed subset of all possible configurations of the chain and c_{\alpha} are the associated amplitudes. I want to define a state

\ket{\mathbb{I}} = \sum_{\{\alpha\}} \ket{s_1, s_2, \dots, s_N}_{\alpha}

i.e. the same superposition of states but all coefficients are 1.
Indeed, the sum of the amplitudes is then

\sum_{\{\alpha\}} c_{\alpha} = \langle \mathbb{I} | \psi \rangle.

Is there a simple way I can do this if \ket{\psi} is represented as an MPS?

You’re in luck – this is a task which is ideal to perform for an MPS in a fast, polynomial-scaling way. The basic idea is that the state you identified \ket{\mathbb{I}} is actually a product (unentangled) state i.e. an MPS of bond dimension 1. It is defined by making each MPS tensor to be just a vector with entries [1,1] (for the case of a d=2 dimensional site index).

Then after defining this “summing state” \ket{\mathbb{I}} you compute its inner product with the MPS whose components or amplitudes you want to sum. Here is some code to do it manually in ITensor, making each MPS tensor of the \ket{\mathbb{I}} state on the fly:

using ITensors


  N = 100
  s = siteinds("S=1/2",N)

  psi = randomMPS(s;linkdims=10)

  I = ITensor(1.0)
  for j=1:N
    I = I*(psi[j]*ITensor([1.0,1.0],s[j]))
  @show scalar(I)


Another way to do the above would be to actually make the MPS for the state \ket{\mathbb{I}} then use the function inner to compute its inner product with the other MPS.

1 Like

Thank you very much! This is exactly what I needed to do.

1 Like

Glad to hear it

This code doesn’t seem to work with QN conserving MPS. Is there a way to ‘convert’ the block-sparse tensors to the dense tensors, or maybe is there a better way to do it with QN conserving MPS?

1 Like

I would recommend just converting the MPS to a dense MPS. I.e. just before the main part of the code runs you can do:

dpsi = dense(psi)

and then use dpsi in the rest of that part of the code. It should still be very efficient, and this kind of algorithm is not going to make much use of the block sparse structure of the MPS anyway. So the speed should be very similar.


1 Like