Default to QR iteration for the SVD of a matrix #3571
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 506 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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.373
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3571"
general
weight: 0.35
kshyatt
svdandsvdvalsof aCuMatrixdefault to cuSOLVER's one-sided Jacobi method (gesvdj). QR iteration (gesvd, through the 64-bitXgesvd) is faster in double precision: 13–45× for the ComplexF64 matrices of size 512 and 1466 below, and faster in every double-precision case measured. Its singular vectors are also closer to orthonormal: 10–20× at n = 64 and 90–400× at n = 512–1466. This PR makes it the default for matrices. Batches (3-D arrays) keep the Jacobi method, sincegesvdjBatchedis the only batched routine that computes the full decomposition.QRAlgorithm()also threw anArgumentErrorfor wide matrices, becausegesvdrequires m ≥ n. Making it the default meant fixing that first. The adapter that decomposes Aᴴ already existed, but was only used when Jacobi's 32-bit workspace overflowed; now it implementsQRAlgorithmforsvd,svd!,svdvalsandsvdvals!, compact and full.svd(A)andsvdvals(A)on an RTX 5080 (CUDA 13.5), minimum of ≥ 3 runs. "main" is Jacobi withtol = eps; "Jacobi" is the previous PR's tolerance; "QR" is this PR's default. Orthogonality is the larger of ‖UᴴU − I‖ and ‖VᴴV − I‖ (Frobenius norm):| type | n | spectrum |
svd: main / Jacobi / QR |svdvals: main / Jacobi / QR | orthogonality: Jacobi / QR ||---|---|---|---|---|---|
| ComplexF64 | 64 | 1 → 1e-3 | 37.9 / 37.3 / 3.2 ms | 37.9 / 37.2 / 1.3 ms | 2e-13 / 2e-14 |
| ComplexF64 | 64 | 1 → 1e-20 | 91.5 / 70.0 / 2.8 ms | 91.6 / 69.8 / 1.3 ms | 3e-13 / 1e-14 |
| ComplexF64 | 512 | 1 → 1e-3 | 1.01 s / 990 / 77 ms | 1.01 s / 988 / 28 ms | 1e-11 / 1e-13 |
| ComplexF64 | 512 | 1 → 1e-20 | 5.34 / 2.08 s / 57 ms | 5.34 / 2.08 s / 27 ms | 1e-11 / 9e-14 |
| ComplexF64 | 1466 | 1 → 1e-3 | 7.85 / 7.69 s / 560 ms | 6.36 / 6.25 s / 168 ms | 7e-11 / 3e-13 |
| ComplexF64 | 1466 | 1 → 1e-20 | 40.0 / 17.6 s / 388 ms | 36.5 / 14.8 s / 158 ms | 9e-11 / 2e-13 |
| ComplexF32 | 64 | 1 → 1e-3 | 1.57 / 1.38 / 1.37 ms | 1.51 / 1.34 / 0.70 ms | 1e-4 / 8e-6 |
| ComplexF32 | 64 | 1 → 1e-20 | 11.5 / 1.30 / 1.20 ms | 11.3 / 1.27 / 0.68 ms | 8e-5 / 7e-6 |
| ComplexF32 | 512 | 1 → 1e-3 | 36.5 / 33.3 / 16.4 ms | 35.3 / 32.7 / 11.1 ms | 6e-3 / 6e-5 |
| ComplexF32 | 512 | 1 → 1e-20 | 211 / 36.5 / 13.4 ms | 208 / 35.8 / 10.2 ms | 4e-3 / 5e-5 |
| ComplexF32 | 1466 | 1 → 1e-3 | 267 / 237 / 86 ms | 219 / 199 / 53 ms | 3e-2 / 2e-4 |
| ComplexF32 | 1466 | 1 → 1e-20 | 1.66 s / 255 / 61 ms | 1.42 s / 224 / 47 ms | 2e-2 / 1e-4 |
A wider comparison on CUDA 13.5 found where Jacobi is still competitive. It covered all four element types, n = 1…1024, 4096×64, 20000×32 and 64×4096, compact, full and values-only, and four spectra, 312 cells per type:
A smaller sample on CUDA 12.0 and 11.8 (Float32 and ComplexF64; n = 8…1024 and 4096×64; two spectra; compact and values-only):
Even where Jacobi is faster in single precision, its singular vectors are about 100× less orthogonal (‖VᴴV − I‖ 1.8e-2 vs 1.2e-4 at n = 1024).
Caveat. On graded matrices whose large columns are not first, the Jacobi method determines the smallest singular values to a much higher relative accuracy: for example 5.6e-10 vs 1.6e-6 for Float64, n = 128, columns scaled 1 → 1e-12 in random order. QR iteration only gives normwise accuracy (error ≈ eps·σ₁/σᵢ).
Results change with the algorithm. Both are accurate in norm, but singular-vector phases, and the bases for repeated or zero singular values, can differ.
alg=JacobiAlgorithm()restores the old route.