Exact application of an array of ITensors to an MPS.

Hi all,

I am trying to apply an array of ITensors to an MPO exactly (without truncation). Here is a MWE.

using LinearAlgebra
using ITensors
sites = siteinds("S=1/2", num_sites)



This throws the following error.

MethodError: no method matching factorize(::ITensor, ::Vector{Index{Int64}}; method="naive", truncate=false, tags="Link,n=1", ortho="left")
Closest candidates are:
  factorize(::ITensor, ::Any...; mindim, maxdim, cutoff, ortho, tags, plev, which_decomp, eigen_perturbation, svd_alg, use_absolute_cutoff, use_relative_cutoff, min_blockdim, singular_values!, dir) at ~/.julia/packages/ITensors/MnaxI/src/tensor_operations/matrix_decomposition.jl:727 got unsupported keyword arguments "method", "truncate"
  factorize(::ITensor; kwargs...) at ~/.julia/packages/ITensors/MnaxI/src/tensor_operations/matrix_decomposition.jl:682

I have checked the documentation that this works for application of MPO to MPS. But is there an implementation of the same for an array of ITensors? It seems to work for an array of ITensors in v0.3.39 but doesn’t work on v0.3.57.
Also a follow-up question. Is there an in-place version of apply (e.g. apply!). Does psi=apply(itarray,psi..) cause unnecessary allocation that can be avoided?

Thank you so much for this awesome library!

We don’t support a "naive" backend for gate application, only for MPO*MPS contraction. Can you just use a cutoff of 0 or a very small one (eps(Float64))?

We didn’t support it in older versions like v0.3.39 either, it was just ignoring the method keyword argument, while now we catch when incorrect keyword arguments are passed and throw an error ([ANN] Change to keyword argument behavior in ITensors.jl).

There isn’t an in-place version, given that the tensors generally have very dynamic sizes it is not straightforward to reuse memory, though that is something we have investigated and hopefully we can do it in a general and automated way at some point.

Thank you so much @mtfishman for the prompt reply and the clarification regarding keyword arguments. I was worried that just including a numerical precision cutoff would still require a truncation sweep resulting in some additional unnecessary overhead.

I was thinking of converting the ITensor array to an MPO but, it seems like to do it I need to insert identity manually in itarray. Otherwise MPO(itarray) would not be ompatible with the size of the MPS.

Thank you.

Yeah, ideally we would allow applying an MPO to an MPS that only acts on a subset of sites, it wouldn’t be hard to support but we just haven’t done it yet. We have that planned in ITensorNetworks.jl, but that’s not ready yet.