Report SVD failures instead of returning them #3570
All Vouch review confidence checks passed
Residual risk 0.27 = Change Risk (0.51) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.51 · 473 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.369
Shallow Review Depth
shallow_review_depth
0.344
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #3570"
general
weight: 0.35
kshyatt
gesvdj!,gesvdjBatched!andgesvdaStridedBatched!only threw forinfo < 0(invalid arguments), so a solver that did not converge or failed handed back its output as a result. This PR makes them throw aLAPACKExceptionforinfo > 0, likegesvd!andgesvdp!already do, and gives the Jacobi wrappers a tolerance they can actually reach.Jacobi tolerance. The wrappers set the tolerance to
eps. On matrices with (numerically) zero singular values, the Jacobi residual levels off at about √n·eps, so from n ≈ 64gesvdjoften ran all 100 sweeps and returnedinfo = n+1. Running on past that point sometimes leaves it in a bad state: in 9 of 101 ComplexF64 runs with half the singular values zero (n = 370/512), the reconstruction error was 1.7e-9…1.2e-8. Just throwing oninfo > 0would therefore breaksvd(A; alg=JacobiAlgorithm())for these matrices. The new default is2sqrt(max(m, n))eps(real(T)):| tolerance | grid: cells not converged (F64 / C64 / F32 / C32) | stall test, C64 n = 370/512 | F32/C32 n = 768–2048, 80 runs |
|---|---|---|---|
|
eps(old) | 16/56, 24/64, 25/56, 33/64 | 202/202 not converged, 9 bad results | – || unset (cuSOLVER's own rule) | 0, 0, 0, 5/64 | 0/240 | 31/80 not converged |
|
2√N·eps(new) | 0, 0, 0, 0 | 0/240, worst error 9e-13 | 0/80 |The grid covers n = 16…1466 with six input classes (well-conditioned, condition 1e12, decaying to 1e-20, half zero, unitary, Gaussian) plus tall and wide variants. With
2√N·eps, every cell converged with a margin of at least 4× over the measured floor. Accuracy against a 100-sweep run did not change measurably (geometric-mean ratios 0.85–1.02). It also runs faster: ComplexF64 n = 512 decaying to 1e-20 drops from 5.3 s to 2.0 s, and n = 1024 with half the values zero from 17.8 s to 4.1 s. Leaving the tolerance to cuSOLVER doesn't work: in single precision its criterion stays at about 8 eps, below the floor once n ≥ 1024. ForgesvdjBatched!, the worst error over the batched test inputs (n ≤ 32, four element types) is within 1.24× of theepsresult.The cost shows on graded matrices, where
epsresolves the smallest singular values to a higher relative accuracy. Maximum relative error of the singular values (the unset rule is shown for comparison,Xgesvdfor reference):| input (n = 128 unless noted) |
eps|2√N·eps| unset |Xgesvd||---|---|---|---|---|
| F64, columns scaled 1 → 1e-12, random order | 2.7e-11 | 5.6e-10 | 5.7e-8 | 1.6e-6 |
| C64, same | 1.9e-12 | 2.1e-8 | 2.1e-8 | 6.7e-6 |
| F64, columns scaled 1 → 1e-12, reversed | 5.1e-12 | 8.3e-9 | 9.3e-9 | 2.2e-5 |
| C64 n = 32, same | 6.5e-13 | 3.8e-10 | 1.1e-9 | 9.1e-6 |
| F64, rows and columns scaled 1 → 1e-8, sorted | 8.3e-6 | 3.2e-3 | 1.2e-2 | 1.6e-14 |
So
alg=JacobiAlgorithm()no longer reproduces the old numbers exactly. Callers who want the old tolerance can passtol=eps(real(T))togesvdj!, and now get an exception where it isn't reached.Batched routines. NVIDIA documents
info[i] = min(m,n)+1forgesvdjBatchedwhen a matrix doesn't converge, but cuSOLVER 12.4 returns 0 even after a single sweep. The check is in place for when it does.gesvdaStridedBatched!returns NaN columns for the singular vectors of a matrix whose rank is belowrank. cuSOLVER 11.7.3 (CUDA 12.8) and later also set a positiveinfo, so that now throws, andsvd(A; alg=ApproximateAlgorithm())with it. cuSOLVER 11.7.1 (CUDA 12.6) and older returninfo = 0with the NaNs, so the test is gated on the version. The values-only calls succeeded for the same inputs.Both Jacobi wrappers now also destroy their
gesvdjInfoobject when they throw.Measured on an RTX 5080 with CUDA 13.5 (cuSOLVER 12.4.1). The tests also pass with CUDA 12.0 and 11.8, and on Julia 1.10.