Second-Order, First-Class: A Composable Stack for Curvature-Aware Training
Organizations: IMT School for Advanced Studies Lucca Lucca, Italy
Abstract
Second-order methods promise improved stability and faster convergence, yet they remain underused due to implementation overhead, tuning brittleness, and the lack of composable APIs. We introduce Somax, a composable Optax-native stack that treats curvature-aware training as a single JIT-compiled step governed by a static plan. Somax exposes first-class modules -- curvature operators, estimators, linear solvers, preconditioners, and damping policies -- behind a single step interface and composes with Optax by applying standard gradient transformations (e.g., momentum, weight decay, schedules) to the computed direction. This design makes typically hidden choices explicit and swappable. Somax separates planning from execution: it derives a static plan (including cadences) from module requirements, then runs the step through a specialized execution path that reuses intermediate results across modules. We report system-oriented ablations showing that (i) composition choices materially affect scaling behavior and time-to-accuracy, and (ii) planning reduces per-step overhead relative to unplanned composition with redundant recomputation.
Figures & tables
| Symbol | Meaning |
|---|---|
| Dataset and size | |
| Mini-batch at step and size | |
| Model parameters (weights) | |
| Mini-batch loss at step | |
| Mini-batch gradient | |
| Curvature operator (exact or approximate) |
| Method | Curv. | Lane | Solver | Estimation / preconditioning |
|---|---|---|---|---|
| AdaHessian [ 40 ] | Hessian | diag. | explicit | Hutchinson diag. estimator + diag. EMA preconditioner |
| Sophia-G [ 15 ] | GGN (CE) | diag. | explicit | GNB diag. estimator + diag. EMA preconditioner + clipping |
| Sophia-H [ 15 ] | Hessian | diag. | explicit | Hutchinson diag. estimator + diag. EMA preconditioner + clipping |
| Newton-CG [ 19 ] | Hessian | param. | CG/PCG (HVP) | Optional diag. precond.; damping |
| SGN [ 8 ] | GGN (MSE/CE) | param. | CG/PCG (GGN matvec) | Optional diag. precond.; damping |
| EGN [ 13 ] | GGN (MSE/CE) | row | row-Cholesky / row-CG | Row-space solve with internal damping conversion |
| Setting ( rho_every_k ) | Median (ms) | p90 (ms) | Overhead vs. off |
|---|---|---|---|
| off ( -1 ) | 0.84 | 0.87 | 0.0% |
| every 10 steps ( 10 ) | 0.95 | 1.16 | 12.4% |
| every 5 steps ( 5 ) | 0.96 | 1.33 | 13.8% |
| every 2 steps ( 2 ) | 1.30 | 1.40 | 57.2% |
| every step ( 1 ) | 1.33 | 1.34 | 53.7% |
| Solver | Precond. | Damping | CG budget | Time to 85% (s) | Final acc (%) |
| SGD | – | – | – | 1.60 | 90.58 |
| Adam | – | – | – | 1.23 | 90.39 |
| SGN | – | const | light | 3.52 | 90.69 |
| SGN | – | const | heavy | 4.79 | 90.09 |
| SGN | – | trust region | light | 7.33 | 89.69 |
| SGN | – | trust region | heavy | 9.13 | 91.14 |
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
| Spec Object | Role & Planner Effect |
|---|---|
| CurvatureSpec | Defines the operator family (e.g., hessian , ggn_ce ). Declares if row-primitives are available. |
| SolverSpec | Selects the algorithm (e.g., cg , row_cholesky ). Determines the execution lane (Param vs. Row). |
| DampingSpec | Defines the trust-region or regularization policy. Requests telemetry (e.g., rho-packs) that the planner must schedule. |
| PrecondSpec | (Optional) Defines diagonal scaling (e.g., diag_ema ) for the Diagonal lane or as a preconditioner for CG. |
| EstimatorSpec | (Optional) Layers randomized probing (e.g., Hutchinson) onto the step without extra linearizations. |
| Component | Consumes | Produces | Planner effect (why it matters) | Persistent state |
|---|---|---|---|---|
| Curvature operator | parameters, batch | linearization state; matrix-free primitives (and optionally row primitives); loss/grad consistent with snapshot | determines feasibility of the row lane; declares whether post-update probes can reuse the step-local snapshot | none (the linearization snapshot is step-local) |
| Estimator wrapper (optional) | curvature primitives and RNG (cadence-gated) | additional curvature summaries (e.g., diagonal, trace, spectrum) | adds optional probes without creating a second curvature snapshot; updates the fixed metric schema | optional estimator state (e.g., probe buffers), else none |
| Preconditioner (optional) | diagonal estimate and damping | diagonal scaling (used by diagonal lane or by PCG) | controls whether the param lane specializes to CG vs PCG; avoids runtime switching inside traced code | EMA buffers (optional) |
| Linear solver | lane-specific operator primitives, damping, right-hand side | scaled direction; solver diagnostics (if enabled) | fixes the lane (diag/param/row); enables cadence-gated solver telemetry keys | warm start (solution to the previous iteration, optional) |
| Damping policy | plan-selected telemetry (e.g., gain-ratio bundle) at declared cadence | updated damping state | turns on post-update probes only when required; ensures probes are computed against the applied update | damping state |
| Optax post-transform | scaled direction and Optax state | applied update and updated Optax state | forces step-level semantics: post-update probes must match the exact applied update, not the raw direction | Optax state |