Skip to content

Renormalizer interface for TRG#193

Closed
Yue-Zhengyuan wants to merge 7 commits into
masterfrom
iterable-trg
Closed

Renormalizer interface for TRG#193
Yue-Zhengyuan wants to merge 7 commits into
masterfrom
iterable-trg

Conversation

@Yue-Zhengyuan

Copy link
Copy Markdown
Member
  • TRG is now a pure algorithm struct (@kwdef, kwargs-only) storing trunc and maxiter
  • New Renormalizer type holds algorithm state (TRGState) and is iterable via Base.iterate
  • _renorm_step! dispatches on algorithm type, making the interface extensible
  • step! wraps Base.iterate; run! returns (final_state, norms)
  • TRGState holds the network tensor; get_tensor extracts it
  • Finalizer no longer needed for TRG — users inspect intermediate states via iteration
  • gs_degeneracy.jl refactored: primary methods take tensors directly, scheme wrappers delegate
  • simple_scheme union updated (TRG removed)
  • All tests, examples, and docs updated

Yue-Zhengyuan and others added 2 commits June 18, 2026 14:08
- TRG is now a pure algorithm struct (@kwdef, kwargs-only) storing trunc and maxiter
- New Renormalizer type holds algorithm state (TRGState) and is iterable via Base.iterate
- _renorm_step! dispatches on algorithm type, making the interface extensible
- step! wraps Base.iterate; run! returns (final_state, norms)
- TRGState holds the network tensor; get_tensor extracts it
- Finalizer no longer needed for TRG — users inspect intermediate states via iteration
- gs_degeneracy.jl refactored: primary methods take tensors directly, scheme wrappers delegate
- simple_scheme union updated (TRG removed)
- All tests, examples, and docs updated

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.11538% with 29 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/schemes/renormalizer.jl 39.28% 17 Missing ⚠️
src/schemes/trg.jl 76.31% 9 Missing ⚠️
src/utility/gs_degeneracy.jl 89.65% 3 Missing ⚠️
Files with missing lines Coverage Δ
src/schemes/tnrscheme.jl 95.45% <ø> (+9.74%) ⬆️
src/utility/cft.jl 90.16% <100.00%> (+1.54%) ⬆️
src/utility/gs_degeneracy.jl 92.30% <89.65%> (-4.17%) ⬇️
src/schemes/trg.jl 77.77% <76.31%> (-13.89%) ⬇️
src/schemes/renormalizer.jl 39.28% <39.28%> (ø)

... and 10 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 left a comment

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.

There are a few things I'm not sure about GSD calculation.

Comment thread src/utility/gs_degeneracy.jl Outdated
# Compute normalized eigenvalues
D, _ = eig_full(T)
function ground_state_degeneracy(T::AbstractTensorMap, unitcell::Int = 1)
tm = _row_transfer_matrix(T, unitcell)

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.

Do we have examples to check if anti-PBC (NS sector) should be used for fermionic systems?

@Yue-Zhengyuan

Copy link
Copy Markdown
Member Author

I suggest to make a release before you decide to merge this PR.

Comment thread src/utility/gs_degeneracy.jl
@Yue-Zhengyuan

Copy link
Copy Markdown
Member Author

Loop-TNR with the new interface is available at https://github.com/QuantumKitHub/TNRKit.jl/tree/iterable-looptnr. You may also want to have a look if TRG is too simple to justify some design choices.

@Yue-Zhengyuan Yue-Zhengyuan changed the title Refactor TRG to iterable Renormalizer interface Renormalizer interface for TRG Jun 19, 2026
@VictorVanthilt

Copy link
Copy Markdown
Member

At this point I'm not conviced this new interface actually gains us anything. The code to run a simulation is now strictly more complicated. We just published a paper in Scipost codebase with code examples that use the run! and finalizer interface.

What can you achieve by making the schemes an iterable, that you cannot with the current interface?

Either way, if we were to add the iterable interaface as an "expert mode" the previous interface of run(TRG(T), truncrank(16), maxiter(25)) should still be valid code imo.

@Yue-Zhengyuan

Copy link
Copy Markdown
Member Author

What can you achieve by making the schemes an iterable, that you cannot with the current interface?

Strictly speaking, nothing is unique the new interface if one uses step! to manually do one RG step at one time.

One of my main goals is getting rid of the finalizers, which only have access to the network tensors at the current RG step, and need users to know in advance its return type in order to construct. The iterator can be breaked more easily.

@Yue-Zhengyuan

Copy link
Copy Markdown
Member Author

run(TRG(T), truncrank(16), maxiter(25)) should still be valid code imo

One of my design philosophy is that the TNR algorithms only stores the parameters, not the tensors. So TRG(T) fundamentally conflicts with the new interface.

Anyway, I understand that this is quite a big breaking change. If not accepted in the end, I can still backport some deduplication I made in the process.

- Rename TNRAlgorithm → TNRParams (pure parameter descriptors)
- New TRGParams <: TNRParams with @kwdef defaults (trunc, maxiter)
- Old TRG{E,S,TT} <: TNRScheme{E,S} restored as state type
- Renormalizer wraps TRGParams + TRG for iterable RG stepping
- Legacy run!(::TRG, trunc, criterion) delegates to new interface
- Add iterable TRG test set alongside restored old-style tests
- Finalizer support removed from TRG run!; use iterable for per-step data

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown

Your PR no longer requires formatting changes. Thank you for your contribution!

@Yue-Zhengyuan

Copy link
Copy Markdown
Member Author

Close in favor of #195.

@Yue-Zhengyuan Yue-Zhengyuan deleted the iterable-trg branch June 20, 2026 02:57
@Chenqitrg

Copy link
Copy Markdown
Contributor

Discussed with @Yue-Zhengyuan yesterday and feel it is really breaking. But it is natural in the following sense:

  1. Tensors themself is not related to RG scheme. For example, TRG, BTRG, et, their tensors are all the same, which is 1x1 unit cell. Therefore, all other algorithms that hold for 1x1 unit cell should be easily inherented
  2. Algorithm is something only depend on parameters and scheme we choose, therefore should be independent from tensors. For example, LoopTNR is some algorithm that hold for all TN with unit cell 2x2
  3. TNR or TRG is a monoid, therefore, algorithm can act on unit cell tensors by a multiplication map (Renormalizier). $TRG \times Tensor \rightarrow Tensor$.

@Yue-Zhengyuan Yue-Zhengyuan removed the request for review from VictorVanthilt June 20, 2026 05:19
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.

4 participants