Skip to content

Add Neighborhood Tensor Update (NTU)#144

Draft
Yue-Zhengyuan wants to merge 45 commits intoQuantumKitHub:mainfrom
Yue-Zhengyuan:bondenv-ntu
Draft

Add Neighborhood Tensor Update (NTU)#144
Yue-Zhengyuan wants to merge 45 commits intoQuantumKitHub:mainfrom
Yue-Zhengyuan:bondenv-ntu

Conversation

@Yue-Zhengyuan
Copy link
Copy Markdown
Member

@Yue-Zhengyuan Yue-Zhengyuan commented Feb 27, 2025

(Finally, after being delayed for over a year)


This PR adds the Neighborhood Tensor Update (NTU, arXiv 2107.06635), which works for both iPEPS and iPEPO, and supports nearest neighbor 2-site gates and arbitrary MPO gates (in particular, the next-nearest neighbor 3-site MPO).

One caveat to be emphasized is that after applying an N-site gate (N > 2), the updated bonds are truncated sequentially without going back. In other words, it does not perform an ALS optimization of all site tensors that are updated, since producing the environment surrounding a general cluster of sites is complicated, and the following ALS optimization will be extremely costly.

When truncating a bond after applying a time evolution gate, the NTU uses some neighboring tensors as the bond environment, instead of using only a few bond weights (simple update) of the full iPEPS approximated by CTM (full update), "interpolating" between the two extremes. Currently the NN, NN+ and NNN bond environments (see description in the YASTN package) are implemented.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 27, 2025

Codecov Report

❌ Patch coverage is 96.57143% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/algorithms/time_evolution/ntupdate.jl 95.12% 6 Missing ⚠️
src/algorithms/contractions/bondenv/benv_tools.jl 88.23% 4 Missing ⚠️
src/algorithms/time_evolution/get_cluster.jl 75.00% 1 Missing ⚠️
src/utility/util.jl 83.33% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/algorithms/contractions/bondenv/benv_ntu.jl 100.00% <100.00%> (ø)
src/algorithms/contractions/bondenv/gaugefix.jl 100.00% <100.00%> (ø)
src/algorithms/time_evolution/ntupdate3site.jl 100.00% <100.00%> (ø)
src/algorithms/time_evolution/simpleupdate.jl 97.10% <100.00%> (ø)
src/algorithms/truncation/bond_tensor.jl 100.00% <100.00%> (ø)
src/algorithms/time_evolution/get_cluster.jl 84.21% <75.00%> (+0.87%) ⬆️
src/utility/util.jl 69.69% <83.33%> (+0.87%) ⬆️
src/algorithms/contractions/bondenv/benv_tools.jl 89.47% <88.23%> (+39.47%) ⬆️
src/algorithms/time_evolution/ntupdate.jl 95.12% <95.12%> (ø)

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Yue-Zhengyuan Yue-Zhengyuan marked this pull request as ready for review May 7, 2025 02:58
@Yue-Zhengyuan Yue-Zhengyuan marked this pull request as draft May 26, 2025 03:37
@lkdvos lkdvos force-pushed the master branch 2 times, most recently from ad4945f to 37ace4c Compare June 13, 2025 12:14
@Yue-Zhengyuan Yue-Zhengyuan changed the title Add NTU bond environments Add Neighborhood Tensor Update (NTU) Oct 24, 2025
@Yue-Zhengyuan Yue-Zhengyuan self-assigned this Nov 12, 2025
@Yue-Zhengyuan Yue-Zhengyuan force-pushed the bondenv-ntu branch 2 times, most recently from 85d2c44 to ecbbee4 Compare November 30, 2025 01:56
@Yue-Zhengyuan Yue-Zhengyuan reopened this Apr 8, 2026
@Yue-Zhengyuan Yue-Zhengyuan marked this pull request as ready for review April 8, 2026 08:39
@Yue-Zhengyuan
Copy link
Copy Markdown
Member Author

Some commits are based on #348, #349.

@Yue-Zhengyuan Yue-Zhengyuan marked this pull request as draft May 4, 2026 04:42
@Yue-Zhengyuan
Copy link
Copy Markdown
Member Author

I'll keep this as a draft for a while to not waste resources on CI.

@QuantumKitHub QuantumKitHub deleted a comment from github-actions Bot May 6, 2026
Copy link
Copy Markdown
Member Author

