Questions about "Observer" Feature in ITensors.jl

+1 vote

I noticed just now that the Julia code has this AbstractObserver data type (defined at https://github.com/ITensor/ITensors.jl under ITensors.jl/src/mps/observer.jl). It seems to have methods to call early termination if a nonzero imaginary part is detected in the expectation values for certain specified operators on the MPS, or if convergence has occurred to within a certain allowed error. To understand this better, I have a few questions:

(1) Can this observer feature be adapted to some broader set of reasons for early termination, or can it realistically only be used for these two things?

(2) What exactly is the point of specifically detecting imaginary parts of these expectations? I'm guessing it's because one can specify an operator representing an observable, meaning its expectation must be real. But could this functionality be expanded to, say, terminating early if any nonnegligible expectation (real or imaginary) shows up for a local operator?

(3) Suppose one detects one of these nonneglible imaginary parts in some operator. Is there a viable way to "correct" this, or is early termination the only practical answer here?

(4) If one terminates DMRG in the middle of a sweep, are there "side effects" that one should be aware of, since this isn't normally the way DMRG works?

commented by (70k points)
Hi Sujay,
Thanks for the question. This is a good excuse for me to write up some documentation on the observer system in Julia ITensor. As a brief answer, the whole point in fact of the observer system is to be customizable. So yes you can devise other stopping criteria than the default one and also any custom measurements. I will post more about how to do this.

In the meantime, though, can you say what you mean about the imaginary part of some observable being used in the default code? The criterion I see in the default checkdone! function is that the absolute value of the difference of two energies has to be below a certain threshold (line 99 of observer.jl).

Best,
Miles
commented by (1.1k points)
edited
Hi Miles,

I'm referring to the measurelocalops! method (lines 53-61) in the observer.jl file, which I've pasted below:

function measurelocalops!(obs::DMRGObserver,
wf::ITensor,
i::Int)
for o in ops(obs)
m = dot(wf, noprime(op(sites(obs),o,i)*wf))
imag(m)>1e-8 && (@warn "encountered finite imaginary part when measuring \$o")
measurements(obs)[o][end][i]=real(m)
end
end
commented by (70k points)
I see. So that code just prints a warning to notify the user if any of the observables happen to result in a complex number. It only prints out a warning and does not terminate the code. Also that function, measurelocalops!,  is only for measuring observables and not for stopping DMRG early. The function that stops DMRG early is a different function called checkdone!. We might remove that warning because there could be some observables which are complex-valued on purpose.

Miles
commented by (1.1k points)
OK, I see. That clears it up. I think whatever documentation you eventually post will definitely be very helpful. Thank you so much!

Sujay
commented by (1.1k points)
Miles,
Oh sorry, and one other thing: just to be sure, there's no side effect of terminating DMRG in the middle of a sweep, right? Is there anything funny that happens with the orthogonality center?
commented by (70k points)
To answer this question, the observer checkdone! function is only checked at the end of each sweep (full sweep). So it never terminates in the middle of a sweep, and the orthogonality center will be at site 1 if checkdone! does stop DMRG early. (This fact about it happening at the end of a sweep is mentioned in the new docs linked below.)

Miles

+1 vote
answered by (70k points)

Hi, so we now have much more complete documentation about the DMRG observer system for the Julia version of ITensor (ITensors.jl).

Please see the 'dev' branch of the documentation here:

https://itensor.github.io/ITensors.jl/dev/Observer.html

(It will appear in the stable version after the next release.)

Best regards,
Miles