Use `mapreduce` in `chkfinite`, which vectorizes #1811
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 240 lines diff across 3 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.328
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1811"
general
weight: 0.35
stevengj
LAPACK.chkfinitelooped over the matrix and returned at the first non-finite entry. That early exit keeps the loop from vectorizing, and the check runs on every call of the routines that use it, mostly with finite input: the balancing routines behindeigenandeigvals, the SVD routines, and the generalized eigenvalue and Schur routines. Following @mikmoore's suggestion forchknanin #1804, this usesmapreduce(isfinite, &, A; init = true)instead, which goes through the whole matrix, but vectorizes.On finite input, with the loop and
mapreduceeach wrapped in a function returning aBool, minimum of 7 × 200 calls:| Input | loop |
mapreduce| ||---|---|---|---|
|
Float64, 10×10 | 0.07 μs | 0.03 μs | 2.8× ||
Float64, 100×100 | 6.1 μs | 1.1 μs | 5.4× ||
Float32, 100×100 | 6.0 μs | 0.6 μs | 10.6× ||
ComplexF64, 100×100 | 6.5 μs | 3.8 μs | 1.7× ||
ComplexF32, 100×100 | 9.9 μs | 2.3 μs | 4.2× ||
Float64, 1000×1000 | 695 μs | 180 μs | 3.9× ||
Float64, vector of 1000 | 0.48 μs | 0.13 μs | 3.8× |For input with a non-finite entry, it now goes through the whole matrix before throwing, but that's the error path, and still cheap next to the factorization that would follow.
init = truekeeps empty inputs working.chkuplofinite, which checks one triangle for the symmetric routines, has the same kind of loop. I left it alone here, since it needs a different formulation to check only one triangle.Tests
A new testset in
test/lapack.jlcheckschkfiniteandchknandirectly, forFloat32,Float64,ComplexF32andComplexF64: finite, empty and non-contiguous inputs pass, and NaN, Inf and -Inf, also in the imaginary part, throw the rightArgumentError.test/lapack.jl,eigen.jl,svd.jl,schur.jl,bidiag.jl,dense.jlandambiguous_exec.jlpass locally.---
_Generated by Claude Code_