Skip to content

Conversation

@pbrehmer
Copy link
Collaborator

@pbrehmer pbrehmer commented Jan 21, 2026

In this PR we will finally add a dedicated C4v CTMRG algorithm. I started with the standard version using eigh projectors but we can easily also implement a QR version by making a C4vQRProjector algorithm and the corresponding c4v_projector method. (@Yue-Zhengyuan said he would be up for doing this :-)) This C4v routine is completely differentiable using naive AD, :diffgauge and :fixed mode.

Note that I needed to generalize the gauge_fix method for CTMRGEnvs to not have separate methods for all the C4v stuff. Same thing is true for environment initialization, where it would be nice to have an initialize_environment method where one can dispatch on an algorithm. Here we'll have to wait until we merge #264.

Let me also say that it would eventually be nicer to have a dedicated C4vCTMRGEnv since this would make things cleaner. However, this would entail a larger rewrite of quite a few things, so I propose that I postpone this rewriting and cleaning up process until I have more resources for that again. (In general I feel like we should clean up and refactor some stuff again since the codebase has been growing quite a bit.) Anyways, for now it would be nice to have a working C4v CTMRG that people can use.

This is still very much under construction but I'll finish up things and adjust the test suite tomorrow.

Closes #258.

@pbrehmer pbrehmer self-assigned this Jan 21, 2026
@pbrehmer pbrehmer marked this pull request as draft January 21, 2026 19:12
@github-actions
Copy link
Contributor

github-actions bot commented Jan 22, 2026

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

@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

❌ Patch coverage is 5.01792% with 265 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/utility/eigh.jl 0.00% 127 Missing ⚠️
src/algorithms/ctmrg/c4v.jl 0.00% 54 Missing ⚠️
...rithms/optimization/fixed_point_differentiation.jl 0.00% 38 Missing ⚠️
src/algorithms/ctmrg/gaugefix.jl 0.00% 35 Missing ⚠️
src/algorithms/ctmrg/projectors.jl 61.11% 7 Missing ⚠️
src/algorithms/select_algorithm.jl 50.00% 2 Missing ⚠️
src/algorithms/ctmrg/ctmrg.jl 50.00% 1 Missing ⚠️
src/environments/ctmrg_environments.jl 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/Defaults.jl 85.71% <ø> (ø)
src/PEPSKit.jl 100.00% <ø> (ø)
src/algorithms/ctmrg/sequential.jl 87.30% <ø> (-11.12%) ⬇️
src/algorithms/ctmrg/simultaneous.jl 82.35% <ø> (-17.65%) ⬇️
src/utility/svd.jl 82.99% <ø> (-4.51%) ⬇️
src/algorithms/ctmrg/ctmrg.jl 83.60% <50.00%> (-6.87%) ⬇️
src/environments/ctmrg_environments.jl 47.09% <0.00%> (-34.41%) ⬇️
src/algorithms/select_algorithm.jl 17.39% <50.00%> (-57.61%) ⬇️
src/algorithms/ctmrg/projectors.jl 50.84% <61.11%> (-32.18%) ⬇️
src/algorithms/ctmrg/gaugefix.jl 0.00% <0.00%> (-97.23%) ⬇️
... and 3 more

... and 28 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
Copy link
Member

This PR already involves lots of things. For QR CTMRG, besides getting projectors from QR instead of SVD, the way to enlarge corners is also different. Maybe we focus on the eigh version here only, and handle QR CTMRG in a separate PR.

@pbrehmer
Copy link
Collaborator Author

This PR already involves lots of things. For QR CTMRG, besides getting projectors from QR instead of SVD, the way to enlarge corners is also different. Maybe we focus on the eigh version here only, and handle QR CTMRG in a separate PR.

Completely agree, I anyway assumed this would go into a separate PR. Also I apologize for making this PR so big, I found it somewhat hard to split up the changes needed to make the whole apparatus compatible with C4v CTMRG.

