Skip to content

Conversation

@lkdvos
Copy link
Member

@lkdvos lkdvos commented May 29, 2025

This PR refactors a bunch of the IDMRG implementations.

In particular, I've removed all hardcoded @plansor calls to make sure that the implementations are also working for MPS with multiple legs.
Additionally, somehow the edge handling for the find_groundstate and approximate implementations was very different.
This is now all the same, although I'm not entirely sure if this is correct, and in the future we should really look into de-duplicating this code, similar to what was done for VUMPS/VOMPS.

I've also added leading_boundary implementations to allow the PEPS algorithms to function.

Finally, I've fixed the following issue when working with IDMRG environments for statmech systems: because the expectation value scales multiplicative with system size, we have to renormalize the environments to ensure the values don't blow up. Previously, we did this in an asymmetric manner, absorbing the norm in the left environment. This was mostly to avoid taking square roots of negative real values, which would lead to complex environments whenever we split the norm equally over left and right.
However, this leads to a different problem: the norm of the right environment grows exponentially, while the left environment shrinks exponentially to ensure their product remains one. At some point, LAPACK complains and starts failing.
I've changed this to now always normalize the right environment to 1, and the left environment as before to ensure the inner product is 1.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the IDMRG implementations to support multi-leg MPS, unifies edge-handling logic, introduces a new AC2 utility across MPS types, and fixes environment normalization to prevent exponential norm growth.

  • Remove hardcoded @plansor calls and unify edge updates in find_groundstate and approximate!
  • Add a generic AC2 two-site tensor accessor for AbstractMPS and concrete MPS types
  • Change environment normalization to always scale the right env to norm 1 and update tests for the new convention

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/algorithms.jl Updated leading_boundary tests with dynamic bond dims and IDMRG2 case
src/states/multilinemps.jl Added AC2 methods for MultilineMPS
src/states/infinitemps.jl Added AC2 for InfiniteMPS
src/states/finitemps.jl Added AC2 for FiniteMPS
src/states/abstractmps.jl Documented AC2 on AbstractMPS
src/environments/infinite_envs.jl Updated normalize! to avoid norm blow-up
src/algorithms/statmech/idmrg.jl Implemented leading_boundary for IDMRG and IDMRG2 with unified edge logic
src/algorithms/derivatives/derivatives.jl Extended projection macros to pass kwargs to AC2
src/algorithms/approximate/idmrg.jl Refactored approximate! sweeps to use AC2
src/MPSKit.jl Included the new statmech idmrg.jl
Comments suppressed due to low confidence (1)

src/environments/infinite_envs.jl:110

  • The new normalization logic in normalize! (right envs to norm 1, left envs to overlap 1) isn't covered by existing tests. Consider adding unit tests, including cases with negative overlaps, to ensure both branches behave as intended.
normalize!(envs.GRs[i])

@codecov
Copy link

codecov bot commented May 29, 2025

Codecov Report

Attention: Patch coverage is 97.31183% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/algorithms/derivatives/derivatives.jl 77.77% 2 Missing ⚠️
src/algorithms/statmech/idmrg.jl 98.48% 2 Missing ⚠️
src/states/infinitemps.jl 83.33% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/MPSKit.jl 100.00% <ø> (ø)
src/algorithms/approximate/idmrg.jl 95.69% <100.00%> (-0.05%) ⬇️
src/algorithms/groundstate/idmrg.jl 98.38% <100.00%> (+0.08%) ⬆️
src/environments/infinite_envs.jl 94.59% <100.00%> (+0.03%) ⬆️
src/states/abstractmps.jl 61.90% <ø> (ø)
src/states/finitemps.jl 82.49% <100.00%> (+0.05%) ⬆️
src/states/multilinemps.jl 72.54% <100.00%> (+2.98%) ⬆️
src/states/infinitemps.jl 64.93% <83.33%> (+0.74%) ⬆️
src/algorithms/derivatives/derivatives.jl 93.75% <77.77%> (-0.13%) ⬇️
src/algorithms/statmech/idmrg.jl 98.48% <98.48%> (ø)

... and 1 file with indirect coverage changes

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

@lkdvos lkdvos enabled auto-merge (squash) May 30, 2025 14:37
Copy link
Member

@VictorVanthilt VictorVanthilt left a comment

Choose a reason for hiding this comment

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

Should we write some extra tests to test the handling of the edges of find_groundstate and approximate?

@lkdvos
Copy link
Member Author

lkdvos commented Jun 2, 2025

Yeah probably some checks are a good idea, especially given the reported issues in #292, which I still need to further delve into.

@lkdvos lkdvos force-pushed the ac2 branch 2 times, most recently from b69a3c5 to 7606dd8 Compare June 17, 2025 20:59
@lkdvos lkdvos disabled auto-merge June 18, 2025 14:13
@lkdvos lkdvos merged commit 2a7856c into master Jun 18, 2025
28 checks passed
@lkdvos lkdvos deleted the ac2 branch June 18, 2025 14:14
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.

3 participants