Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance simple_update! for MPS in the Canonical form #255

Merged
merged 26 commits into from
Nov 22, 2024

Conversation

jofrevalles
Copy link
Member

Summary

This PR refactors the simple_update! function so now it properly uses the $\Lambda$ tensors of an MPS in the Canonical form to evolve the state without the need of recanonizing it.

Additionally, we also added the kwarg of normalize in the canonize! function.

@jofrevalles
Copy link
Member Author

@mofeing @starsfordummies Maybe we should put the renormalize kwarg in all truncate! functions (for all the Forms), right? Since we will lose norm every time we truncate.

@starsfordummies
Copy link
Contributor

ok for me!

src/Ansatz.jl Outdated Show resolved Hide resolved
src/Ansatz.jl Outdated Show resolved Hide resolved
src/Ansatz.jl Outdated Show resolved Hide resolved
src/MPS.jl Show resolved Hide resolved
src/MPS.jl Outdated Show resolved Hide resolved
src/MPS.jl Outdated Show resolved Hide resolved
src/MPS.jl Outdated Show resolved Hide resolved
@jofrevalles
Copy link
Member Author

@mofeing I refactored the normalize functions, so now we can do normalize! of an MPS in the Canonical form without recanonizing. We can also choose the bond at which it normalizes it.

@mofeing
Copy link
Member

mofeing commented Nov 21, 2024

@mofeing I refactored the normalize functions, so now we can do normalize! of an MPS in the Canonical form without recanonizing. We can also choose the bond at which it normalizes it.

nice! so I understand that if you don't provide the bond, then it normalizes all of them right? mmm do you have a use case for normalizing just 1 bond?

@jofrevalles
Copy link
Member Author

nice! so I understand that if you don't provide the bond, then it normalizes all of them right? mmm do you have a use case for normalizing just 1 bond?

So I did not implemented it like that but I will change it so it is like you said. Maybe a use case would be when you truncate, right? Since you only truncate a bond and thus you want to renormalize the only "perturbed" bond.

@jofrevalles
Copy link
Member Author

I will do some more tests on evolve! this afternoon, for now let's keep this PR open. I think I can finish it today.

@mofeing
Copy link
Member

mofeing commented Nov 21, 2024

So I did not implemented it like that but I will change it so it is like you said. Maybe a use case would be when you truncate, right? Since you only truncate a bond and thus you want to renormalize the only "perturbed" bond.

that could be a case. in general you would want such a method in the case that you want to normalize 1 $\Lambda$ and keep the rest of $\Lambda$s intact but I can't think of a real case where you would want that. if you want to normalize all the $\Lambda$s (or only one) calling normalize! on each $\Lambda$ shouldn't be costly because they're just vectors.

@jofrevalles
Copy link
Member Author

Okay for me this is ready to merge @starsfordummies @mofeing . I found that, in order to normalize all $\Lambda$, you need to divide all of them by norm(mps)^(1/(L-1)).

Copy link
Member

@mofeing mofeing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, but can you check these comments?
https://github.com/bsc-quantic/Tenet.jl/pull/255/files#r1850557758
https://github.com/bsc-quantic/Tenet.jl/pull/255/files#r1850558850

also, on normalize!(::Canonical), doesn't just calling normalize! individually on each $\lambda$ just work?

src/MPS.jl Outdated Show resolved Hide resolved
src/MPS.jl Outdated Show resolved Hide resolved
src/MPS.jl Outdated Show resolved Hide resolved
src/MPS.jl Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 21, 2024

Codecov Report

Attention: Patch coverage is 0% with 47 lines in your changes missing coverage. Please review.

Project coverage is 0.04%. Comparing base (0ba1707) to head (3ffd4e0).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/Ansatz.jl 0.00% 29 Missing ⚠️
src/MPS.jl 0.00% 17 Missing ⚠️
src/Quantum.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #255       +/-   ##
==========================================
- Coverage   79.59%   0.04%   -79.55%     
==========================================
  Files          32      32               
  Lines        2068    2072        +4     
==========================================
- Hits         1646       1     -1645     
- Misses        422    2071     +1649     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@jofrevalles
Copy link
Member Author

Okay, this was complicated... @mofeing @starsfordummies I finally managed to make everything work. For me, this makes sense. At least now, I think tomorrow I will forget for sure... Let's try to write it here:
evolve! has a renormalize kwarg, that for NonCanonical or MixedCanonical passes through truncate. This can not be done for Canonical, since simple_update_2site!(::Canonical, ...) contracts the two-site wave-function, evolves by calling simple_update_2site!(::NonCanonical, ...), and the truncate is there, but we need to truncate after that, when in we recover the (pseudo)Canonical form, and then is when we have to normalize! the bond.

src/Ansatz.jl Outdated Show resolved Hide resolved
src/Ansatz.jl Outdated Show resolved Hide resolved
src/Ansatz.jl Outdated Show resolved Hide resolved
src/Ansatz.jl Outdated Show resolved Hide resolved
src/Ansatz.jl Outdated Show resolved Hide resolved
src/MPS.jl Outdated Show resolved Hide resolved
src/MPS.jl Outdated Show resolved Hide resolved
@jofrevalles jofrevalles merged commit 4247207 into master Nov 22, 2024
5 checks passed
@jofrevalles jofrevalles deleted the fix/simple_update! branch November 22, 2024 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants