Skip to content

Use MatrixAlgebraKit's SVD pullbacks#335

Open
pbrehmer wants to merge 13 commits intomasterfrom
pb-mak-svd-pullbacks
Open

Use MatrixAlgebraKit's SVD pullbacks#335
pbrehmer wants to merge 13 commits intomasterfrom
pb-mak-svd-pullbacks

Conversation

@pbrehmer
Copy link
Collaborator

So far we defined a custom SVD pullback inside of PEPSKit which copied over some old TensorKit code. Here I remove that old part and instead use MatrixAlgebraKit's svd_pullback! and svd_trunc_pullback!. This makes all the SVD routines also more consistent with the newly added eigh forward and pullback code.

As a side note: What initially held me back from immediately using MAK's pullbacks was that it didn't implement any Lorentzian broadening. However, it does use a safe_inv with a cutoff tolerance which should in principle work just as well. So here I decided to completely scrap the Lorentzian broadening code and only use save_invs via MAK's pullbacks. To be able to adjust the degeneracy/broadening tolerance, I added a degeneracy_tol to all the pullback structs.

@kshyatt
Copy link
Member

kshyatt commented Feb 17, 2026

Oh man this will make life a lot easier for the GPU support, thanks for doing this!

@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

❌ Patch coverage is 90.90909% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/utility/eigh.jl 71.42% 2 Missing ⚠️
src/utility/svd.jl 92.30% 2 Missing ⚠️
Files with missing lines Coverage Δ
src/Defaults.jl 85.71% <ø> (ø)
src/PEPSKit.jl 100.00% <ø> (ø)
src/algorithms/ctmrg/projectors.jl 86.15% <ø> (ø)
src/algorithms/ctmrg/simultaneous.jl 100.00% <100.00%> (ø)
...rithms/optimization/fixed_point_differentiation.jl 95.50% <100.00%> (+1.99%) ⬆️
src/utility/eigh.jl 84.00% <71.42%> (ø)
src/utility/svd.jl 88.27% <92.30%> (+1.02%) ⬆️

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

:iterative =>
(; tol = 1.0e-14, krylovdim = 25, kwargs...) ->
IterSVD(; alg = GKL(; tol, krylovdim), kwargs...),
:divideandconquer => LAPACK_DivideAndConquer,
Copy link
Member

Choose a reason for hiding this comment

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

this is a very breaking change, are we certain that we want to rename the symbols?
I have no specific preference, as I am not really affected, but I also don't necessarily see the benefit of the rename, so just wanted to double-check

Copy link
Member

Choose a reason for hiding this comment

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

Also, can we not force these to be LAPACK by default?

Copy link
Member

Choose a reason for hiding this comment

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

Could we instead do what MPSKit does and allow a settable default?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not entirely sure what you mean here, this is just a list of "short-hand-symbols" to avoid having to type full names, I don't really think there is a way to make this "settable" ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I kind of did this on a whim but I do think this is much more consistent overall. That's also the way the eigh algorithms are named. Of course this is breaking but I would hope that it wouldn't mess up too many peoples code because mostly they should have used the default SVD algorithm anyway. So I'd be in favor of keeping this change but if there is a strong case to be made for keeping :sdd, :svd and :iterative then that's fine by me.

Copy link
Member

Choose a reason for hiding this comment

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

I think my main argument against is that at that point it's not really that clear to me why we even have these symbols, and why not simply use LAPACK_DivideAndConquer in its entirety?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

While I do understand that argument, I did shorten the names for super long algorithms names, e.g. for :multiple. So most of the symbols are not that long. For :divideandconquer I kept it that way because its a memorable term that people usually know.

@leburgel
Copy link
Member

leburgel commented Feb 17, 2026

Once tests are up and running, I would really like to triple check the actual accuracy of the gradients to make sure there's no regressions (and then also add this test to CI, don't know why I didn't do that before). Just to avoid running into something like #276 later.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 17, 2026

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

@pbrehmer
Copy link
Collaborator Author

Would be good to go for me once the tests turn green

@pbrehmer pbrehmer requested a review from lkdvos February 18, 2026 12:50
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

Comments