0 votes
asked by (310 points)

I am trying to calculate the MPS resulting from exp(-tau H)|psi> where where H has up to three site interaction terms, and the exponential is the usual Boltzmann operator in this case.
I can't use expH because of the three term interactions so I moved to applyExpH, but I keep on having an allocation error which I cannot trace back.

Here is a snippet of my code

auto args = Args("Cutoff=",1E-8,"MaxDim=",20,"Order=",2);
for (int i = 1; i<= Nstep; i++)
    std::cout << "Step " << i << std::endl;
    psi1 = res;
    println("Norm: ",norm(res));

The error I get is the following:
terminate called after throwing an instance of 'std::badalloc'
what(): std::bad
Removing the three site interactions the error disappear so it must be related to the Hamiltonian structure. Is this a normal behaviour?


commented by (70.1k points)
Hi Raffaele, it’s a little hard to say what’s causing the error. Did you compile and run the code in debug mode? http://itensor.org/docs.cgi?vers=cppv3&page=formulas/debug_mode

Then we will likely get a more informative error message.
commented by (310 points)
in debug mode I can't see any error. The code runs without problems.
commented by (70.1k points)
Hi, ok thanks. That's interesting. So then I'm not sure what's happening. All I can guess right now is that std::bad_alloc happens sometimes when the code is using too much ram, more than is available on the system. Are you running the code for either a very long time or involving a very large MPS bond dimension in the many thousands? Or if there is a bug in the code it could be using up a lot of ram by mistake.

Please monitor the ram usage of the code before it crashes and see if that gives a clue. Barring that I'll need to run your code myself to investigate the issue.

commented by (310 points)
Hi, thanks for the help. I tried several things but unfortunately this error is difficult to reproduce. I am currently running the code without issues but every now and then I get this error. I might also suspect some OS/hardware issue. I'll monitor the job and post an update if any.
commented by (70.1k points)
Hi Raffaele, thanks. Yes, please keep an eye on the ram used (and of course make sure no other program is using up too much ram at the same time). It could be that ITensor is using quite a lot relative to the total you have, and unfortunately even modern software does not handle the case of running out of ram very gracefully.

commented by (70.1k points)
Of course please let us know if ITensor seems to be using an unwarranted amount of ram, say in excess of 10 Gb for a modest calculation. On the other hand, when working with MPS having bond dimensions in the thousands, it can actually be normal for tensor network calculations to need many hundreds of Gb of ram! (Depending on the algorithm used.)

Please log in or register to answer this question.

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.