From 37436888d2fc1a5955f5fde68ca8144c6bc17761 Mon Sep 17 00:00:00 2001 From: Katharine Hyatt Date: Tue, 10 Nov 2026 14:20:18 +0100 Subject: [PATCH 1/2] Fix a batched SVD TODO --- ext/MatrixAlgebraKitCUDAExt/yacusolver.jl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ext/MatrixAlgebraKitCUDAExt/yacusolver.jl b/ext/MatrixAlgebraKitCUDAExt/yacusolver.jl index d6ff6924b..93955fd1a 100644 --- a/ext/MatrixAlgebraKitCUDAExt/yacusolver.jl +++ b/ext/MatrixAlgebraKitCUDAExt/yacusolver.jl @@ -500,10 +500,8 @@ for (bname, fname, elty, relty) in throw(DimensionMismatch("size mismatch between A and S")) # these MUST be "full" sized - # TODO: check if U and Vᴴ already have the correct size to avoid - # some allocations - Ṽ = similar(Vᴴ, (n, n, batch_size)) - Ũ = similar(U, (m, m, batch_size)) + Ṽ = ifelse(size(Vᴴ) == (n, n, batch_size), Vᴴ, similar(Vᴴ, (n, n, batch_size))) + Ũ = ifelse(size(U) == (m, m, batch_size), U, similar(U, (m, m, batch_size))) lda = max(1, stride(A, 2)) ldu = max(1, stride(Ũ, 2)) ldv = max(1, stride(Ṽ, 2)) From 07b890d14409e9831bdd15eb9e75d7794829291f Mon Sep 17 00:00:00 2001 From: Katharine Hyatt Date: Fri, 13 Nov 2026 01:23:50 -0500 Subject: [PATCH 2/2] Allocate for V --- ext/MatrixAlgebraKitCUDAExt/yacusolver.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/MatrixAlgebraKitCUDAExt/yacusolver.jl b/ext/MatrixAlgebraKitCUDAExt/yacusolver.jl index 93955fd1a..c598f0df4 100644 --- a/ext/MatrixAlgebraKitCUDAExt/yacusolver.jl +++ b/ext/MatrixAlgebraKitCUDAExt/yacusolver.jl @@ -500,7 +500,7 @@ for (bname, fname, elty, relty) in throw(DimensionMismatch("size mismatch between A and S")) # these MUST be "full" sized - Ṽ = ifelse(size(Vᴴ) == (n, n, batch_size), Vᴴ, similar(Vᴴ, (n, n, batch_size))) + Ṽ = similar(Vᴴ, (n, n, batch_size)) # gesvdj computes V, *not* Vᴴ Ũ = ifelse(size(U) == (m, m, batch_size), U, similar(U, (m, m, batch_size))) lda = max(1, stride(A, 2)) ldu = max(1, stride(Ũ, 2))