You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NTU: approximate contraction of a finite part of iPEPS #188
In neighborhood tensor update (NTU), the environment of a bond can be a finite patch around the bond. For example, if we contain two more layers around a bond, the environment is (the bra is contracted with ket)
This is called EnvApproximate of type 65 in YASTN documentation. May I ask @leburgel if MPSKit already have boundary MPS method to contract such a finite network? Alternatively, @pbrehmer how can I use CTMRG to contract it? (In my mind CTMRG is for infinite size, so it's not quite clear to me how to apply it to a finite system).
Using MPSKit, you could contract the patch from the top to towards the open bond by using the approximate algorithm to sequentially approximately contract a finite MPO slice of the patch into the top boundary MPS and return another MPS, until you've contracted everything above the open bond. You could then do the same starting from the bottom (where you would have to be a bit careful with how you pass the MPS and MPO slices to the algorithm, since the algorithm always assumes an MPO to be contracted into an MPS from below, where here you contract it from above). After this you have just the MPO-like slice with the open bond, and a top and bottom finite boundary MPS, at which point you can contract everything manually.
So this is not really a plug-and-play built-in routine, but it can definitely be done using MPSKit.approximate.
... how can I use CTMRG to contract it? (In my mind CTMRG is for infinite size, so it's not quite clear to me how to apply it to a finite system)
From what I've head, in principle one can also use CTMRG for contracting finite environments with reasonable accuracy but I have no experience with this. I would be skeptical if that would be a viable approach for small-ish finite environments like the one you're trying to contract. In any case, the current CTMRG implementation only works for infinite lattices. The boundary MPS technique Lander suggested seems to be the way to go, I think.
I wonder what's a good way to obtain the initial guess ψ₀? Do you just use local SVD truncation on each bond? Actually I have one method based on some sort of "projectors" (it's exact for truncation of one bond on an OBC-MPS), but maybe you have a better approach.
In addition, do we already have a function to construct an InfinitePartitionFunction from $\langle \psi | \psi \rangle$ so I don't need to write again? To use the MPSKit functions it is easier to first merge the virtual legs of the bra network and the ket network.
I think I added a mpotensor function recently in PEPSKit that takes a sandwich and spits out the correct MPOTensor, which you can then use in MPSKit. In principle the goal would be to be able to work with the double-layer objects directly as well, but there are definitely some parts missing there so it can be a good short-term solution to map to a single-layer network first.
Suppose that for convenience, I merge the virtual indices in such a way that the two-layer cluster is converted to a single-layer network with the following choice of arrows:
C ← E ← E --←-- E ← E ← C
↓ ↓ ↓ ↓ ↓ ↓
E ← T ← T --←-- T ← T ← E
↓ ↓ ↓ ↓ ↓ ↓
E ← T ← X ← ← Y ← T ← E
↓ ↓ ↓ ↓ ↓ ↓
E ← T ← T --←-- T ← T ← E
↓ ↓ ↓ ↓ ↓ ↓
C ← E ← E ← E ← E ← E ← C
and I compress the cluster horizontally starting from the left and right boundary. The right boundary is a very standard ket MPS, and the column transfer MPO acts on its left. However, the left boundary is a bra MPS, and the column transfer MPO acts on its right.
It seems that adjoint is not defined for a FiniteMPS in MPSKit (although it is for FiniteMPO). @leburgel@lkdvos Can MPSKit actually handle a bra MPS? If not, can you suggest a workaround?
@leburgel Do you have some time recently for this example of conjugating an MPS? I may start working on long-range expectation values (#396) based on it.
@leburgel Do you have some time recently for this example of conjugating an MPS? I may start working on long-range expectation values (#396) based on it.
I did some digging and found a local script where I do something like this from a while back, for contracting partition functions of finite statistical mechanics models. Let me dust that off and I'll post a link to a corresponding gist soon.
However, if I did this again now I just wouldn't treat the last row/column as a FiniteMPS instance. To do this you have to conjugate it, just because MPSKit then conjugates it again in things like dot(::FiniteMPS, ::FiniteMPS). We can just use a sequential edge_transfer_left to contract in this last line, without having to conjugate anything.
I bundled everything I already had on contracting finite patches as well as a few new aspects into a single script here. Sorry about the delay, but hopefully this helps @Yue-Zhengyuan. In particular, this should do exactly do what you mentioned in your comment above.
The details are entirely up for debate, but I definitely prefer the approach of contract_network_via_edge from the gist, circumventing the need to conjugate a FiniteMPS at any point.
After a bit of struggling I also managed to get the example running directly using the double-layer structure of the PEPS overlap network. This required quite a bit of hacky patches of MPSKit internals to work with MPSKit.FiniteMPO and MPSKit.FiniteMPS where the number of legs of the MPS and MPO tensors is not the same on all sites. I'll try to clean this up and add the example next week, but for now the above should also work by squashing the local PEPS sandwiches down to rank-4 tensors using PEPSKit.mpotensor.
Linking the draft example using the double-layer structure here already, just in case I lose track of this.
Activity
leburgel commentedon May 1, 2025
Using MPSKit, you could contract the patch from the top to towards the open bond by using the
approximatealgorithm to sequentially approximately contract a finite MPO slice of the patch into the top boundary MPS and return another MPS, until you've contracted everything above the open bond. You could then do the same starting from the bottom (where you would have to be a bit careful with how you pass the MPS and MPO slices to the algorithm, since the algorithm always assumes an MPO to be contracted into an MPS from below, where here you contract it from above). After this you have just the MPO-like slice with the open bond, and a top and bottom finite boundary MPS, at which point you can contract everything manually.So this is not really a plug-and-play built-in routine, but it can definitely be done using
MPSKit.approximate.pbrehmer commentedon May 1, 2025
From what I've head, in principle one can also use CTMRG for contracting finite environments with reasonable accuracy but I have no experience with this. I would be skeptical if that would be a viable approach for small-ish finite environments like the one you're trying to contract. In any case, the current CTMRG implementation only works for infinite lattices. The boundary MPS technique Lander suggested seems to be the way to go, I think.
Yue-Zhengyuan commentedon May 1, 2025
Indeed in YASTN they use the boundary MPS approach. I'll try to implement this feature in near future as an option to NTU (#144).
Yue-Zhengyuan commentedon May 6, 2025
@leburgel Looking at the method signature of
approximate:I wonder what's a good way to obtain the initial guess
ψ₀? Do you just use local SVD truncation on each bond? Actually I have one method based on some sort of "projectors" (it's exact for truncation of one bond on an OBC-MPS), but maybe you have a better approach.Yue-Zhengyuan commentedon May 6, 2025
In addition, do we already have a function to construct an$\langle \psi | \psi \rangle$ so I don't need to write again? To use the MPSKit functions it is easier to first merge the virtual legs of the bra network and the ket network.
InfinitePartitionFunctionfromlkdvos commentedon May 6, 2025
I think I added a
mpotensorfunction recently in PEPSKit that takes a sandwich and spits out the correctMPOTensor, which you can then use in MPSKit. In principle the goal would be to be able to work with the double-layer objects directly as well, but there are definitely some parts missing there so it can be a good short-term solution to map to a single-layer network first.Yue-Zhengyuan commentedon May 6, 2025
Suppose that for convenience, I merge the virtual indices in such a way that the two-layer cluster is converted to a single-layer network with the following choice of arrows:
and I compress the cluster horizontally starting from the left and right boundary. The right boundary is a very standard ket MPS, and the column transfer MPO acts on its left. However, the left boundary is a bra MPS, and the column transfer MPO acts on its right.
It seems that
adjointis not defined for aFiniteMPSin MPSKit (although it is forFiniteMPO). @leburgel @lkdvos Can MPSKit actually handle a bra MPS? If not, can you suggest a workaround?lkdvos commentedon May 8, 2025
@leburgel do you happen to have an example laying around of doing the required mapping to go from ket to bra?
leburgel commentedon May 8, 2025
I've definitely done this a few times, let me see if I can dig up an example when I find some time.
Yue-Zhengyuan commentedon Jul 16, 2026
@leburgel Do you have some time recently for this example of conjugating an MPS? I may start working on long-range expectation values (#396) based on it.
leburgel commentedon Jul 30, 2026
I did some digging and found a local script where I do something like this from a while back, for contracting partition functions of finite statistical mechanics models. Let me dust that off and I'll post a link to a corresponding gist soon.
However, if I did this again now I just wouldn't treat the last row/column as a
FiniteMPSinstance. To do this you have to conjugate it, just because MPSKit then conjugates it again in things likedot(::FiniteMPS, ::FiniteMPS). We can just use a sequentialedge_transfer_leftto contract in this last line, without having to conjugate anything.leburgel commentedon Jul 31, 2026
I bundled everything I already had on contracting finite patches as well as a few new aspects into a single script here. Sorry about the delay, but hopefully this helps @Yue-Zhengyuan. In particular, this should do exactly do what you mentioned in your comment above.
The details are entirely up for debate, but I definitely prefer the approach of
contract_network_via_edgefrom the gist, circumventing the need to conjugate a FiniteMPS at any point.leburgel commentedon Jul 31, 2026
After a bit of struggling I also managed to get the example running directly using the double-layer structure of the PEPS overlap network. This required quite a bit of hacky patches of MPSKit internals to work with
MPSKit.FiniteMPOandMPSKit.FiniteMPSwhere the number of legs of the MPS and MPO tensors is not the same on all sites. I'll try to clean this up and add the example next week, but for now the above should also work by squashing the local PEPS sandwiches down to rank-4 tensors usingPEPSKit.mpotensor.Linking the draft example using the double-layer structure here already, just in case I lose track of this.