ITensors.jl icon indicating copy to clipboard operation
ITensors.jl copied to clipboard

[ITensors] Set the `default_warn_order` to 32

Open GiggleLiu opened this issue 3 years ago • 5 comments

Set the default default_warn_order to 32. Otherwise the warning is too many in a rank tensor network contraction algorithm.

GiggleLiu avatar Aug 30 '22 09:08 GiggleLiu

Thanks Jinguo, but the default warn order is already very high. For specialized applications like yours, we have provided options to raise or turn off the warn order, like these:

ITensors.set_warn_order(N)
@disable_warn_order

emstoudenmire avatar Aug 30 '22 13:08 emstoudenmire

Thanks for introducing the alternatives. Maybe we can just optimize the warning message, now it contains a very long trace back, which makes it look like an error. It is hard to get useful message from it, like what you suggested.

https://github.com/ITensor/ITensors.jl/blob/cd836799f98484a97a0eba5b7968fef3c329b86b/src/itensor.jl#L1884

I would suggest removing the stack trace and add your solution in the message. Does it make sense?

GiggleLiu avatar Aug 31 '22 00:08 GiggleLiu

The error message does actually include the information about @disable_warn_order and other ways to change or turn off the warn order, so then the only question is about the backtrace. We do want to keep the backtrace happening at least once so that users can find the code that is triggering the warn order.

I think a good solution here would be for us to count the number of times the backtrace gets printed then only print it a small number of total times. (We don't want it to never print by default.)

A good workaround for now, though, is just to call @disable_warn_order for your code.

emstoudenmire avatar Aug 31 '22 18:08 emstoudenmire

Ah, that is true. Maybe we can left as it is.

An alternative way is only warn users about the tensor rank in the debug mode. i.e. enclosing the warning information with a @debug macro. Users only see the warning when they set ENV["JULIA_DEBUG"] = "ITensors".

Which one do you prefer?

GiggleLiu avatar Sep 01 '22 09:09 GiggleLiu

We could only enable the backtrace in debug mode, though I think Miles' suggestion of just showing the backtrace some number of times may be best.

I've found it is fairly common that people assume this warning is an error or a serious issue in their code, and also don't read the message at all, which may be due to the backtrace looking long and scary. So it would be nice to improve this in some way since I don't think the current situation has been working as well as I would have hoped. Maybe the message explaining how to suppress the warning should be made clearer?

I prefer putting backtraces in warnings since it helps you actually fix the warning and not just have to guess where it is coming from, but I think it scares people (I've found people are scared by warnings in general but that is another issue).

I would be ok increasing the warning cutoff a bit from the current one, it isn't uncommon to reach tensors of order 14 when doing ED calculations.

mtfishman avatar Sep 08 '22 14:09 mtfishman