You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Julia 1.13.3 with one BLAS thread, LinearAlgebra.LAPACK.gesdd!('S', A) is slower on a 28 × 2744 matrix than on its 2744 × 28 transpose. A direct dgesdd call with preallocated workspace reproduces the gap, which points to the backend's wide LAPACK path.
Backend
Direct dgesdd, tall
Direct dgesdd, wide
Apple Accelerate
0.39 ms
6.32 ms
OpenBLAS 0.3.30
0.79 ms
1.73 ms
MatrixAlgebraKit's svd_compact! inherits this cost through its default SafeDivideAndConquer algorithm. On the same inputs, the tall and wide calls took 0.55 ms and 6.40 ms on Accelerate, and 0.96 ms and 1.80 ms on OpenBLAS.
LinearAlgebra MWE
Run either example with julia --startup-file=yes -O1 --threads=1. To select Julia's bundled OpenBLAS, insert using OpenBLAS_jll and BLAS.lbt_forward(OpenBLAS_jll.libopenblas_path; clear = true) before setting the BLAS thread count.
using LinearAlgebra, Random, Statistics
BLAS.set_num_threads(1)
println(BLAS.lbt_find_backing_library("dgesdd_", :ilp64).libname)
functionmedian_ms(f, A)
f(copy(A))
return1e3*median([begin
scratch =copy(A)
@elapsedf(scratch)
endfor _ in1:31])
end
A =randn(MersenneTwister(42), 2744, 28)
compact_svd!(A) = LAPACK.gesdd!('S', A)
@showmedian_ms(compact_svd!, A)
@showmedian_ms(compact_svd!, copy(transpose(A)))
MatrixAlgebraKit MWE
Run with MatrixAlgebraKit 0.6.14.
using MatrixAlgebraKit, LinearAlgebra, Random, Statistics
BLAS.set_num_threads(1)
println(BLAS.lbt_find_backing_library("dgesdd_", :ilp64).libname)
functionmedian_ms(f, A)
f(copy(A))
return1e3*median([begin
scratch =copy(A)
@elapsedf(scratch)
endfor _ in1:31])
end
A =randn(MersenneTwister(42), 2744, 28)
@showmedian_ms(svd_compact!, A)
@showmedian_ms(svd_compact!, copy(transpose(A)))
I agree this is an upstream issue. But is it feasible to have a temporary workaround in MAK by SVD-ing the adjoint when the input matrix is wide above a certain threshold?
In principle that's definitely possible, the more annoying part is that it's not so easy to detect which LAPACK backend is being used, and then where to put the cutoff for what sizes. It's mostly a maintenance thing, because that typically depends on the machine you're running it on as well. As an alternative, would it also work to have a QR first? That might also be faster (and is typically the first thing done inside these SVD routines anyways)
Activity
lkdvos commentedon Nov 7, 2026
I'm not sure this is really something we can do anything about, you could try and report this upstream though?
Yue-Zhengyuan commentedon Nov 7, 2026
I agree this is an upstream issue. But is it feasible to have a temporary workaround in MAK by SVD-ing the adjoint when the input matrix is wide above a certain threshold?
lkdvos commentedon Nov 8, 2026
In principle that's definitely possible, the more annoying part is that it's not so easy to detect which LAPACK backend is being used, and then where to put the cutoff for what sizes. It's mostly a maintenance thing, because that typically depends on the machine you're running it on as well. As an alternative, would it also work to have a QR first? That might also be faster (and is typically the first thing done inside these SVD routines anyways)