+1 vote
asked by (1.1k points)

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 (50.7k 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).

commented by (1.1k points)
edited by
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,
      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")
commented by (50.7k 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.

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!

commented by (1.1k points)
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 (50.7k 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.)


1 Answer

+1 vote
answered by (50.7k 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:


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

Best regards,

Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.