@Yue-Zhengyuan
Copy link
Member

it would eventually be nicer to have a dedicated C4vCTMRGEnv since this would make things cleaner. However, this would entail a larger rewrite of quite a few things

One approach is to make C4vCTMRGEnv (and associated functions) independent from general CTMRG routines (behave like a self-sufficient submodule) for now and just provide a C4vCTMRGEnv-to-CTMRGEnv converter. At least the forward pass should be concise enough. We can think about reusing or rewriting existing CTMRG functions in later PRs. Does this still need a large rewrite?

@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

❌ Patch coverage is 87.16216% with 38 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/utility/eigh.jl 83.21% 23 Missing ⚠️
src/algorithms/ctmrg/c4v.jl 78.57% 12 Missing ⚠️
src/algorithms/select_algorithm.jl 71.42% 2 Missing ⚠️
src/algorithms/ctmrg/projectors.jl 94.73% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/Defaults.jl 85.71% <ø> (ø)
src/PEPSKit.jl 100.00% <ø> (ø)
src/algorithms/ctmrg/ctmrg.jl 90.76% <100.00%> (+0.29%) ⬆️
src/algorithms/ctmrg/gaugefix.jl 97.87% <100.00%> (+0.65%) ⬆️
src/algorithms/ctmrg/sequential.jl 98.41% <ø> (ø)
src/algorithms/ctmrg/simultaneous.jl 100.00% <ø> (ø)
...rithms/optimization/fixed_point_differentiation.jl 93.18% <100.00%> (+1.45%) ⬆️
src/environments/ctmrg_environments.jl 81.50% <100.00%> (ø)
src/utility/svd.jl 87.50% <ø> (ø)
src/algorithms/ctmrg/projectors.jl 83.33% <94.73%> (+0.31%) ⬆️
... and 3 more

... and 3 files with indirect coverage changes

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

@pbrehmer
Copy link
Collaborator Author

One approach is to make C4vCTMRGEnv (and associated functions) independent from general CTMRG routines (behave like a self-sufficient submodule) for now and just provide a C4vCTMRGEnv-to-CTMRGEnv converter. At least the forward pass should be concise enough. We can think about reusing or rewriting existing CTMRG functions in later PRs. Does this still need a large rewrite?

I have thought about this but this would be rather annoying as an intermediate stage I think since it would break a lot of the general CTMRG functions that I use now leading to a lot of code duplication and extra work (that I don't really have time for at the moment). I'd rather do it once but properly. I hope that's fine!

@pbrehmer pbrehmer marked this pull request as ready for review January 26, 2026 17:06
@pbrehmer
Copy link
Collaborator Author

I think in principle the tests should run through now. Once we have merged #264 and some details have been settled, I will add a small example to the docs on how to use C4v CTMRG.

@Yue-Zhengyuan
Copy link
Member

Yue-Zhengyuan commented Jan 27, 2026

Since we are going to also introduce CTMRG on triangular lattices in #324 (which also has a C6v specialization), it may be better to reorganize files into sub-folders under src/algorithms/ctmrg.

  • square: The generic Sequential & Simultaneous CTMRG on the square lattice for any unit cell sizes.
  • c4v: The specialization with C4v symmetry and 1x1 unit cell, with projectors found from eigh.
  • c4vqr (TODO): The specialization with C4v symmetry and 1x1 unit cell, with projectors found from qr.
  • triangle (add Triangular CTMRG #324): The generic Simultaneous CTMRG on the triangular lattice for any unit cell sizes.
  • c6v and c6vqr: The specialization with C6v symmetry (for triangular or honeycomb lattice), with projectors found from eigh or qr.

Similarly, the pure contraction functions in src/algorithms/contractions/ctmrg_contractions.jl (this file is already painfully long) may also be split into several files under src/algorithms/contractions/ctmrg. (This can be done in later refactoring PRs).

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.

[Feature] C4v CTMRG

3 participants