Skip to content

Conversation

@lkdvos
Copy link
Member

@lkdvos lkdvos commented Nov 10, 2025

This PR brings TensorKit up to speed with the MatrixAlgebraKit v0.6.

The main changes are the addition of the new projection functionality, and a rework of the orthnull interface.
The former is mostly just implemented here, while the latter means that a lot of code could be removed from TensorKit instead.

I additionally took the time to hopefully stabilize some of the truncated SVD AD tests, as these struggled with finite differences in combination with spaces that change.

@codecov
Copy link

codecov bot commented Nov 14, 2025

Codecov Report

❌ Patch coverage is 81.70732% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/factorizations/adjoint.jl 7.69% 12 Missing ⚠️
src/auxiliary/deprecate.jl 0.00% 1 Missing ⚠️
src/factorizations/truncation.jl 96.66% 1 Missing ⚠️
src/tensors/adjoint.jl 50.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/TensorKit.jl 22.72% <ø> (ø)
src/factorizations/factorizations.jl 94.11% <100.00%> (+6.31%) ⬆️
src/factorizations/matrixalgebrakit.jl 94.92% <100.00%> (+6.71%) ⬆️
src/factorizations/pullbacks.jl 30.76% <100.00%> (-26.38%) ⬇️
src/auxiliary/deprecate.jl 0.00% <0.00%> (-2.20%) ⬇️
src/factorizations/truncation.jl 85.80% <96.66%> (+10.06%) ⬆️
src/tensors/adjoint.jl 72.41% <50.00%> (-1.67%) ⬇️
src/factorizations/adjoint.jl 2.32% <7.69%> (+2.32%) ⬆️

... and 15 files with indirect coverage changes

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

@github-actions
Copy link
Contributor

github-actions bot commented Nov 14, 2025

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

@lkdvos
Copy link
Member Author

lkdvos commented Nov 14, 2025

I'm linking #313 and #314 here, as this should hopefully be easier to resolve with the updated orthnull interfaces

@lkdvos lkdvos marked this pull request as ready for review November 15, 2025 15:00
@lkdvos lkdvos requested a review from Jutho November 16, 2025 14:09
@lkdvos
Copy link
Member Author

lkdvos commented Nov 16, 2025

Assuming that the tests pass here, I think this should be ready to be merged.
There are some parts that definitely could be improved (for example the AdjointTensorMap factorizations), but this depends on improvements in MatrixAlgebraKit itself so I want to hold off on that for now.

@Jutho
Copy link
Member

Jutho commented Nov 17, 2025

What change made it such that so much code in "src/factorizations/factorizations.jl" can be removed?

@lkdvos
Copy link
Member Author

lkdvos commented Nov 17, 2025

Most of that code was introduced in the first place to work around the design of the orthnull parts. This was one of the main motivations to rework that, which now more cleanly reuses the different factorization functions. I think the biggest contribution is that we now first figure out the algorithm type, which dictates the factorization type, and only then start the rest of the logic, which makes it a lot easier to implement in a generic way.

Additionally we've been more careful in MatrixAlgebraKit to not overly specialize on AbstractMatrix, and while there is a bit more boilerplate over there, we can remove quite a lot of it here.

@kshyatt
Copy link
Member

kshyatt commented Nov 21, 2025

What's the status here? This is blocking the GPU updates PR :)

@Jutho
Copy link
Member

Jutho commented Nov 21, 2025

I will try to go through tonight.

$right_f!(adjoint(t), reverse(adjoint.(F)), _adjoint(alg))
return F
F′ = $right_f!(adjoint(t), reverse(adjoint.(F)), _adjoint(alg))
return reverse(adjoint.(F′))
Copy link
Member

Choose a reason for hiding this comment

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

These were incorrect before my latest commit, so reminder here to figure out why the tests didn't pick this up.

return reverse(adjoint.(F′))
end

# disambiguate by prohibition
Copy link
Member

Choose a reason for hiding this comment

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

Another out-of-place question due to the limitation to only add comments near edited code: line 113 below, namely

function MAK.svd_compact!(t::AdjointTensorMap, USVᴴ, alg::DiagonalAlgorithm)
    return MAK.svd_compact!(t, USVᴴ, alg.alg)
end

This doesn't seem correct. I don't think DiagonalAlgorithm has an alg.alg field. Even if this is only to fix an ambiguity and is never called, we should try to make it some valid code. But I am a bit confused about this method definition.

@Jutho
Copy link
Member

Jutho commented Nov 23, 2025

Ok, I went over this PR (and the whole src/factorizations/ code more generally) during the past few days. I made a few changes already, but also left some more comments.

I think this is almost ready, but it would be good to have a discussion about the deprecation path of the old interface. For me, the MatrixAlgebraKit function naming was always a convenient way to implement all these methods as a library implementer. And I think it is very useful that they all exist at the level of TensorMaps as well.

But a library as TensorKit might also want to have an additional more convenient interface with shorter function names (better discoverable) and more general behavior, where truncation is simply controlled by a keyword argument, such as the earlier tsvd (I guess that is the most important one). It would be good to exchange ideas about this.

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.

truncation error with rtol right_null errors when trunc is provided

4 participants