+1 vote
asked by (1.1k points)

I have been trying to write a modified version of the dmrg and sweepnext functions in Julia for my work on the lattice Schwinger model with periodic boundary conditions. However, when I do so, I am confronted with the following error message:

ERROR: LoadError: LoadError: UndefVarError: @timeit_debug not defined

When I looked in the original dmrg.jl code, I see @timeit_debug used four times. There is no indication of it being defined earlier in the file or being imported from somewhere else. The first one looks like this:

@timeit_debug GLOBAL_TIMER "position!" begin
      position!(PH, psi, b)
end

When I try to look up this macro, the only thing I can find is this GitHub repository (https://github.com/KristofferC/TimerOutputs.jl/blob/b91912e12902a41425d030fed9d3f418134279ff/src/TimerOutput.jl). However, when I look in my Julia files and packages, I cannot find this repository or anything like it.

So anyway, my questions are:
(1) What is the purpose of this macro? In particular, is it necessary for the functioning of DMRG, or is it just some helpful addition? (Guessing by the name of the macro, I'm guessing it's the latter, but I want to be sure.)
(2) Where exactly is ITensors.jl getting this macro from?
(3) If I write my own methods in a separate Julia file that are meant to imitate ones in the repository but with certain modifications, what steps do I need to follow to incorporate this macro without getting the above error?

1 Answer

0 votes
answered by (70.1k points)

Hi Sujay,
The @timeit_debug macro is provided by the library TimerOutputs.jl:
https://github.com/KristofferC/TimerOutputs.jl

You can see on the README page there that @timer_debug is discussed.

It's not necessary for the functioning of our ITensor DMRG code, but we just use it sometimes to check whether the code is running as quickly as we'd like to see. So if you're making your own code which doesn't have using TimerOutputs at the top, you can just remove the @timeit_debug macro and the associated begin..end block keywords.

The way it gets brought into ITensors.jl is that it's one of ITensors.jl's dependencies (see the Project.toml file at the top of the ITensors.jl source code if you'd like a list of all dependencies). But that doesn't mean that you will have TimerOutputs definitions available in your own code; you have to do using TimerOutputs for that.

Hope that helps & let me know if any of that doesn't seem correct because I'm still on a learning curve with Julia too -

Miles

commented by (1.1k points)
edited by
Thank you Miles! Indeed, putting "using TimerOutputs" was all I needed to do.

As a related follow-up to this, I am now finding that the program will claim that the ITensors.jl function ProjMPO_MPS (defined in src/mps/projmpo_mps.jl) is now giving me an error ("ERROR: LoadError: UndefVarError: ProjMPO_MPS not defined"). However, I haven't seen this happen in the past with any other ITensors.jl function (dmrg, AutoMPO, etc.). Just putting "using ITensors" at the top of my code has always been enough, and I did that here, so do you know why this is happening?
commented by (70.1k points)
Hi Sujay,
It is because we did not export these types. I think we should so I'll add them to our exports and it will appear in version 0.1.11. For now for any symbol (type, function) like that you can just explicitly import them like this:

    import ITensors: ProjMPO_MPS

and use a comma separated list of all the names you want to import. Or you can just write ITensors.ProjMPO_MPS if you prefer.

Miles
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.

Categories

...