Skip to content

Add regression test for long-range SvdCut with identity components - #551

Open
lkdvos wants to merge 1 commit into
mainfrom
issue550
Open

lkdvos wants to merge 1 commit into
mainfrom
issue550

Conversation

@lkdvos

@lkdvos lkdvos commented Oct 30, 2026

Copy link
Copy Markdown
Member

Closes #550.

The bug reported in #550 is already fixed on main by #539. This PR only adds the issue's reproducer as a regression test.

Cause (v0.14.0)

In v0.14.0, the identity component of C was projected out with an unnormalized identity: t = tr(1ᴴ C), without dividing by dim(P). The gauge transformation stays exact in exact arithmetic, but the identity component is never actually removed. The leftover t grows by roughly a factor of dim(P) per site along an interaction channel; for the MWE, the site waiting to absorb it reached norm(C) ≈ 4e11. The result is catastrophic cancellation that gets worse with interaction distance. Traceless operators have t = 0, so they were unaffected.

#539 rewrote the canonicalization as a QR of [1 C; 0 A] with the identity as its first column, which normalizes the projection correctly.

Max |⟨H⟩ - ⟨Hc⟩| for the MWE in #550 (n ⊗ n, trunctol(rtol = 0), 5 random states):

sites v0.14.0 main
(5, 6) 2e-15 2e-16
(5, 7) 4e-14 2e-16
(5, 25) 0.078 7e-16

Test

test/algorithms/changebonds.jl: n ⊗ n on sites (5, 25) of a 30-site ℂ^4 chain, compressed with SvdCut(; trunc = trunctol(; rtol = 0.0)). The test checks that the expectation value matches to rtol = 1e-10. The existing tests from #539 only cover nearest-neighbour terms, which v0.14.0 already handled correctly.

🤖 Generated with Claude Code

Compressing a FiniteMPOHamiltonian with a long-range interaction whose
operators have non-zero trace lost precision geometrically with distance
in v0.14.0 (#550). This was fixed by the canonical-form rewrite in #539;
this test guards against regressions.

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

This branch has not been deployed

No deployments
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.

Compressing Hamiltonians with certain long-range interactions loses precision

1 participant