@Yue-Zhengyuan Yue-Zhengyuan left a comment

Choose a reason for hiding this comment

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

Some comments that may help with reviewing.

twistdual!(ket, ax)
h === nothing && continue
axes, biperm = _permute_to_first(axes, ax)
ket = permute(h, ((1,), (2,))) * permute(ket, biperm)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is slightly unfortunate that I have to permute h every time, because I decide to put the bra legs in front of the ket legs, and all legs in the codomain (which was the result of using ncon).

Comment thread src/algorithms/time_evolution/simpleupdate.jl
Comment on lines +75 to +86
a, X = if stype1 == :first
bond_tensor_first(A; trunc = qrtrunc)
else
@assert stype1 == :middle
bond_tensor_midnext(A; trunc = qrtrunc)
end
b, Y = if stype2 == :last
bond_tensor_last(B; trunc = qrtrunc)
else
@assert stype2 == :middle
bond_tensor_midprev(B; trunc = qrtrunc)
end
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I may better explain why the middle sites need different treatment from the first/last sites when factoring out the reduced bond tensor.

Consider the 3-site gate MPO acting on PEPS. Its virtual bond dimension is $d^2$. For the first site, we know that we can first factor out a reduced bond tensor (carrying one physical leg) which is acted on by the gate.

    |
--- X ---  --- a ---
    |            ↘

The dimension of the leg connecting X and a is $Dd$, and number of elements (size) in truncated a (which is going to be optimized with ALS) is $D^2 d^2$.

But if we keep the physical leg in X,

    |
--- X ---  --- a ---
    | ↘

then after applying the gate, the leg connecting X, a has dimension $D d^2$, while the size of truncated a remains $D^2 d^2$. This increased the dimension of the bond environment surrounding a, thus being less efficient.

The same argument applies to the last site, for which it is also better to transfer the physical leg to the bond tensor b to reduce the dimension of the bond environment.

However, things are different for middle sites.

     ╱    
--- M --
  ╱ |     
    ↓     
--- g ---
    ↓     

After applying the gate, the cluster bond dimension increases to $D d^2$. To truncate the left (previous) bond, if we still transfer the physical leg to the bond tensor

                |
--- b ---   --- Y ---
      ↘         |

The leg connecting b, Y have dimension $D d^3$, and truncated b has size $D^2 d^4$. But if we keep the physical leg in Y,

                |
--- b ---   --- Y ---
                | ↘

then the leg connecting b, Y has a smaller dimension $D d^2$, with truncated b also having a smaller size $D^2 d^2$. This can make the bond truncation less costly.

There is also an important subtlety: for middle sites, the unitary tensors X or Y also contains the effect of the gate, in contrast to the first/last tensors, for which X, Y can be found prior to applying the gate. Thus, it seems that varying the bond tensors alone cannot reach the optimal truncation result except for NN gates.


Finally, a technical question on whether it is good to use symbols to distinguish the different cases.

function bond_tensor_midnext(A::PEPSTensor; kwargs...)
X, a = left_orth!(permute(A, ((1, 2, 4, 5), (3,)); copy = true); kwargs...)
X = permute(X, ((1,), (2, 5, 3, 4)))
a = insertrightunit(a, 1)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For middle tensors, the physical leg is not transferred to the reduced bond tensor a. A trivial physical leg is added in order to fit the current bond_truncate code.

showinfo = (iter == 1) || (iter % check_interval == 0) || (iter == it.nstep)
!showinfo && continue
# bond weight change
Δλ = hasproperty(info0, :wts) ? compare_weights(info.wts, info0.wts) : NaN
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Here the bond weights are simply the bond_truncate SVD spectra. They are not the same as those produced by BP gauge fixing. For the first iteration, since the initialization does not provide information on bond weights, Δλ is set to NaN.

If we incorporate BP gauge fixing in the future, the bond truncation spectra should be replaced by the diagonalized BP messages. In this case, we can also find Δλ for the first step by gauge fixing the initial state.

Comment on lines +33 to +40
struct NTUState{S <: InfiniteState, N <: Number}
"number of performed iterations"
iter::Int
"evolved time"
t::N
"PEPS/PEPO"
psi::S
end
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If we incorporate BP gauge fixing, NTUState should also include the BPEnv. It will also be used to construct bond environments. But for now I just leave it out.

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.

1 participant