How fast should products of MPO and MPS be?

I’ve been running some timing tests to check when MPS/MPO “outspeeds” matrix multiplication. My end goal is to use MPS to represent my states and run quantum jumps, and I think my bottleneck in speed is running product(MPS, MPO).

I did some quick timing for applying S_- = \sum_{i=1}^N\sigma_-^i to the initial state all spin up. My MPO/MPS run is faster than dense matrices, but much slower than sparse. Is there something inefficient in how I’m writing this that can be sped up?

For reference, I’m running the following code (timing just the matrix multiplication vs. the product in MPS/MPO) for N=12, where my product() beats a dense matrix code:

# MPS/MPO Timing
let
    # Setting some parameters + site index
    N = 12
    state = ["Up" for n=1:N]                       # define the state to be all spin up (|e>)
    s = siteinds("S=1/2",N; conserve_qns=true)     # all the atoms are spin 1/2 
    
    psi = MPS(s, state)                            # Creating State, MPS
    Smin = OpSum()
    for i in 1:N
        Smin  += 1.,"S-", i                        # first argument is the coefficient. We can alter this as need be for WG, for example.
    end
    SminMPO = MPO(Smin, s)                         # Creating MPO of Smin
    
    @time product(SminMPO, psi)                    # Timing
end

  0.002528 seconds (20.08 k allocations: 4.358 MiB)
function tensor_lower_sp(i, N)
    # Function to create S- = sum of all individual sigma_-
    id = spzeros(2,2); lower = spzeros(2,2)                  # creating lowering operator and identity
    lower[2,1] = 1.
    id[1,1] = 1.; id[2,2] = 1.
    prod = 1
    for x in 1:N
        if x == i
            prod = kron(prod, lower)
        else
            prod = kron(prod, id)
        end
    end
    return prod
end


let
    # Sparse mult timing.
    N = 12 
    
    psiMat = spzeros(2^N); psiMat[1] = 1.0                   # Initial state, 2^N dimension
    SminMat = spzeros(2^N, 2^N)                              # Creating lowering op, 2^N by 2^N matrix
    for i in 1:N
        SminMat = SminMat + tensor_lower_sp(i, N)
    end
    @time res1 = SminMat * psiMat
end

  0.000009 seconds (9 allocations: 96.188 KiB)

It’s an interesting question. Please tell me if I have any of the details wrong, but it appears the case you are testing is when the MPS has a bond dimension of \chi=1 (i.e. it is a product state, which is what the MPS(s,state) constructor always makes).

Also the MPO should have a small bond dimension also, I believe just 2.

So in these limits, the power of MPS and MPO does not really come out very much. In contrast, for problems where one was e.g. time evolving a state the bond dimension can become arbitrarily large and the state will be generically dense, giving a huge savings once the bond dimension grows to intermediate values.

Another limit that would make the MPS-MPO approach more valuable would be a large number of sites N, just because 2^{12} is only 4096, so well within reach of dense matrix algorithms. But of course once N \geq 35 or so, things rapidly become very slow for dense matrix algorithms.

1 Like

Ah yes - the step I am benchmarking is pretty trivial because the states bond dimension is \chi = 1. Later in the evolution it changes but I will have to run much larger N for any reasonable comparisons.

Thanks for the help!

1 Like

Quick follow up, but less iTensor related and more just MPS related.

Shouldn’t I expect the computation to be much faster for low bond dimensions? My understanding is that with N d-dimensional particles, I would need 2^N parameters. However, with MPS I can rewrite this as \mathcal{O}(Ndm^2) where m is the bond dimension. Naively I would then think smaller bond dimensions are better, and thus states that can be represented with bond dimension 1 would be best.

But then for my benchmarking, if I have an MPO and I apply it to an MPS, since applying this contracts the physical indices, I would expect the computation to scale as \mathcal{O}(d^N) and not have the bond dimension come into play at all, which makes me think this type of computation should not be faster than standard matrix multiplication. I believe I am missing something crucial in how MPS really works.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.