rocSOLVER's gesvdj diagonalizes A'A with a Jacobi eigensolver and takes
U and S from a QR of AV, so singular values below sqrt(eps)*σ₁ are lost
while info = 0 and the residual is below tolerance: a Float64 svd, cond
or rank could silently be accurate to 1e-8 only. gesvd matches LAPACK
down to the eps*σ₁ floor. Make QRAlgorithm() the default of svd, svd!,
svdvals and svdvals! (and the target of DivideAndConquer()), as CUDA.jl
does; JacobiAlgorithm() stays available as the documented fast path
(3-9x faster on MI250X and MI300A) for well-conditioned matrices.
Upstream: ROCm/rocm-libraries#12868 (gesvdj accuracy), #15788 (cgesvd
singular vectors of a rank-deficient ComplexF32 matrix, worked around
in the test).
svd,svd!,svdvalsandsvdvals!of aROCMatrixdefault toQRAlgorithm()(rocSOLVER'sgesvd) instead ofJacobiAlgorithm()(gesvdj), as CUDA.jl does in JuliaGPU/CUDA.jl#3571, but for the opposite reason: on AMD the Jacobi routine is the faster one, and it is inaccurate.rocSOLVER's
gesvdjis not a one-sided Jacobi onA: it diagonalizesA'Awith its Jacobi eigensolver and takesUandSfrom a QR ofAV(roclapack_gesvdj.hpp). Squaring the matrix loses every singular value belowsqrt(eps)·σ₁, and the convergence test cannot see it. On a Float64 matrix with singular values graded from 1 to 1e-20 (n = 11),gesvdjreturnsinfo = 0and a residual of 1e-19 with singular values that are right down to 1e-6·σ₁ and 3–80 % wrong from 1e-8·σ₁ on;gesvdmatches LAPACK down to the eps·σ₁ floor. On a graded 128×128 ComplexF64 matrix the factorization is accurate to 9e-9 (gesvd: 8e-15), the numerical rank at rtol 1e-12 comes out one short, andcondis 20× too small. Reported upstream in ROCm/rocm-libraries#12868 (in fp32 there; the double-precision numbers are in a comment).Speed goes the other way from NVIDIA:
gesvdjis 3–9× faster thangesvdat every size and element type on MI250X and MI300A (ComplexF64, 1466×1466: 1.45 s vs 7.8 s on MI250X, 0.81 s vs 5.6 s on MI300A; ROCm 7.2.3). So a Float64svd,cond,rankorpinvthat is silently accurate to 1e-8 is traded for one that takes longer.JacobiAlgorithm()stays available and documented as the fast path for well-conditioned matrices.LinearAlgebra.DivideAndConquer()now maps to the default as well;QRIteration()maps to QR as before.Tests: the default equals
QRAlgorithm()on tall, wide, square, rank-deficient and zero matrices; a graded 64×64 matrix in Float64 and ComplexF64 is resolved to 1e-12 through the default. Docs: the SVD section and theQRAlgorithm/JacobiAlgorithmdocstrings state the trade-off.One defect of
gesvdturned up on the way: for a rank-deficientComplexF32matrix (and only that element type) rocSOLVER returns the singular vector of a zero singular value with a norm between 0.84 and 1.05, in about half of the random matrices, deterministically per matrix, in both work modes; singular values, reconstruction andinfoare fine, andgesvdjis not affected. Same with rocSOLVER 3.37.0 (the ROCm 10.1.0 artifacts) on MI300A. Reported in ROCm/rocm-libraries#15788; the rank-deficient test checks the vectors of the non-zero singular values for that element type, and the docs mention it.Behaviour change (minor release): the default
svdis slower; callers who want the previous speed passalg = JacobiAlgorithm(). API and return types are unchanged. Verified on MI250X and MI300A.🤖 Generated with Claude Code