Skip to content

Support CUSOLVER's randomized SVD for svd_trunc - #322

Open
kshyatt wants to merge 2 commits into
mainfrom
ksh/rand
Open

kshyatt wants to merge 2 commits into
mainfrom
ksh/rand

Conversation

@kshyatt

@kshyatt kshyatt commented Nov 6, 2026

Copy link
Copy Markdown
Member

This makes svd_trunc! and svd_trunc_no_error! produce k-sized outputs so that we can avoid calling the internal gesvdxr functions. Also has a fix for the truncation so that if we pass in inputs which are "too big", we pass views that fit.

@kshyatt
kshyatt requested a review from lkdvos November 6, 2026 10:42
@codecov

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.69565% with 19 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ixAlgebraKitEnzymeExt/MatrixAlgebraKitEnzymeExt.jl 0.00% 13 Missing ⚠️
...gebraKitMooncakeExt/MatrixAlgebraKitMooncakeExt.jl 57.14% 6 Missing ⚠️
Files with missing lines Coverage Δ
src/implementations/svd.jl 95.91% <100.00%> (+0.17%) ⬆️
...gebraKitMooncakeExt/MatrixAlgebraKitMooncakeExt.jl 84.02% <57.14%> (+13.47%) ⬆️
...ixAlgebraKitEnzymeExt/MatrixAlgebraKitEnzymeExt.jl 74.23% <0.00%> (-3.91%) ⬇️

... and 1 file with indirect coverage changes

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

@kshyatt
kshyatt requested a review from Jutho November 19, 2026 14:04
Comment on lines +342 to +346
throw(DimensionMismatch("size of S ($r) must be between k ($k) and min(size(A)...) ($minmn)"))
(size(U, 1) == m && k ≤ size(U, 2) ≤ m) ||
throw(DimensionMismatch("size of U $(size(U)) must be ($m, r) with r between k ($k) and $m"))
(size(Vᴴ, 2) == n && k ≤ size(Vᴴ, 1) ≤ n) ||
throw(DimensionMismatch("size of Vᴴ $(size(Vᴴ)) must be (r, $n) with r between k ($k) and $n"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For these small interpolations, I don't know if it is worth using LazyString. We have probably not been using this very consistently, though we do use it at some places in the ecosystem.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think it hurts at all, so I can add it in.

Comment thread src/implementations/svd.jl Resolved
Comment thread src/implementations/svd.jl Resolved
@kshyatt

kshyatt commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

I realized this will currently fail with AD so I'm adding some logic to handle that too

@lkdvos

lkdvos commented Nov 20, 2026

Copy link
Copy Markdown
Member

I'm still not entirely convinced by the current logic of the randomized SVDs through svd_trunc to be honest. In principle the interface of #225 was more or less ready, so it could be nice to just pick that up, which might supersede this?

@kshyatt

kshyatt commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Totally fine with me, I had no idea whether that one was still alive or not

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.

3 participants