Skip to content

Conversation

@kshyatt
Copy link
Member

@kshyatt kshyatt commented Aug 26, 2025

The ReshapedArray overrides are needed to dispatch to the correct GPU algorithms. Needed to modify the type signature for the default algorithms to avoid ambiguities. Also it's nice to give some more info about dimension mismatches.

@kshyatt kshyatt requested a review from lkdvos August 26, 2025 08:29
@codecov
Copy link

codecov bot commented Aug 26, 2025

Codecov Report

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

Files with missing lines Patch % Lines
...MatrixAlgebraKitCUDAExt/MatrixAlgebraKitCUDAExt.jl 18.75% 13 Missing ⚠️
src/implementations/eig.jl 0.00% 2 Missing ⚠️
Files with missing lines Coverage Δ
ext/MatrixAlgebraKitCUDAExt/yacusolver.jl 95.75% <100.00%> (ø)
src/implementations/eigh.jl 94.02% <ø> (ø)
src/implementations/svd.jl 91.90% <100.00%> (ø)
src/implementations/eig.jl 97.14% <0.00%> (-1.89%) ⬇️
...MatrixAlgebraKitCUDAExt/MatrixAlgebraKitCUDAExt.jl 57.62% <18.75%> (-13.21%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

include("yacusolver.jl")

function MatrixAlgebraKit.default_qr_algorithm(::Type{T}; kwargs...) where {T<:StridedCuMatrix}
function MatrixAlgebraKit.default_qr_algorithm(::Type{T}; kwargs...) where {TT<:BlasFloat, T<:StridedCuMatrix{TT}}
Copy link
Member

Choose a reason for hiding this comment

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

There are probably a couple more of these somewhat complex wrapper types that can still be handled by these algorithms, how do you feel about doing something like

for MatType in [...]
@eval ...
end

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds fine to me, do we have a list of the ones we want?

Copy link
Member

Choose a reason for hiding this comment

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

Was this particular change also induced by TensorKit requirements, or simply more strictness (which I fully support)?

Copy link
Member

Choose a reason for hiding this comment

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

Would it be equivalent to defining a new type constant

const StridedCuBLASMatrix{T} = StridedCuMatrix{T} where {T<:BlasFloat}

and then using default_xxx_algorithm(::Type{<:StridedCuBLASMatrix}; kwargs...) everywhere?

m, n = size(A)
minmn = min(m, n)
At = adjoint!(similar(A'), A)::AbstractMatrix
At = min(m, n) > 0 ? adjoint!(similar(A'), A)::AbstractMatrix : similar(A')
Copy link
Member

Choose a reason for hiding this comment

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

Is this ::AbstractMatrix type assert useful?

@kshyatt
Copy link
Member Author

kshyatt commented Sep 3, 2025

Changed the format of some of the orthnull tests -- CuArray and UniformScaling and isapprox really don't play nicely together. Also added a path to use CUSOLVER_QRIteration even in the case where m < n via transpose. Happy for feedback on the implementation - should this be a separate algorithm?

Ut = similar(U')
Vᴴt = similar(Vᴴ')
if size(U) == (m, m)
_gpu_gesvd!(At, view(S, 1:minmn, 1), Vᴴt, Ut)
Copy link
Member

Choose a reason for hiding this comment

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

Didn't think long about it, but it was not immediately clear to me why this was necessary. Isn't S always of length minmn?

Copy link
Member Author

Choose a reason for hiding this comment

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

Here I'm following what the CPU bindings have done, but I suppose we could be reusing an S over and over between differently sized arrays?

@github-actions
Copy link

github-actions bot commented Oct 3, 2025

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

Copy link
Member

@lkdvos lkdvos left a comment

Choose a reason for hiding this comment

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

Left two minor comments, and this PR needs a formatter run, otherwise this is good to merge!

@kshyatt
Copy link
Member Author

kshyatt commented Nov 10, 2025

OK fixed both comments, formatted. Thanks for the look!

@kshyatt kshyatt merged commit 58846bb into main Nov 10, 2025
9 of 10 checks passed
@kshyatt kshyatt deleted the ksh/tk branch November 10, 2025 21:41
@lkdvos lkdvos mentioned this pull request Nov 14, 2025
lkdvos referenced this pull request Nov 14, 2025
* Bump v0.6

* rename `gaugefix` -> `fixgauge`

* reduce unnecessary warnings

* fix `copy_input` signatures in Mooncake tests

* Add changelog to docs
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