Commit 4d058fe
perf(linalg): opt-in solve_ols normal-equations Cholesky fast path (DIFF_DIFF_SOLVE_OLS_FASTPATH)
solve_ols is the universal OLS entry point; both backends run an equilibrated
thin SVD (gelsd-parity) unconditionally. After #634's stage-0 certification
removed the pivoted-QR cost, the SVD solve itself is the dominant stage on
solver-bound fits (58%/54%/40% of SunAbraham county/firm and CS dr cov40).
Setting DIFF_DIFF_SOLVE_OLS_FASTPATH=1 (positive integer; per-call resolver
mirroring DIFF_DIFF_DEMEAN_CHUNK_COLS) routes certified-well-conditioned
full-rank solves through an equilibrated normal-equations Cholesky:
- numpy twin: reuses the stage-0 rank-certification artifacts (the Gram is
already built to certify rank), gated by cho_factor + LAPACK dpocon at
reciprocal condition > 1e-6 (the _IRLS_CHOL_RCOND_GUARD budget: forward
error ~eps*cond <= 2e-10); self-builds and self-certifies on the
skip_rank_check route (factorization success alone is not a certificate).
- Rust kernel solve_ols_chol: SEPARATE self-certifying pyfunction (a stale
extension degrades via the independent-import pattern instead of a
call-time TypeError): faer Llt with the exact 1-norm rcond whose inverse
byproduct doubles as the sandwich bread; ONE owned n x k buffer (the
equilibrated copy, reused in place for the vcov scores - no thin-SVD U
transient); faer-only heavy ops, so the accelerate/openblas/no-BLAS wheel
variants behave identically; shared first-appearance cluster indexer with
the SVD path.
- Fallback contract: any certification decline falls through the UNCHANGED
legacy chain (Rust SVD, then gelsd) on both dispatch routes, so
knob-on-decline output equals knob-off exactly; solve_ols gains an
optional diagnostics_out sink recording which branch ran.
Measured (M4 Max, medians; committed A/B lane with a pristine-base-tree
identity gate): SunAbraham 1.13->0.63 s and 16.77->9.89 s (1.7-1.8x),
CallawaySantAnna dr 40-cov 4.40->3.57 s (1.23x), skip_rank_check micro
1.56x, weighted/survey twin 1.07x; estimate deltas <= 9e-15 ATT / 3e-12
rel SE; rust allocator high-water on the 2.4Mx130 clustered solve
7.27 -> 2.66 GB. Knob-off byte-identical to the base tree on every
benchmark scenario.
Also fixed (found while validating the non-finite-inference contract):
the legacy Rust SVD vcov path silently returned all-Inf vcov on saturated
full-rank designs (n == k) - the (n-k) adjustment divides by zero and the
dispatcher fallback check keyed on NaN only. Both Rust vcov paths now
return the documented all-NaN sentinel (matching the canonical numpy
saturated guard, G >= 2 cluster error keeping precedence), and the
dispatcher rejects any non-finite Rust vcov via a shared helper - on the
skip_rank_check route only Inf reroutes (all-NaN remains the documented
sentinel there; rerouting it to a full-rank-assuming numpy path could
raise on a singular bread). CHANGELOG Fixed entry; sole qualified
exception to the byte-identity claim.
Tests: 57 cargo (LU oracles for beta/hc1/CR1, decline contracts, saturated
NaN, G<2 precedence) + resolver/fast-path/dispatch/kernel/saturated pytest
classes across both backends (property parity on ~20 designs, forced and
natural-guard-trip byte-identity, BETWEEN fixture with self-check,
default-path spy locks, WLS incl. zero weights, hc2/conley spot checks,
20-call clustered bit-determinism, stale-symbol degradation, Inf-injection
reroutes on both routes, NaN-sentinel pass-through).
Docs: CHANGELOG Added+Fixed, REGISTRY Note (thresholds, verbatim-fallback
contract, tol-bounded-not-bit opt-in parity), performance-plan section
with attribution/results/memory tables, doc-deps notes, TODO row swapped
to the default-on-flip follow-up + cross-refs on the parked memory-floor
and QR-reuse rows.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GPX5Rv8ozQXPdUV23QTfjr1 parent fd3cc0d commit 4d058fe
14 files changed
Lines changed: 2387 additions & 18 deletions
File tree
- benchmarks/speed_review
- baselines
- diff_diff
- docs
- methodology
- rust/src
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
225 | 239 | | |
226 | 240 | | |
227 | 241 | | |
| |||
236 | 250 | | |
237 | 251 | | |
238 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
239 | 273 | | |
240 | 274 | | |
241 | 275 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
118 | | - | |
| 117 | + | |
| 118 | + | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| |||
Lines changed: 135 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
Lines changed: 77 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
0 commit comments