Skip to content

Fix stackoverflow in renormalize_southwest_corner#344

Merged
leburgel merged 3 commits intomasterfrom
lb/fix_stackoverflow
Apr 10, 2026
Merged

Fix stackoverflow in renormalize_southwest_corner#344
leburgel merged 3 commits intomasterfrom
lb/fix_stackoverflow

Conversation

@leburgel
Copy link
Copy Markdown
Member

Bumped into this by accident: using renormalize_southwest_corner directly on an enlarged corner and its projectors gave a stackoverflow, must have been a typo.

@Yue-Zhengyuan
Copy link
Copy Markdown
Member

Looking back on this, it seems that all four renormalize_xxxx_corner(quadrant, P_left, P_right) are simply wrappers to the same renormalize_corner(quadrant, P_left, P_right). How about we directly write, for example,

function renormalize_northwest_corner((row, col), enlarged_env, P_left, P_right)
    return renormalize_corner(
        enlarged_env[NORTHWEST, row, col],
        P_left[NORTH, row, col],
        P_right[WEST, _next(row, end), col],
    )
end

to reduce one layer of wrapping?

@leburgel
Copy link
Copy Markdown
Member Author

I don't think this works, because the enlarged_env can also contain a sparse representation of the enlarged corners, as EnlargedCorner instances. So the extra layer is required to dispatch to the EnlargedCorner implementations like

function renormalize_southwest_corner(ec::EnlargedCorner, P_left, P_right)
    return renormalize_southwest_corner(ec.E_1, ec.C, ec.E_2, P_left, P_right, ec.A)
end

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
...lgorithms/contractions/ctmrg/renormalize_corner.jl 52.63% <100.00%> (+8.77%) ⬆️

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

Is it convenient to add some test coverage here? In #326, I observed that tests only cover half of the CTMRG code.

@leburgel
Copy link
Copy Markdown
Member Author

Yes, we should add some coverage here before merging, seems like a good opportunity.

@leburgel
Copy link
Copy Markdown
Member Author

leburgel commented Apr 9, 2026

I added a small test to unblock this for now. We can add to this test stub afterwards until all contractions are covered by just comparing dense and sparse versions, even if there are some that aren't actually used in any of the algorithms yet.

Copy link
Copy Markdown
Member

@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.

Good to go for me. Though we need to reduce duplication of tests some time in the future.

@leburgel leburgel merged commit 267d918 into master Apr 10, 2026
59 of 63 checks passed
@leburgel leburgel deleted the lb/fix_stackoverflow branch April 10, 2026 07:43
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.

2 participants