Skip to content

Conversation

@lkdvos
Copy link
Member

@lkdvos lkdvos commented Apr 29, 2025

This PR changes the changebonds implementations to first normalize before computing the truncated SVD.
As we are not using the resulting S, this effectively has no influence on truncations like truncdim, however for truncbelow this will now truncate a normalized spectrum, therefore being a bit more "scale-invariant".
Effectively, this is manually converting the absolute truncation schemes defined in TensorKit to relative ones.

@codecov
Copy link

codecov bot commented Apr 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ
src/algorithms/changebonds/optimalexpand.jl 100.00% <100.00%> (ø)
src/algorithms/changebonds/randexpand.jl 100.00% <100.00%> (ø)

... and 2 files 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 changed the title Make changebonds truncation use relative truncation schemes. Make changebonds truncation use relative truncation schemes Apr 29, 2025
@lkdvos lkdvos requested review from VictorVanthilt and leburgel May 5, 2025 15:01
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.

Makes sense, this should probably be reflected in the docstring. The original paper seems to only talk about truncdim-type behaviour so defining what we do with truncbelow seems okay.

Copy link
Member

@leburgel leburgel left a comment

Choose a reason for hiding this comment

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

Normalizing makes sense to me, and if I understand correctly this now makes sure the squared singular values sum to 1 so the choice of normalization here is perfect for MPS.

I think it's exactly the same so I'm fine with approving as is, but I thought it would be slightly more natural to normalize the AC2 resulting from the effective Hamiltonian right away, rather than normalizing after absorbing in the null spaces. But this would give just the same result, right?

And just out of curiosity, where did you encounter a need to normalize before performing the SVD? Is there something that went wrong when using the algorithms?

@lkdvos
Copy link
Member Author

lkdvos commented May 5, 2025

if I understand correctly this now makes sure the squared singular values sum to 1

If you mean the singular values of the intermediate tensor: yes, this rescales the spectrum such that the singular values sum to 1.
If you mean the resulting MPS, not really - we're discarding the S to begin with, so this overall scale doesn't factor into the final result. Given that we are truncating the U and V, these are not isometries but rather projectors, so depending on the amount of truncation this process "loses norm". Interestingly though, that doesn't really matter all that much: since these are orthogonal to the original MPS I don't think this affects the final norm.

it would be slightly more natural to normalize the AC2 resulting from the effective Hamiltonian right away, rather than normalizing after absorbing in the null spaces. But this would give just the same result, right?

It wouldn't, the AC2 gets projected onto the nullspace, ie the norm is not preserved.

where did you encounter a need to normalize before performing the SVD?

With the finite temperature methods (but this would also be relevant for boundary MPS type applications), the norm of the finite MPS or the MPO actually has meaning. In my case, it is precisely the value of the partition function, which is extensive, so it is actually possible to blow up certain entries if you naively ignore this and go to larger chain lengths.
In order to combat this, there are various ways to redistribute global scalars and factorize out normalizations. One option is to take the norm of the mpo and divide each tensor by the N-th square root, an alternative is to simply normalize the local tensors to have frobenius norm one.

While I was playing around with these different methods to see which one makes the most sense, the results changed quite drastically, because depending on the norm of the operator and MPS, O * psi can have a very large or very small norm, and using truncbelow(1e-5) is not a scale-invariant setting. Basically, even though the results are consistent, the truncation parameter discriminates between the two.

Long story short, we should really just have truncbelow(; atol, rtol), but since that is not yet a thing (coming soon ™️ ), this fixes that in the meantime.

@lkdvos lkdvos merged commit 59c49b2 into master May 5, 2025
28 checks passed
@lkdvos lkdvos deleted the changebonds branch May 5, 2025 20:11
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