# Non-consecutive swap gates

+1 vote

Hello,

I'm interested in simulating next-to-nearest neighbor (nnn) interactions using trotter gates, which requires swap gates.

For a lattice of site N, this requires implementing 6(N-2) gates when doing a right/left sweep

• Swap gate between j+1,j+2
• nnn gate between j,j+2
• swap gate between j+1,j+2
• repeat for right sweep

However, one could think about first ordering the sites in an odd/even order, apply the nnn gates right and left and reorder the sites again. This method only requires 4(N-2) gates.

• Swap gates such that the final order is: 1357...2468...
• Apply the nnn gates in the right sweep: (13)(35)...(24)(46)...
• Apply the nnn gates in the left sweep
• Inverse swap gates such that the final order is: 12345....

My question are the following:

1. if I'm careful enough to check that the position is set to the first site before applying the nnn gates, does this construction respect the orthogonality condition?
2. Since swap gates don't accept two sites far apart, I was thinking about grouping the swap gates into an MPO and use applyMPO. However, this MPO scales with N because we will swap sites very far apart. Could one instead apply the gates without the svdBond and the position steps?

Thank you for the help!

commented by (8.5k points)
I'm not sure that the site reordering operation:

12345678... -> 1357...2468...

will be efficient, since that requires some very nonlocal swapping of sites (on the order of the system size). That introduces a lot of entanglement into your state, and you would see the bond dimension of your MPS grow a lot even before you apply your gates. Therefore, I think the cost of doing that reordering will outway the benefits of reducing the number of gate applications. If I were to implement it, I would do it the way you initially proposed.

-Matt

+1 vote
answered by (46.9k points)
selected by

Thanks for the good question. To officially answer the question, I agree with Matt's answer above. Unless you have a very specific understanding of the entanglement properties of the wavefunction you're working with, such that it can be compactly represented as an MPS in both site orderings (which is very unlikely given how non-locally they are related to each other) then probably you will encounter very large bond dimensions going to the non-local site order.

If you are definitely going to stick to nnn interactions at most, though, and if you are interesting in doing some by-hand coding beyond just using the ITensor gateTEvol function, then there are some other things you may want to try. No guarantee these are faster though the first one probably is:

1. instead of applying an explicit swap gate, do a "virtual swap gate" by just contracting the MPS tensors for sites j+1,j+2 then SVD'ing them back apart so that the "U" tensor carries the j+2 site index (and the left link index from the original j+1 MPS tensor). ITensor lets you control which indices end up on U by which indices you pass to the svd function. Then do a similar contract-and-SVD to 'swap' back. It saves the extra computation time of applying an explicit gate to the MPS.

2. try contracting 3 MPS tensors in a row, so j,j+1,j+2 and then applying all possible nn and nnn gates acting on those 3 sites. This has an advantage that it can reduce the total truncation errors incurred because no truncation is needed while applying those gates. Now use the SVD to factorize off the "j" site and left link index into an update MPS tensor for site j. Save the remaining (S*V) tensor from the SVD and contract it with the MPS tensor for site j+3 to go to the next configuration. This approach may not be the most efficient, though, due to working with the larger "core" tensor having one extra site index. But it could be more efficient due to less swapping and more accurate due to fewer truncations.

Best regards,
Miles

commented by (340 points)
Thank you Matt and Miles,

Indeed the growth of entanglement is not something that I'm concerned about. In my case, I'm performing real-time evolution on a MPDO to find the NESS so entanglement is not a problem.

I'm for sure going to implement the second algorithm in the situations where I need a smaller error. I couldn't understand the difference between number 1 and directly implementing a "non-virtual swap gate".  Is the only difference not calling the .position() method?
commented by (46.9k points)
Hi, thanks for explaining some more about your study. But I would say you almost certainly do need to be concerned about growth of entanglement if you hope to perform an accurate and efficient calculation unless you are willing to be restricted to very small system sizes (10 sites or so) or very short times of order 1. Perhaps you mean there’s something special about your study where you expect the MPDO bond dimensions to remain small no matter the ordering of your sites though?

Regarding method #1, the difference is that in a “non-virtual swap gate” i.e. an actual swap gate, you would need to (1) make the swap gate itself as a tensor, with components stored in memory, and (2) perform the contraction of this swap gate with your MPS before finally (3) truncating the MPS back apart to finish the swapping of the two sites. The virtual swap gate idea is that you avoid doing step (1) entirely, only do (2) inasmuch as you contract the two MPS tensors together (but don’t act on them with any gate) and then do (3) but ordering the indices in the SVD step so that they get exchanged and site j+2 goes onto U instead of site j+1. The pattern of indexing the ITensor gates is also a little bit different but you’d have to diagram it all out to see what I mean.

Hope that clarifies -

Miles
commented by (340 points)
Hi,

About my study: in my case, I have a unique NESS which means that doing time evolution will always lead you to a unique MPS (which has a low bond dimension). To find this state, one simply evolves long enough and keeps increasing the bond dimension. Since the state is unique, you can afford to make "mistakes" during this artificial time-evolution and only be careful at the very end. Thus my comment about not being concern about the entanglement growth. Also, I can always reorthogonalize the MPS every few steps to iron out any "mistakes" done during the evolution.

The answer clarifies a lot. Thank you both very much!
commented by (46.9k points)
Thanks, that does clarify things. It will still be good to exercise caution though. Imagine if the low bond dimension MPS you reached at the end was similar to a dimer state with singlets connecting sites (1,2) (3,4) (5,6) etc. Even though it would be an MPS of only bond dimension 2 at most, if you switched to the other site ordering of 1,3,5,... 2,4,6... then representing this state as an MPS would require exponential resources as a function of N.
commented by (340 points)
Yes, I see how my initial suggestion could be problematic