shuaigroup / Renormalizer

Quantum dynamics package based on tensor network states
https://shuaigroup.github.io/Renormalizer/
Apache License 2.0
51 stars 16 forks source link

Correct numpy tolerence #167

Closed atxy-blip closed 4 months ago

atxy-blip commented 4 months ago

In commit 254b981, atol for numpy backend was wrongly set to 1e-5 in mps/backend.py, instead of the original value 1e-8. Meanwhile, in this version only atol was set up.

https://github.com/shuaigroup/Renormalizer/blob/254b9819d0e9124736d9c1681de0ec7bc60792bb/renormalizer/mps/backend.py#L136-L140

As for numpy, the basic logic for considering two numbers a and b close in is:

abs(a - b) <= max(rtol * max(abs(a), abs(b)), atol)

The existence of rtol allows for the comparison of large numbers, e.g., 10001 and 10000, which may emerge in imaginary time-evolution. Therefore, I propose adding back the rtol parameter.


This commit does the following things:

I am not sure whether rtol set to 1e-2 is appropriate for 32-bits. Discussions are welcome for any issue concerned : )

codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 94.54545% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 87.23%. Comparing base (07b639f) to head (2c37a67).

:exclamation: Current head 2c37a67 differs from pull request most recent head 24626e1

Please upload reports for the commit 24626e1 to get more accurate results.

Files Patch % Lines
renormalizer/mps/mp.py 85.00% 3 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #167 +/- ## ========================================== + Coverage 85.87% 87.23% +1.35% ========================================== Files 117 118 +1 Lines 12342 13710 +1368 ========================================== + Hits 10599 11960 +1361 - Misses 1743 1750 +7 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

liwt31 commented 4 months ago

In general the PR is OK, but I'm curious if this setting has a practical effect on the calculations you've carried out?

atxy-blip commented 4 months ago

if this setting has a practical effect on the calculations you've carried out

Nope. Code from the lastest master branch still messes up our Holstein test after I set $RENO_NUM_THREADS to 1 and appied the new atol. I am still investigating on why it happens on my setup.

Anyway, proposing a fix on atol is the least thing I can do at this stage : (

jiangtong1000 commented 4 months ago

What do you mean by messing up?

On Thu, May 9, 2024 at 6:03 AM Yu Xiong @.***> wrote:

if this setting has a practical effect on the calculations you've carried out

Nope. Code from the lastest master branch still messes up our Holstein test after I set $RENO_NUM_THREADS to 1 and appied the new atol. I am still investigating on why it happens on my setup.

Anyway, proposing a fix on atol is the least thing I can do at this stage : (

— Reply to this email directly, view it on GitHub https://github.com/shuaigroup/Renormalizer/pull/167#issuecomment-2102352484, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIZLWMJW2PXQ7FUFOAVL7ZLZBNCXBAVCNFSM6AAAAABHONXYD2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBSGM2TENBYGQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

atxy-blip commented 4 months ago

@jiangtong1000 I intend to open a new issue for discussion of the current problem. Please check #168 : D

liwt31 commented 4 months ago

@atxy-blip ready to merge if you fix my review comment. It'll be better if you can solve the codecov issue.

atxy-blip commented 4 months ago

ready to merge if you fix my review comment

Fixed.

liwt31 commented 4 months ago

Thanks for the contribution! Looking forward to more of your PRs 😄

liwt31 commented 4 months ago

Note that this branch has been rebased and its commits are different from your local version @atxy-blip