I’ve have been working on implementing time-evolution of a transmon chain (Bose-Hubbard model), and I’ve been following this example MPS Time Evolution. I got the time-evolution to work, but it seems to be “slow”, or not as fast as I would hope for it to be. I used 4th order Trotter gates, but other than that what I have done is very similar to this example. Profiling my code I see that the bottleneck is the apply
function which applies the gates to evolve a single time-step. Comparing to a similar solver which uses a Krylov method to do the time-evolution, this one does a lot more allocations and uses a lot more memory. Do you have any tips for optimising this?
To clarify, my question is: can anything be done in this example MPS Time Evolution to reduce allocations and memory usage when looping over the time-steps?
Here are some other questions:
I did 4th order Trotter gates by using the recursion relation withouth thinking about it too much, is it possible that the gates can be simplified somehow? (There was a mention in an other post that reversing the gates might not generalize to higher order…)
In this example the state is normalized after applying the gates but the apply
function also takes the keyword normalize
, is there any difference between these two?
In this example the in-place .=
is not used to equate the state with the applied state, should it be?
When dealing with vectors I can initialise them by using zeros
or Vector{ComplexF64}(undef, n)
, is there something similar to MPS?
Here is what my time-evolution loop looks like
function mpsevolve(mps0::MPS, gates::Vector{ITensor}, dt::Real, t::Real; kwargs...) #keyword arguments for ITensors.apply
out = [deepcopy(mps0)]
for _ in dt:dt:t
push!(out, apply(gates, out[end]; normalize = true, kwargs...))
end
return out
end
I understand that here I could calculate expectation values of the state and store those instead of storing the whole state, but I am more concerned with the possibly unnecessary memory usage of apply
which causes a lot of garbage collection.
Thank you for your time