← Back to Pull requests

Use `mapreduce` in `chkfinite`, which vectorizes #1811

Closed
unknown closed this pull request without merging on Oct 25, 2026 18:53 UTC
View on GitHub
unknown unknown commented on Oct 25, 2026 09:55 UTC
Author

LAPACK.chkfinite looped 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 behind eigen and eigvals, the SVD routines, and the generalized eigenvalue and Schur routines. Following @mikmoore's suggestion for chknan in #1804, this uses mapreduce(isfinite, &, A; init = true) instead, which goes through the whole matrix, but vectorizes.

On finite input, with the loop and mapreduce each wrapped in a function returning a Bool, 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 = true keeps 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.jl checks chkfinite and chknan directly, for Float32, Float64, ComplexF32 and ComplexF64: finite, empty and non-contiguous inputs pass, and NaN, Inf and -Inf, also in the imaginary part, throw the right ArgumentError. test/lapack.jl, eigen.jl, svd.jl, schur.jl, bidiag.jl, dense.jl and ambiguous_exec.jl pass locally.

---
_Generated by Claude Code_

Diff: 240 lines (+180 / -60) across 3 files Reviewer: stevengj Review duration: 538m
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
0.39
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 38.7% (MEDIUM) · Higher = larger blast radius
38.7%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 15.3% · Safe to merge
15.3%