Expand description
Analytic diagnostic helpers for LAML/REML optimization.
Production diagnostics inspect analytic invariants only. Runtime fitting, prediction, and diagnostic APIs must consume quantities the optimizer already computes. This module implements diagnostic strategies that identify root causes of gradient pathologies from those analytic quantities:
-
KKT Audit (Envelope Theorem Check): Detects violations of the stationarity assumption used in implicit differentiation.
-
Spectral Bleed Trace: Detects when truncated eigenspace corrections are inconsistent with the penalty’s energy in that subspace.
-
Dual-Ridge Consistency Check: Verifies that the ridge used by the inner solver (PIRLS) matches what the outer gradient calculation assumes.
Structs§
- Diagnostic
Config - Configuration for gradient diagnostics
- Dual
Ridge Result - Result of dual-ridge consistency check
- Envelope
Audit - Result of envelope theorem (KKT) audit
- Gradient
Diagnostic Report - Complete diagnostic report for a gradient evaluation
- Prediction
Diagnostics - Residual diagnostics for observed values and predicted means.
- Spectral
Bleed Result - Result of spectral bleed trace diagnostic
Enums§
- KktRefusal
Diagnosis - Three-way classification of why the cert refused, computed from the
H_pen spectrum and the projected residual at the refusing iterate.
RankDeficientHPenis the regression canary the nullspace lead’s smooth-construction rework is intended to eliminate; keep this variant intact when extending — it doubles as the user-facing signal for “an unconstrained polynomial null space slipped past absorption.”
Constants§
- MIN_
EIG_ DIAG_ EVERY - Repeat period within a magnitude bucket for the Hessian-minimum-eigenvalue diagnostic: after the first emission for a bucket, every Nth subsequent invocation also emits.
- MIN_
EIG_ DIAG_ THRESHOLD - Threshold below which a positive Hessian minimum eigenvalue is treated as nearly-singular and routed through the rate-limited diagnostic.
Statics§
- H_
MIN_ EIG_ LOG_ BUCKET - Rate-limited diagnostic for Hessian minimum eigenvalue warnings
- H_
MIN_ EIG_ LOG_ COUNT - Count of
should_emit_h_min_eig_diaginvocations that have ever been considered for emission; used together withH_MIN_EIG_LOG_BUCKETto rate-limit one diagnostic per decade-magnitude bucket and perMIN_EIG_DIAG_EVERYrepeats within the same bucket.
Functions§
- compute_
dualridge_ check - Check consistency between the ridge used in different stages of computation.
- compute_
envelopeaudit - Compute the inner KKT residual to detect envelope theorem violations.
- diagnostics_
from_ predictions - Compute prediction residual diagnostics from observed values and predicted means.
- format_
top_ abs - Diagnostic formatter shared across the outer optimizer and the custom-family
fitter: shows the
max_itemsentries ofvalueswith largest absolute value, formatted aslabel=[i:value, ...]. - should_
emit_ h_ min_ eig_ diag - Rate-limited check for Hessian minimum eigenvalue diagnostics. Returns true if this eigenvalue warrants a diagnostic message.