-
Notifications
You must be signed in to change notification settings - Fork 25
Belief propagation gauge fixing #223
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
... and 3 files with indirect coverage changes 🚀 New features to boost your workflow:
|
|
I remember that BP is equivalent to simple update (PhysRevResearch.3.023073), although I haven't looked at the details (such as whether the bond messages are guaranteed to be real diagonal, and thus already represented by BTW, YASTN people are also working on BP, and with NNN Hamiltonian support (in one of the branches) as well. |
|
I looked into trying to reuse some of that functionality, and at least for the I do agree that it would be nice to join the simple update part, but for now I was actually mostly interested in affecting the gauge of a PEPS, and we can look into extending this to actually do updates in the future. It's nice to hear that YASTN also are finding this helpful! I don't think adding NNN support would be too hard, the contractions with these rank 1 environments are a lot more manageable in general. |
|
Thanks for getting this started! I'd be happy to join in on this since I was recently talking to Bram about PEPS optimization, how well it might perform and how that might be related to gauge freedoms. Specifically, I was looking at optimization runs that get stuck in linesearching at some point - e.g. when choosing a CTMRG environment dimension that is too low. Around these iterations where the optimizer gets stuck I computed cuts through the energy landscape along the current gradient directions and I was getting all sorts of weird curves with cusps or discontinuities (inspired by Appendix B of the periodic PEPS paper: https://arxiv.org/pdf/2411.12731). For example, a Heisenberg model at At In these cases you can really see that a low environment dimension will first get you smooth convex functions that become more closely centered around I seemed that gauging by symmetrizing the PEPS spatially did improve the energy landscapes but I haven't properly investigated that. In any case, I would be quite interested to see how BP gauging could improve optimization convergence and perhaps stabilize more complicated optimization runs. |
I also have wanted to try it out for quite a while, and see how it can systemically improve over SU. To suggest some tests for the current PR, we can first check that if the bond weights produced by SU (with identity gates) are consistent with the BP message tensors. |
|
@pbrehmer these are some really cool plots! This was indeed one of the primary use-cases I had in mind, so it would be cool to see how this alters these gradient plots. As a side note, at such low bond dimensions I would also be slightly cautious about picking bond dimensions that necessarily break the symmetry, for example in a U1 case with charge conjugation I would expect that you might need to check for each D whether or not it gives a valid combination. This is motivated by similar problems for MPS simulations, where certain bond dimensions don't work because they have to cut inbetween multiplets. |
|
@pbrehmer Indeed, we have seen this a lot for periodic PEPS, and pushing |
Yes I have also noticed that recently in some cases! Good to know that that seems to be consistent with your findings :) |
Yue-Zhengyuan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since adding BP may need some revisions for SU and InfiniteWeightPEPS, I want to ask a few things to get more familiar with it.
|
Resolved the |
|
Your PR no longer requires formatting changes. Thank you for your contribution! |
|
Should the doc build here be fixed by #301? |
Yes, should be fixed now! |
lkdvos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for continuing working on this, looks nice!
I have a couple things that I would like to bring up, that I still remember from when I was implementing this.
The first is that because of the layout of the algorithm, at some point I was wondering if it would actually make sense to have the south and west messages defined as the adjoint of what they are right now. The idea being the same as how typically for left/right eigenvectors we write A * R and L' * A, and I somehow had in my head that this would make things a bit more symmetric. Additionally, I think that means that for standard arrows no twists appear, while otherwise that would be the case. (although I have to double check this)
The second is that I need to double check if I implemented the efficient stopping criterion, rather than simply playing around with the default slow one.
I'm not a huge fan of the updated convention for the coordinates, since I find it a bit unintuitive if I just consider the algorithm itself, but I understand that the similarity to CTMRGEnv is also important.
Finally, I don't remember what we decided in the end, but I would not be opposed to gaugefixing resulting in a state that has different arrows than the original one. We can still add in convenience flipping functionality to fix that afterwards, but I am not a big fan of always paying that price. (This is also how MPSKit works, this will change the arrows to the canonical convention)
I should have some time next week to look into this myself as well though.
If we are going to enforce the messages to be semi-positive definite, I think taking adjoints won't make any differences? |
|
For fermions, do we also take the approach that first flipping virtual arrows (for both the state and the BPEnv) to leftwards/downwards, then finding BP fixed point and gauge transformation, and finally flipping back? |
|
So, I pushed some more changes to clean the code up a bit, and in particular made sure everything is type stable now.
|
|
Here we have at least one more choices of what should be the "canonical" arrow direction: same as the bond message orientation, i.e. a message to tensor A from tensor B has axis order (leg connected to A, leg connected to B). Here we are using this choice, which I think is more natural. Although it requires transposing during gauging, I think it makes the BP equations (in For A similar problem exists here for fermions when we initialize the messages with identity operators. For our current choice of axis order, I feel that for some messages, elements in the odd sector should be -1, i.e. the message is the permuted identity operator. This can be seen by requiring the trivial BPEnv to be the parity matrices needed to cancel the twists when evaluating the inner product of a local patch of two iPEPS, interpreting the open virtual bonds on the boundary of the patch as physical ones. |
I'm pretty sure that the implicit permutes shouldn't affect anything, at least that's what the Detailsfunction contract_north_message(
A::PEPSSandwich, M_west::PEPSMessage, M_north::PEPSMessage, M_east::PEPSMessage
)
return @autoopt @tensor begin
M_north′[DSt; DSb] :=
ket(A)[d; DNt DEt DSt DWt] * conj(bra(A)[d; DNb DEb DSb DWb]) *
conj(M_west[DWt; DWb]) * M_north[DNt; DNb] * M_east[DEt; DEb]
end
end
function contract_east_message(
A::PEPSSandwich, M_north::PEPSMessage, M_east::PEPSMessage, M_south::PEPSMessage
)
return @autoopt @tensor begin
M_east′[DWt; DWb] :=
ket(A)[d; DNt DEt DSt DWt] * conj(bra(A)[d; DNb DEb DSb DWb]) *
M_north[DNt; DNb] * M_east[DEt; DEb] * conj(M_south[DSt; DSb])
end
end
function contract_south_message(
A::PEPSSandwich, M_east::PEPSMessage, M_south::PEPSMessage, M_west::PEPSMessage
)
return @autoopt @tensor begin
M_south′[DNt; DNb] :=
conj(ket(A)[d; DNt DEt DSt DWt]) * bra(A)[d; DNb DEb DSb DWb] *
conj(M_east[DEt; DEb]) * M_south[DSt; DSb] * M_west[DWt; DWb]
end
end
function contract_west_message(
A::PEPSSandwich, M_south::PEPSMessage, M_west::PEPSMessage, M_north::PEPSMessage
)
return @autoopt @tensor begin
M_west′[DEt; DEb] :=
conj(ket(A)[d; DNt DEt DSt DWt]) * bra(A)[d; DNb DEb DSb DWb] *
M_south[DSt; DSb] * M_west[DWt; DWb] * conj(M_north[DNt; DNb])
end
end
absorb_north_message(A::PEPSTensor, M::PEPSMessage) =
@tensor A′[d; N' E S W] := A[d; N E S W] * M[N; N']
absorb_east_message(A::PEPSTensor, M::PEPSMessage) =
@tensor A′[d; N E' S W] := A[d; N E S W] * M[E; E']
absorb_south_message(A::PEPSTensor, M::PEPSMessage) =
@tensor A′[d; N E S' W] := A[d; N E S W] * conj(M[S; S'])
absorb_west_message(A::PEPSTensor, M::PEPSMessage) =
@tensor A′[d; N E S W'] := A[d; N E S W] * conj(M[W; W'])which is the equivalent of defining MM = M_north * M_south'What I like about this is that all index orders are still top to bottom and the spaces are still equal for north and south, there are no unneeded permutations, and this is the same kind of notation as thinking about eigenvectors like:
Fully agree to not tackle any of the SU code in this PR, I just wanted to briefly think about it.
This is a very good point. I think this is a great argument in favor of just canonicalizing the arrows before the procedures, and flipping back after. I'll implement this accordingly for BP in this PR already. By the way, how do you feel about me just restricting the BP implementation for two-layer for now, and not exporting it? I think most of it isn't actually working for PEPO nor partition functions and I'm not even sure yet how to handle these (e.g. hermitian projection does not really make sense) |
Would it make sense to split the This would also be compatible with other gauging algorithms, which also require an algorithm subroutine such as |
I cannot imagine how to do BP gauging with messages with |
I think this would in general make sense since there are a few different gauging algorithms which we might want to try out at some point (BP, MCF, maximal fidelity, ...). Would you also think it'd be a good idea to use the same function ( |
| U, Λ, Vᴴ = svd_compact!(sqrtM * sqrtMᴴ) | ||
| if !isdual(space(Mᴴ, 1)) | ||
| U, Λ′, Vᴴ = flip_svd(U, Λ, Vᴴ) | ||
| Λ = transpose(Λ′) | ||
| end | ||
| sqrtΛ = sdiag_pow(Λ, 1 / 2) | ||
| X = isqrtM * U * sqrtΛ | ||
| invX = sqrtΛ * Vᴴ * isqrtMᴴ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be safer to flip_svd after X and invX have been obtained using the "canonical" virtual arrow.
| U, Λ, Vᴴ = svd_compact!(sqrtM * sqrtMᴴ) | |
| if !isdual(space(Mᴴ, 1)) | |
| U, Λ′, Vᴴ = flip_svd(U, Λ, Vᴴ) | |
| Λ = transpose(Λ′) | |
| end | |
| sqrtΛ = sdiag_pow(Λ, 1 / 2) | |
| X = isqrtM * U * sqrtΛ | |
| invX = sqrtΛ * Vᴴ * isqrtMᴴ | |
| U, Λ, Vᴴ = svd_compact!(sqrtM * sqrtMᴴ) | |
| sqrtΛ = sdiag_pow(Λ, 1 / 2) | |
| X = isqrtM * U * sqrtΛ | |
| invX = sqrtΛ * Vᴴ * isqrtMᴴ | |
| if !isdual(space(Mᴴ, 1)) | |
| X, Λ, invX = flip_svd(X, Λ, invX) | |
| end |
|
After merging #315 we can try bringing back the BPEnv to SUWeight conversion as part of the gauging process. And possibly include SU-gauging as well (at least for test purposes)? |


This is an initial implementation for gauge fixing a PEPS based on the algorithm described here
From what I can tell it is mostly functional, although it requires some tests etc to actually see how well it performs in practice.
The idea would be to attempt to stabilize some gradient methods by re-gauging the state every N steps.
TODO:
rotl90etc.) ofBPEnv.BPEnvtoCTMRGEnvand.SUWeight