Phiacta
ExplorePostDocsGuidesContributingAbout

Phiacta

The knowledge backend.

Contact Us
ExploreInduced-Metric Optimizer: Learnable Diagonal Metric

Induced-Metric Optimizer: Learnable Diagonal Metric

Induced-metric optimizer where the inverse metric γ⁻¹ = diag(exp(s)) is a learnable per-parameter diagonal, updated online each step. Each parameter gets its own scale factor exp(s_i), with mean-centering to avoid scale degeneracy with ξ. O(N) learnable state. Best peak accuracy on MNIST (97.99%).

ContentIssuesEditsHistoryFilesReferences5

Learnable Diagonal Induced Metric and the Curvature-Aware Variant

The induced metric with a fixed base γ=I\gamma = Iγ=I gives a uniform damping of the Euclidean step. The learnable scalar variant replaces the identity by esIe^s IesI for a single learnable scalar sss. The diagonal generalisation goes one step further: give every parameter its own learnable scale factor esie^{s_i}esi​. This is the most expressive diagonal extension of the original framework, and the variant with the highest peak accuracy on the project's 1000-trial MNIST MLP sweep.

This entry derives the metric, the online learning rule, the Riemannian Hessian of the resulting (now θ\thetaθ-dependent) metric, the hierarchy among scalar and diagonal variants, the optimal curvature correction, the curvature-aware update rule, and the empirical results. The headline structural observation is that the learnable diagonal sits in the highest tier of the geodesic convexity hierarchy: it has enough degrees of freedom to flip eigenvalue signs of the Riemannian Hessian, which the scalar variant can do only when tr(H)>0\mathrm{tr}(H) > 0tr(H)>0 and the fixed metric cannot do at all. The headline empirical observation is that the variant's best-run accuracy is the highest on MNIST MLP but its median is well below Adam's, exposing a robustness gap that is the principal open problem.

1. The learnable diagonal metric

Parameterise the inverse base metric by

γϕ−1(θ)=diag(es1(θ),…,esN(θ)),\gamma^{-1}_\phi(\theta) = \mathrm{diag}\bigl(e^{s_1(\theta)},\dots,e^{s_N(\theta)}\bigr),γϕ−1​(θ)=diag(es1​(θ),…,esN​(θ)),

where s∈RNs \in \mathbb{R}^Ns∈RN is a vector of per-parameter log-scale factors that evolves under its own learning rule (Section 4). Working in log space ensures positive-definiteness by construction. The induced metric becomes

gij(θ)=e−si(θ) δij+ξ ℓi(θ) ℓj(θ),ℓ=∇L.g_{ij}(\theta) = e^{-s_i(\theta)}\,\delta_{ij} + \xi\,\ell_i(\theta)\,\ell_j(\theta), \qquad \ell = \nabla L.gij​(θ)=e−si​(θ)δij​+ξℓi​(θ)ℓj​(θ),ℓ=∇L.

Setting s=0s = 0s=0 recovers the original induced metric with γ=I\gamma = Iγ=I. The base metric γ\gammaγ is now θ\thetaθ-dependent through s(θ)s(\theta)s(θ), which makes the Christoffel symbols nonzero and produces a curvature correction in the Riemannian Hessian (Section 3).

Sign convention for sss. This entry parameterises the inverse metric (equivalently, the preconditioner applied to the gradient): increasing sis_isi​ inflates the preconditioner and increases the parameter step in direction iii. The geodesic convexity entry parameterises the metric itself (γ=diag(esi)\gamma = \mathrm{diag}(e^{s_i})γ=diag(esi​)), so its sss has the opposite sign: increasing sis_isi​ in that entry's convention means more metric weight and a smaller step in direction iii. The underlying object is the same; when porting a formula from there to here (or vice versa), substitute s→−ss \to -ss→−s.

2. How the metric enters the update

The preconditioned gradient is

g~t,i=esi gt,i,\tilde g_{t,i} = e^{s_i}\,g_{t,i},g~​t,i​=esi​gt,i​,

each gradient component scaled by its own factor. The metric trace, which determines the global damping factor of the Sherman-Morrison denominator, is

vt=ξ ∑igt,i g~t,i=ξ ∑iesi gt,i2.v_t = \xi\,\sum_i g_{t,i}\,\tilde g_{t,i} = \xi\,\sum_i e^{s_i}\,g_{t,i}^2.vt​=ξi∑​gt,i​g~​t,i​=ξi∑​esi​gt,i2​.

This is where the global coupling enters: every parameter contributes to the single scalar vtv_tvt​, which determines the global scaling factor rt=1/(1+vt)r_t = 1/(1 + v_t)rt​=1/(1+vt​). A parameter with large esie^{s_i}esi​ and large gradient dominates the trace, and therefore influences the step size for every other parameter. Adam has no such mechanism: each Adam coordinate is scaled independently.

The full update is

δθt,i=−η rt esi m^t,i−η λwd θt,i,\delta\theta_{t,i} = -\eta\,r_t\,e^{s_i}\,\hat m_{t,i} - \eta\,\lambda_{\mathrm{wd}}\,\theta_{t,i},δθt,i​=−ηrt​esi​m^t,i​−ηλwd​θt,i​,

where m^t\hat m_tm^t​ is the bias-corrected momentum and the last term is decoupled weight decay (AdamW-style; the Riemannian-correct coupled version is implementable but not what the production code uses).

3. The Riemannian Hessian with learnable metric

Metric field versus trajectory state. The Riemannian Hessian formula below assumes that γ\gammaγ is an actual metric field on parameter space, i.e., that sss is a smooth function s:RN→RNs: \mathbb R^N \to \mathbb R^Ns:RN→RN with well-defined Jacobian ∂ksi\partial_k s_i∂k​si​. In the online optimizer, sts_tst​ is trajectory state updated step by step from observables; the Jacobian ∂ksi\partial_k s_i∂k​si​ is not directly available, and there is no guarantee that the trajectory state is the value of some smooth global sss field at θt\theta_tθt​. The pointwise-feasibility analysis of geodesic convexity §4.3 makes this explicit: the SDP/Gershgorin theorems are statements about pointwise first-jet feasibility, not about a global metric field. The bridge from theory to optimizer is therefore: the theory tells us what kind of σ\sigmaσ would help if it existed; the online rule produces a σ\sigmaσ from local observables that approximates this in spirit; whether the produced σ\sigmaσ is the Jacobian of any global sss is generally unknown and not strictly required for the optimizer to work.

When γ\gammaγ depends on θ\thetaθ, the Riemannian Hessian theorem for fixed metric generalises. The Christoffel bracket ∂igjl+∂jgil−∂lgij\partial_i g_{jl} + \partial_j g_{il} - \partial_l g_{ij}∂i​gjl​+∂j​gil​−∂l​gij​ decomposes additively into a γ\gammaγ-part (involving ∂kγij\partial_k \gamma_{ij}∂k​γij​) and a ξ\xiξ-part (involving ξ(Hijℓl+ℓjHil)\xi(H_{ij} \ell_l + \ell_j H_{il})ξ(Hij​ℓl​+ℓj​Hil​) and similar). Each piece is treated separately under the Sherman-Morrison inverse gkl=γkl−ξ ℓkℓl/(1+ξ ∥ℓ∥γ2)g^{kl} = \gamma^{kl} - \xi\,\ell^k \ell^l/(1 + \xi\,\lVert \ell\rVert_\gamma^2)gkl=γkl−ξℓkℓl/(1+ξ∥ℓ∥γ2​).

Define the curvature correction

Cij=Γijk(γ) ℓk,Γijk(γ)=12 γkl(∂iγjl+∂jγil−∂lγij),C_{ij} = \Gamma^k_{ij}(\gamma)\,\ell_k, \qquad \Gamma^k_{ij}(\gamma) = \tfrac{1}{2}\,\gamma^{kl}\bigl(\partial_i \gamma_{jl} + \partial_j \gamma_{il} - \partial_l \gamma_{ij}\bigr),Cij​=Γijk​(γ)ℓk​,Γijk​(γ)=21​γkl(∂i​γjl​+∂j​γil​−∂l​γij​),

where the Christoffel symbols are computed using γkl\gamma^{kl}γkl, not gklg^{kl}gkl. A clean algebraic cancellation (verified symbolically in the geodesic convexity entry's Appendix A) gives

(HessgL)ij=Hij−Cij1+ξ ∥ℓ∥γ2,(\mathrm{Hess}_g L)_{ij} = \frac{H_{ij} - C_{ij}}{1 + \xi\,\lVert \ell\rVert_\gamma^2},(Hessg​L)ij​=1+ξ∥ℓ∥γ2​Hij​−Cij​​,

where ∥ℓ∥γ2=ℓ⊤γ−1ℓ\lVert \ell\rVert_\gamma^2 = \ell^\top \gamma^{-1} \ell∥ℓ∥γ2​=ℓ⊤γ−1ℓ. The formula is exact, no approximation.

The key structural fact: CCC depends on ∇γ\nabla \gamma∇γ and ℓ\ellℓ but not on HHH. Therefore CCC can have eigenvalue structure completely different from HHH and can, in principle, cancel negative eigenvalues, making the corrected H−CH - CH−C positive semidefinite. This is the mechanism that allows the learnable variants to do something the fixed metric cannot: convert saddle directions into convex ones.

The denominator 1+ξ ∥ℓ∥γ21 + \xi\,\lVert \ell\rVert_\gamma^21+ξ∥ℓ∥γ2​ is always a positive scalar, so it does not affect eigenvalue signs. The sign structure of the Riemannian Hessian is determined entirely by H−CH - CH−C.

4. The online learning rule for sss

The metric trace serves as a surrogate for the metric's adaptive utility. The per-parameter gradient of the surrogate v=ξ ∑keskgk2v = \xi\,\sum_k e^{s_k} g_k^2v=ξ∑k​esk​gk2​ with respect to sis_isi​ is

∂v∂si=ξ esi gt,i2.\frac{\partial v}{\partial s_i} = \xi\,e^{s_i}\,g_{t,i}^2.∂si​∂v​=ξesi​gt,i2​.

The interpretation. Parameters with large gradient magnitudes get their scale factors pushed upward, increasing their influence on the metric trace and their effective preconditioning strength. Parameters with small gradients have their factors driven toward zero (and thus esie^{s_i}esi​ toward unity).

The base online update mirrors the scalar case:

si←si+ηmetric ξ esi gt,i2−ηmetric λreg si.s_i \leftarrow s_i + \eta_{\mathrm{metric}}\,\xi\,e^{s_i}\,g_{t,i}^2 - \eta_{\mathrm{metric}}\,\lambda_{\mathrm{reg}}\,s_i.si​←si​+ηmetric​ξesi​gt,i2​−ηmetric​λreg​si​.

Two numerical safeguards.

  1. Mean-centering per leaf. si←si−sˉs_i \leftarrow s_i - \bar ssi​←si​−sˉ. Without this, the overall scale of esie^{s_i}esi​ is degenerate with ξ\xiξ: doubling all esie^{s_i}esi​ and halving ξ\xiξ gives the same trace. Mean-centering removes the degree of freedom by keeping the geometric mean of the diagonal at 111.

  2. Clipping. si∈[−c,c]s_i \in [-c, c]si​∈[−c,c] with c=4c = 4c=4 by default. Bounds the condition number of the preconditioner at e2c≈3000e^{2c} \approx 3000e2c≈3000 and prevents the metric from collapsing or diverging in pathological cases.

The base rule has been the production version for most of the project's sweep results. Section 6 below shows that it is structurally suboptimal as a curvature corrector, motivating the curvature-aware variant of Section 7.

5. Comparison with Adam

PropertyLearnable diagonalAdam
Per-parameter scalingesie^{s_i}esi​, learned by gradient ascent on vvv1/(v^i+ε)1/(\sqrt{\hat v_i} + \varepsilon)1/(v^i​​+ε), EMA of gi2g_i^2gi2​
Global couplingYes: scalar rtr_trt​ from ∑esigi2\sum e^{s_i} g_i^2∑esi​gi2​ damps all parametersNone: each coordinate is independent
Adaptation mechanismExplicit gradient ascent on a surrogateImplicit via second-moment EMA
MemoryO(N)O(N)O(N) for sss plus O(1)O(1)O(1) for the metric traceO(N)O(N)O(N) for v^\hat vv^
Geometric interpretationRiemannian gradient flow with learned metricCoordinate-wise rescaling
Curvature correctionYes (Section 3, nonzero CCC)No (Adam is not a pullback metric)

The crucial distinction is global coupling. The per-parameter scales feed into a shared scalar rtr_trt​ that modulates the entire update, so the optimizer can detect when the overall landscape is steep and dampen accordingly, even when individual parameters look tame. The curvature correction CCC from Section 3 is a second structural advantage: it allows the metric to bend convergence away from sharp regions, a mechanism Adam lacks entirely.

6. The hierarchy of curvature corrections

The geodesic convexity question (when can the metric convert a non-convex landscape into a Riemannian convex one?) splits cleanly across three levels of metric complexity. The geodesic convexity entry gives the full theorem; this section summarises the part directly relevant to the learnable diagonal.

Level 0: constant γ\gammaγ

C=0C = 0C=0 identically. The Riemannian Hessian is the Euclidean Hessian divided by a positive scalar. Eigenvalue signs are preserved. Saddle points cannot be fixed.

Level 1: scalar learnable, γ=esI\gamma = e^s Iγ=esI

The Christoffel symbols are Γijk=12(∂is δjk+∂js δik−∂ks δij)\Gamma^k_{ij} = \tfrac{1}{2}(\partial_i s\,\delta_{jk} + \partial_j s\,\delta_{ik} - \partial_k s\,\delta_{ij})Γijk​=21​(∂i​sδjk​+∂j​sδik​−∂k​sδij​). Contracting with ℓk\ell_kℓk​:

Cij=12(∂is ℓj+∂js ℓi−(∇s⋅ℓ) δij).C_{ij} = \tfrac{1}{2}\bigl(\partial_i s\,\ell_j + \partial_j s\,\ell_i - (\nabla s \cdot \ell)\,\delta_{ij}\bigr).Cij​=21​(∂i​sℓj​+∂j​sℓi​−(∇s⋅ℓ)δij​).

The trace is

tr(C)=2−N2 (∇s⋅ℓ).\mathrm{tr}(C) = \frac{2 - N}{2}\,(\nabla s \cdot \ell).tr(C)=22−N​(∇s⋅ℓ).

This is dimension-dependent.

  • N=2N = 2N=2: tr(C)=0\mathrm{tr}(C) = 0tr(C)=0. The correction is trace-free. It can redistribute eigenvalues but not change the total. For an indefinite HHH with tr(H)>0\mathrm{tr}(H) > 0tr(H)>0, the trace-free CCC can shift one eigenvalue up and the other down by equal amounts, equalising them at tr(H)/2>0\mathrm{tr}(H)/2 > 0tr(H)/2>0 (a clean construction: the optimal ∇s\nabla s∇s solves a 2×22 \times 22×2 linear system with determinant ∥ℓ∥2\lVert \ell\rVert^2∥ℓ∥2, always solvable when ℓ≠0\ell \ne 0ℓ=0). When tr(H)≤0\mathrm{tr}(H) \le 0tr(H)≤0, the trace-free constraint forces tr(H−C)≤0\mathrm{tr}(H - C) \le 0tr(H−C)≤0, making positive-definiteness impossible.

  • N>2N > 2N>2: tr(C)=2−N2(∇s⋅ℓ)\mathrm{tr}(C) = \frac{2 - N}{2}(\nabla s \cdot \ell)tr(C)=22−N​(∇s⋅ℓ) depends on ∇s⋅ℓ\nabla s \cdot \ell∇s⋅ℓ, whose sign the learner controls. The scalar's NNN degrees of freedom (the components of ∇s\nabla s∇s) control an N(N+1)/2N(N + 1)/2N(N+1)/2-dimensional space of symmetric matrices, with the additional structural constraint that CCC is rank-two plus a scalar multiple of the identity. Sign-flipping becomes increasingly constrained as NNN grows.

Level 2: diagonal learnable, γ=diag(es1,…,esN)\gamma = \mathrm{diag}(e^{s_1}, \dots, e^{s_N})γ=diag(es1​,…,esN​)

The Christoffel symbols of a diagonal metric involve cross-terms with factors esi−sje^{s_i - s_j}esi​−sj​. The exponential anisotropy is what unlocks the trace constraint:

  • The trace of CCC is not constrained to depend only on ∇s⋅ℓ\nabla s \cdot \ell∇s⋅ℓ. The NNN independent log-scales sis_isi​ give NNN independent control directions, and the exponential ratios esi−sje^{s_i - s_j}esi​−sj​ allow asymmetric amplification.
  • Numerically verified for N=2N = 2N=2 on multiple test functions: the diagonal learnable can flip eigenvalue signs on the symmetric saddle L=x2−y2L = x^2 - y^2L=x2−y2 (where tr(H)=0\mathrm{tr}(H) = 0tr(H)=0 and the scalar cannot succeed), the asymmetric saddle x2−3y2x^2 - 3 y^2x2−3y2, the monkey saddle x3−3xy2x^3 - 3 x y^2x3−3xy2, and the Rosenbrock function.
  • The constructive Gershgorin argument in the geodesic convexity entry (Appendix C.2) shows that for any symmetric indefinite HHH and any ℓ\ellℓ with all components nonzero, there exists a (diagonal) σ\sigmaσ such that H−C≻0H - C \succ 0H−C≻0. The Frobenius norm of the required σ\sigmaσ depends on HHH and ℓ\ellℓ (it scales with max⁡i(Ri−Hii)/min⁡i∣ℓi∣\max_i (R_i - H_{ii})/\min_i |\ell_i|maxi​(Ri​−Hii​)/mini​∣ℓi​∣, where RiR_iRi​ is the iii-th off-diagonal row sum of HHH), so "Frobenius-bounded" is bounded for each instance but the bound is instance-dependent. The construction degenerates on coordinate axes where some ℓi=0\ell_i = 0ℓi​=0.

Summary

VariantCCC structureSign-flip capability
Constant γ\gammaγC=0C = 0C=0None
Scalar learnablerank-two plus scalar ⋅I\cdot I⋅I, trace constrainedN=2N = 2N=2: iff tr(H)>0\mathrm{tr}(H) > 0tr(H)>0; N>2N > 2N>2: increasingly constrained
Diagonal learnableNNN independent degrees of freedom, unrestricted traceAll tested N=2N = 2N=2 cases; arbitrary NNN proven in geodesic convexity entry

Each level strictly contains the previous one (setting all sis_isi​ equal in the diagonal case recovers the scalar). This hierarchy gives a geometric explanation for the empirical observation that the diagonal learnable outperforms the scalar learnable on best-run ceilings: it has the richest curvature-correction capability available within the framework's diagonal class.

\lambda_{\min}(\mathrm{Hess}_g L) across hierarchy levels on the four test saddles: each level strictly improves on the previous

7. The optimal ∇s\nabla s∇s and why the base rule misses it

The base online rule (Section 4) was designed to maximise adaptive step-size calibration via the metric trace, not to optimise the curvature correction CCC. As a result, the rule's equilibrium σij=∂si/∂θj\sigma_{ij} = \partial s_i / \partial \theta_jσij​=∂si​/∂θj​ does not match the structure of the optimal correction.

The optimal σ\sigmaσ at the canonical saddle

For L=x2−y2L = x^2 - y^2L=x2−y2 at (1,1)(1, 1)(1,1), H=diag(2,−2)H = \mathrm{diag}(2, -2)H=diag(2,−2) and ℓ=(2,−2)\ell = (2, -2)ℓ=(2,−2). With ξ=1\xi = 1ξ=1 and γ=I\gamma = Iγ=I, the diagonal optimisation gives the following budget-constrained optima for λmin⁡(HessgL)\lambda_{\min}(\mathrm{Hess}_g L)λmin​(Hessg​L).

Frobenius budget RRR on σ\sigmaσλmin⁡\lambda_{\min}λmin​Sign-flip?
000−0.222-0.222−0.222no
1.51.51.5−0.009-0.009−0.009no
222+0.055+0.055+0.055yes
555+0.360+0.360+0.360yes
101010+0.770+0.770+0.770yes

The sign-flip threshold is R≈1.6R \approx 1.6R≈1.6. The optimal σ\sigmaσ at large RRR has a characteristic anti-correlation structure: σ11≪0\sigma_{11} \ll 0σ11​≪0 (shrink the scale along the positive-curvature direction) and σ22≫0\sigma_{22} \gg 0σ22​≫0 (grow the scale along the negative-curvature direction). The asymmetry between H11H_{11}H11​ and H22H_{22}H22​ is what produces the nonzero trace shift that the scalar case cannot achieve.

What the base rule produces

At the same saddle with the base online rule and λs=10\lambda_s = 10λs​=10, the equilibrium reasoning is more subtle than a single linearisation because the trajectory state sts_tst​ is not literally the gradient of a global potential s(θ)s(\theta)s(θ) (see §3 and §10 for the metric-field-vs-trajectory-state distinction). For a fixed-point analysis at the canonical saddle, treat the gradient as constant locally (ℓ1=2,ℓ2=−2\ell_1 = 2, \ell_2 = -2ℓ1​=2,ℓ2​=−2); the equilibrium is si∗=ξℓi2/(λs−ξℓi2)s_i^* = \xi\ell_i^2/(\lambda_s - \xi\ell_i^2)si∗​=ξℓi2​/(λs​−ξℓi2​), the same value for both coordinates (4/6 = 2/3) because ℓ12=ℓ22=4\ell_1^2 = \ell_2^2 = 4ℓ12​=ℓ22​=4. With both si∗s_i^*si∗​ equal, the metric is uniform across coordinates, the Christoffel-correction symmetry forces C11+C22=0C_{11} + C_{22} = 0C11​+C22​=0, and H−CH - CH−C keeps one positive and one negative eigenvalue. The diagonal degree of freedom is wasted at this symmetric saddle: the rule drives both scales identically because it responds to gradient magnitudes (ℓi2\ell_i^2ℓi2​, equal at this saddle), not to curvature signs (HiiH_{ii}Hii​, opposite). For asymmetric saddles where ∣ℓiHii∣|\ell_i H_{ii}|∣ℓi​Hii​∣ differs across coordinates, the rule produces an asymmetric s∗s^*s∗, but the produced σ\sigmaσ derived from the spatial variation of s∗s^*s∗ still does not match the optimal anti-correlation structure of Section 7.

The qualitative conclusion (base rule wastes the diagonal degree of freedom at the symmetric saddle, produces a λmin⁡\lambda_{\min}λmin​ that is suboptimal but not as bad as no correction) is robust; the exact value −2/27-2/27−2/27 quoted in the table below depends on a specific linearisation that is recorded in the accompanying notebook notebooks/optimal-correction.nb.

Quantitative gap

For the canonical saddle with ξ=1\xi = 1ξ=1.

Methodλmin⁡(HessgL)\lambda_{\min}(\mathrm{Hess}_g L)λmin​(Hessg​L)Geodesically convex?
No correction (constant γ\gammaγ)−2/9≈−0.222-2/9 \approx -0.222−2/9≈−0.222no
Base online rule (λs=10\lambda_s = 10λs​=10, linearised at γ=I\gamma = Iγ=I)−2/27≈−0.074-2/27 \approx -0.074−2/27≈−0.074no
Optimal σ\sigmaσ (diagonal, R=5R = 5R=5)+0.360+0.360+0.360yes

The base rule reduces the negative eigenvalue but never eliminates it. The optimal achieves strict positive-definiteness. The pattern persists across all tested saddles (asymmetric, monkey, Rosenbrock): the base rule is suboptimal, and the optimal with sufficient budget achieves sign-flipping.

8. The curvature-aware update rule

The key insight from Section 7: the update must distinguish directions by their curvature sign, not just by gradient magnitude. The proposed curvature-aware rule, in this entry's "inverse-metric" convention (γ−1=diag(esi)\gamma^{-1} = \mathrm{diag}(e^{s_i})γ−1=diag(esi​), so increasing sis_isi​ means larger step in direction iii),

si←si+μ[ξ esi ℓi2−β sign(H^ii) esi ∣ℓi∣2]−μ λs si.s_i \leftarrow s_i + \mu\Bigl[\xi\,e^{s_i}\,\ell_i^2 - \beta\,\mathrm{sign}(\hat H_{ii})\,e^{s_i}\,\lvert \ell_i\rvert^2\Bigr] - \mu\,\lambda_s\,s_i.si​←si​+μ[ξesi​ℓi2​−βsign(H^ii​)esi​∣ℓi​∣2]−μλs​si​.

The first term (ξ esi ℓi2\xi\,e^{s_i}\,\ell_i^2ξesi​ℓi2​) is the existing adaptive step-size calibration. The second term (−β sign(H^ii) esi ∣ℓi∣2-\beta\,\mathrm{sign}(\hat H_{ii})\,e^{s_i}\,\lvert \ell_i\rvert^2−βsign(H^ii​)esi​∣ℓi​∣2) creates the anti-correlation we want: it shrinks sis_isi​ where curvature is positive (so the step in that direction is smaller, the Newton direction) and grows sis_isi​ where curvature is negative (a larger step in the saddle-escape direction). Setting β=0\beta = 0β=0 recovers the base rule.

Sign-convention check. The "optimal σ\sigmaσ" structure derived in Section 7 was stated in the form "σ11≪0\sigma_{11} \ll 0σ11​≪0 in positive-curvature directions, σ22≫0\sigma_{22} \gg 0σ22​≫0 in negative-curvature directions." That statement uses the geodesic-convexity convention where γii=esi\gamma_{ii} = e^{s_i}γii​=esi​ (so σii<0\sigma_{ii} < 0σii​<0 means smaller metric weight, smaller step). In this entry's inverse-metric convention, the same physical behaviour ("smaller step in high-curvature directions") corresponds to decreasing sis_isi​ when Hii>0H_{ii} > 0Hii​>0. The curvature-aware rule above does decrease sis_isi​ when sign(H^ii)>0\mathrm{sign}(\hat H_{ii}) > 0sign(H^ii​)>0 (because of the minus sign on the β\betaβ term), so the sign convention is internally consistent. The Section 7 derivation, transposed to this convention, would read "the optimal σii\sigma_{ii}σii​ (under the inverse-metric convention) is positive in positive-curvature directions and negative in negative-curvature directions," that is, σii\sigma_{ii}σii​ co-correlates with −sign(Hii)-\mathrm{sign}(H_{ii})−sign(Hii​) in this convention.

Estimating HiiH_{ii}Hii​

The diagonal Hessian entries are approximated by secant differences between consecutive gradient evaluations:

H^ii≈ℓi(t)−ℓi(t−1)θi(t)−θi(t−1).\hat H_{ii} \approx \frac{\ell_i^{(t)} - \ell_i^{(t-1)}}{\theta_i^{(t)} - \theta_i^{(t-1)}}.H^ii​≈θi(t)​−θi(t−1)​ℓi(t)​−ℓi(t−1)​​.

The cost is one extra gradient snapshot (O(N)O(N)O(N) memory) and O(N)O(N)O(N) computation per step. No additional backward passes are needed.

Caveats on the secant estimator

  1. Bias from off-diagonal Hessian. The secant formula estimates (Hδθ)i/δθi(H \delta\theta)_i / \delta\theta_i(Hδθ)i​/δθi​, not HiiH_{ii}Hii​. When HHH has significant off-diagonal entries and the step δθ\delta\thetaδθ is not axis-aligned, the estimate is biased. The sign\mathrm{sign}sign operation provides partial robustness: only the sign matters, not the magnitude, so moderate bias is tolerable as long as it does not flip the sign. The Hutchinson-based estimator analysed in the derived optimizer has a stronger robustness property ((1+δ)/(1-δ) relative-error bound, independent of dimension and condition number), but it requires the relative error to stay bounded below 1; the secant estimator does not satisfy this hypothesis in practice (the derived-optimizer entry §5.4 shows the initial relative error is an order of magnitude above the theorem's domain), so the formal bound does not apply to secant. Sign-robustness is the only formal guarantee available for the secant version.

  2. Near H^ii=0\hat H_{ii} = 0H^ii​=0. The sign\mathrm{sign}sign function is discontinuous and the secant estimate is noisy, so the curvature-sign estimate is unreliable in the transition region. Smoothing via tanh⁡(H^ii/τ)\tanh(\hat H_{ii}/\tau)tanh(H^ii​/τ) instead of sign\mathrm{sign}sign would help; the derived optimizer entry Section 5 discusses why the tanh⁡\tanhtanh smoothing is insufficient on its own to recover the Newton target.

  3. Small steps. When θi(t)−θi(t−1)\theta_i^{(t)} - \theta_i^{(t-1)}θi(t)​−θi(t−1)​ is small, the secant denominator becomes ill-conditioned. The implementation uses a minimum step-size threshold and EMA smoothing of the estimate.

  4. No convergence proof. The curvature-aware rule is motivated by the structure of the optimal σ\sigmaσ but has not been proven to converge to it. The empirical results in Sections 9 and 10 are the evidence base.

The fully principled Newton target

A more aggressive principled version replaces both terms with the Newton target

Di=−λ log⁡max⁡(H^ii, ε),D_i = -\lambda\,\log\max(\hat H_{ii},\,\varepsilon),Di​=−λlogmax(H^ii​,ε),

which by the diagonal minimax theorem (see the derived optimizer entry) is the unique minimax-optimal log-diagonal preconditioner on diagonal quadratics. This is the basis of the principled diagonal Newton variant explored in the derived optimizer entry. Its empirical fate on real architectures is the cautionary tale of that entry: the principled rule is structurally misspecified against the Kronecker structure of neural-network Hessians, and full-batch ablation shows that more aggressive preconditioning yields worse MNIST accuracy. The lesson is that local diagonal optimality is not enough; the structural class matters more than the choice within the class.

9. Empirical results

9.1 1000-trial MNIST MLP sweep

Setup: 2-layer MLP (784, 64, 64, 10), batch size 1024, 200 epochs, 1000 Optuna trials per optimizer. Raw runs in results/mnist_mlp/<optimizer>/itr_4/. The rows below are the learnable-diagonal variants and the Adam, SGD, and Muon baselines, all from the same sweep.

VariantBestMedianMeanWorst
sgd_learn_diag (base rule)98.41%86.57%64.36%2.24%
sgd_learn_diag_curv (curvature-aware)98.39%78.04%60.88%5.36%
sgd_learn_diag_curv_log98.38%57.89%57.27%4.11%
sgd_learn_diag_log98.36%84.63%62.04%5.30%
Adam98.09%94.73%72.69%9.80%
SGD98.04%78.19%58.43%2.57%
Muon98.39%93.73%70.53%9.29%

Two things to note.

  1. Best-run ceiling. The base learnable diagonal finds the highest single-trial accuracy across all 28 swept optimizers (98.41%, narrowly ahead of Muon and the curvature-aware variants). This is a real ceiling signal: with sufficient hyperparameter search, the variant can reach an accuracy that Adam does not match.

  2. Robustness gap. The median is 86.57%86.57\%86.57% for the base rule and 78.04%78.04\%78.04% for the curvature-aware variant. Adam's median is 94.73%94.73\%94.73%. The learnable variants are substantially more hyperparameter-sensitive than Adam. The hyperparameter search range includes regions where the variants behave pathologically, which is the source of the long left tail.

The honest summary: the learnable diagonal raises the best-run ceiling but does not produce a robust improvement under random hyperparameter draws.

MNIST MLP best-vs-median scatter (1000-trial sweep): high ceiling, wide robustness gap

9.2 Implicit sharpness-aware optimisation

A controlled measurement of Hessian sharpness during training shows that the learnable diagonal reaches matched loss levels at substantially flatter minima than Adam.

Setup: 2-layer MLP (8-16-4, 212 parameters), synthetic 200-sample classification.

Loss thresholdSGD max eigAdam max eigLearn-Diag max eigLD vs Adam
≤0.10\le 0.10≤0.100.70114.44790.683184.6% flatter
≤0.05\le 0.05≤0.050.70112.25860.683169.8% flatter
≤0.01\le 0.01≤0.010.36290.69430.294657.6% flatter

The likely mechanism is a combination of two components, both present in the base learnable diagonal variant (the variant used in this measurement; the curvature-aware variant was not the one tested). First, the damping factor r=1/(1+∣v∣)r = 1/(1 + \lvert v\rvert)r=1/(1+∣v∣) shrinks the step in directions where ∑iesigi2\sum_i e^{s_i} g_i^2∑i​esi​gi2​ is large, which empirically correlates with sharper regions, preventing entry into sharp basins. Second, the metric update si←si+μξ esi gi2s_i \leftarrow s_i + \mu\xi\,e^{s_i}\,g_i^2si​←si​+μξesi​gi2​ amplifies weight on high-gradient-magnitude directions, which geometrically stretches the step along those directions and (combined with the damping) effectively compresses the step in high-curvature directions where gradients spike sharply. The net behaviour resembles what SAM (Foret et al., 2021) achieves via adversarial perturbation.

This attribution is a hypothesis: the experiment shows that the learnable diagonal reaches flatter minima at matched loss levels, but it does not isolate which mechanism (damping, metric update, or both, or something else) is responsible. The fully principled Riemannian-Hessian curvature correction CCC from Section 3 is a third candidate mechanism that would apply once the curvature-aware variant is tested with sharpness measurement; that experiment has not been done.

The qualitative comparison.

PropertySAMLearnable diagonal metric (base)
Mechanismadversarial perturbation max⁡δL(θ+δ)\max_\delta L(\theta + \delta)maxδ​L(θ+δ)candidate mechanisms: damping factor rrr plus learned-diagonal scaling; curvature correction CCC is a candidate not isolated in this experiment
Extra cost per step2×2\times2× (two forward-backward)≈1.2×\approx 1.2\times≈1.2× (metric update)
Theoretical backingPAC-Bayes generalisation boundRiemannian Hessian formula (Section 3) for the curvature-correction candidate; no formal backing for the damping mechanism
Explicit sharpness penaltyyesno (implicit through geometry, mechanism not yet isolated)

This is the most plausible positive mechanism for why the learnable diagonal reaches higher peak accuracy than Adam on best-run comparisons, despite the analysis showing that its preconditioning direction is anti-Newton. The hypothesis is that the variant wins not because of better preconditioning (the preconditioning is actively wrong) but because of implicit sharpness regularisation that biases convergence toward flatter, better-generalising minima. Confirming this requires the controlled experiments listed in Section 10 (matched-cost comparison against explicit SAM, scaled-up sharpness measurement, and ablation of the two candidate mechanisms above).

Sharpness \lambda_{\max}(H) over training: learnable diagonal reaches matched loss at substantially flatter minima

Note on baseline values. The sharpness experiment above uses a 212-parameter network and is a small-scale controlled measurement, not part of the 1000-trial MNIST sweep. The "Adam 98.09%" baseline cited in Section 9.1 (from the 1000-trial Optuna sweep on the 55k-parameter MNIST MLP) is a different setting from the older "Adam 97.17%" baseline that appears in the derived optimizer's full-batch ablation (smaller network, full-batch gradients). The two are not directly comparable. The implicit-SAM result here uses neither; it is its own controlled measurement on a third (smaller) network.

9.3 Small multimodal test functions

A focused sweep on standard 2D test functions (raw runs in results/small_examples_*/, itr_4) isolates where the curvature-aware diagonal helps. On rugged, multimodal landscapes it is genuinely useful; on smooth ones Adam remains strongest.

FunctionBest optimizerNotable result
Rastriginsgd_learn_diag_curv491/1000491/1000491/1000 trials converged vs Adam's 24/100024/100024/1000
Ackleysgd_learn_diag_curvbest value 3.6×10−73.6\times10^{-7}3.6×10−7; the log variant sgd_learn_diag_curv_log converged 184/5000184/5000184/5000 vs 2/50002/50002/5000 for the non-log version (earlier itr_3 sweep)
Beale / Himmelblau / RosenbrockAdamstrongest on both best value and median; curvature-aware variant converges often but is less robust

The supportable claim is narrow: the curvature-aware diagonal converges far more often than Adam on rugged multimodal functions (Rastrigin, and Ackley with the log embedding) and is competitive but not dominant on smooth functions. The older "log embedding solves Ackley when all baselines fail" framing is too broad and is not quoted as a general result.

10. What stays open

  1. Closing the robustness gap. The median accuracy of the learnable variants is well below Adam's on MNIST MLP. The structural causes are not pinned down. Candidate explanations include (i) the curvature-aware secant estimator's noise on the long left tail of the hyperparameter distribution, (ii) the mean-centering operation interacting poorly with weight decay at certain LR-decay combinations, and (iii) the metric clip (∣si∣≤4\lvert s_i\rvert \le 4∣si​∣≤4) being too tight in some regimes and the metric saturating. A diagnostic study (which hyperparameter draws produce the divergent trials, and what feature of the learning dynamics distinguishes them) has not been done.

  2. Implicit-SAM at scale. The sharpness measurement in Section 9.2 was on a 212-parameter network. Direct sharpness measurement on a realistic-scale task (MNIST CNN, CIFAR-10 SmallCNN) compared against explicit SAM at matched computational cost would be the next test.

  3. Curvature-aware variant vs base rule. Empirically the two variants have the same peak (98.39%98.39\%98.39% vs 98.41%98.41\%98.41%) and similar medians. The theoretical advantage of the curvature-aware rule (anti-correlation with H^ii\hat H_{ii}H^ii​, motivated by Section 7) does not translate into a measurable empirical edge on this task. Whether it does on harder landscapes (Rastrigin and other multimodal small functions) is positive: the curvature-aware variant converged in 491/1000491/1000491/1000 Rastrigin trials versus Adam's 24/100024/100024/1000 (Section 9.3).

  4. Coupled weight decay. The Riemannian-correct weight decay (passed through G−1G^{-1}G−1) is implementable but has not been swept. The off-diagonal metric entry notes the same open question for the off-diagonal variant.

  5. Combination with off-diagonal. The learnable diagonal and off-diagonal generalisations are structurally orthogonal (different mechanisms for enriching the metric). A combined variant has not been registered or swept.

Appendix A. Derivation of the Christoffel correction for diagonal γ\gammaγ

Convention used in this appendix. This appendix derives the Christoffel symbols of the metric γ\gammaγ itself, using the convention γij=esi δij\gamma_{ij} = e^{s_i}\,\delta_{ij}γij​=esi​δij​ (the geodesic-convexity-entry convention). This is opposite to the main-text convention of Section 1, which parameterises the inverse metric as γ−1=diag(esi)\gamma^{-1} = \mathrm{diag}(e^{s_i})γ−1=diag(esi​). To apply any formula from this appendix to the main-text parameterisation, substitute si→−sis_i \to -s_isi​→−si​ throughout. The derivation is reproduced here in the geodesic-convexity convention because that is the natural setting for the Christoffel calculus; the main text's sign convention is the natural setting for the online optimizer (preconditioner-multiplies-gradient).

For γij=esi δij\gamma_{ij} = e^{s_i}\,\delta_{ij}γij​=esi​δij​ (no sum), the inverse is γij=e−si δij\gamma^{ij} = e^{-s_i}\,\delta_{ij}γij=e−si​δij​ and the derivatives are ∂kγij=esi ∂ksi δij\partial_k \gamma_{ij} = e^{s_i}\,\partial_k s_i\,\delta_{ij}∂k​γij​=esi​∂k​si​δij​. The Christoffel symbols of γ\gammaγ are

Γijk(γ)=12 γkl(∂iγjl+∂jγil−∂lγij).\Gamma^k_{ij}(\gamma) = \tfrac{1}{2}\,\gamma^{kl}\bigl(\partial_i \gamma_{jl} + \partial_j \gamma_{il} - \partial_l \gamma_{ij}\bigr).Γijk​(γ)=21​γkl(∂i​γjl​+∂j​γil​−∂l​γij​).

Case i=j=ki = j = ki=j=k: Γiii=12 e−si(∂iγii+∂iγii−∂iγii)=12 ∂isi\Gamma^i_{ii} = \tfrac{1}{2}\,e^{-s_i}(\partial_i \gamma_{ii} + \partial_i \gamma_{ii} - \partial_i \gamma_{ii}) = \tfrac{1}{2}\,\partial_i s_iΓiii​=21​e−si​(∂i​γii​+∂i​γii​−∂i​γii​)=21​∂i​si​.

Case i=j≠ki = j \ne ki=j=k: Γiik=12 e−sk(∂iγik+∂iγik−∂kγii)=−12 esi−sk ∂ksi\Gamma^k_{ii} = \tfrac{1}{2}\,e^{-s_k}(\partial_i \gamma_{ik} + \partial_i \gamma_{ik} - \partial_k \gamma_{ii}) = -\tfrac{1}{2}\,e^{s_i - s_k}\,\partial_k s_iΓiik​=21​e−sk​(∂i​γik​+∂i​γik​−∂k​γii​)=−21​esi​−sk​∂k​si​.

Case i≠ji \ne ji=j, k=ik = ik=i: Γiji=12 e−si(∂iγji+∂jγii−∂iγij)=12 ∂jsi\Gamma^i_{ij} = \tfrac{1}{2}\,e^{-s_i}(\partial_i \gamma_{ji} + \partial_j \gamma_{ii} - \partial_i \gamma_{ij}) = \tfrac{1}{2}\,\partial_j s_iΓiji​=21​e−si​(∂i​γji​+∂j​γii​−∂i​γij​)=21​∂j​si​.

Case i≠ji \ne ji=j, k=jk = jk=j: Γijj=12 ∂isj\Gamma^j_{ij} = \tfrac{1}{2}\,\partial_i s_jΓijj​=21​∂i​sj​.

Case i,j,ki, j, ki,j,k all distinct: Γijk=0\Gamma^k_{ij} = 0Γijk​=0.

The exponential ratios esi−ske^{s_i - s_k}esi​−sk​ in the off-diagonal terms are what generate the asymmetric amplification mentioned in Section 6: when si≫sks_i \gg s_ksi​≫sk​, the contribution of ∂ksi\partial_k s_i∂k​si​ to Γiik\Gamma^k_{ii}Γiik​ is exponentially amplified. This is the structural ingredient that lets the diagonal learnable achieve sign-flipping that the scalar cannot.

The full Cij=Γijk ℓkC_{ij} = \Gamma^k_{ij}\,\ell_kCij​=Γijk​ℓk​ for the diagonal case is a sum over the five cases above, contracted with ℓk\ell_kℓk​. The diagonal entries (used in the trace identity discussion in the main text) come from cases (i) and (ii),

Cii=12 ∂isi ℓi  −  12∑k≠iesi−sk ∂ksi ℓk,C_{ii} = \tfrac{1}{2}\,\partial_i s_i\,\ell_i \;-\; \tfrac{1}{2}\sum_{k \ne i} e^{s_i - s_k}\,\partial_k s_i\,\ell_k,Cii​=21​∂i​si​ℓi​−21​k=i∑​esi​−sk​∂k​si​ℓk​,

and the off-diagonal entries (i≠ji \ne ji=j) come from cases (iii) and (iv),

Cij=12 (∂jsi ℓi+∂isj ℓj).C_{ij} = \tfrac{1}{2}\,\bigl(\partial_j s_i\,\ell_i + \partial_i s_j\,\ell_j\bigr).Cij​=21​(∂j​si​ℓi​+∂i​sj​ℓj​).

The full case-by-case expression is reproduced in the geodesic convexity entry's Appendix C.

Appendix B. Trace formula for scalar γ\gammaγ

For γij=es δij\gamma_{ij} = e^s\,\delta_{ij}γij​=esδij​ with scalar sss, the Christoffel symbols are

Γijk(γ)=12(∂is δjk+∂js δik−∂ks δij).\Gamma^k_{ij}(\gamma) = \tfrac{1}{2}\bigl(\partial_i s\,\delta_{jk} + \partial_j s\,\delta_{ik} - \partial_k s\,\delta_{ij}\bigr).Γijk​(γ)=21​(∂i​sδjk​+∂j​sδik​−∂k​sδij​).

Contracting with ℓk\ell_kℓk​:

Cij=12(∂is ℓj+∂js ℓi−(∇s⋅ℓ) δij).C_{ij} = \tfrac{1}{2}\bigl(\partial_i s\,\ell_j + \partial_j s\,\ell_i - (\nabla s \cdot \ell)\,\delta_{ij}\bigr).Cij​=21​(∂i​sℓj​+∂j​sℓi​−(∇s⋅ℓ)δij​).

The trace is

tr(C)=∑iCii=12(∇s⋅ℓ+∇s⋅ℓ−N (∇s⋅ℓ))=2−N2 (∇s⋅ℓ).\mathrm{tr}(C) = \sum_i C_{ii} = \tfrac{1}{2}\bigl(\nabla s \cdot \ell + \nabla s \cdot \ell - N\,(\nabla s \cdot \ell)\bigr) = \frac{2 - N}{2}\,(\nabla s \cdot \ell).tr(C)=i∑​Cii​=21​(∇s⋅ℓ+∇s⋅ℓ−N(∇s⋅ℓ))=22−N​(∇s⋅ℓ).

The factor (2−N)/2(2 - N)/2(2−N)/2 is the source of the dimension-dependent trace constraint discussed in Section 6. For N=2N = 2N=2 the correction is trace-free. For N>2N > 2N>2 the factor (2−N)/2(2 - N)/2(2−N)/2 is negative, so Cauchy-Schwarz gives ∣tr(C)∣≤N−22 ∥∇s∥ ∥ℓ∥|\mathrm{tr}(C)| \le \frac{N - 2}{2}\,\lVert \nabla s\rVert\,\lVert \ell\rVert∣tr(C)∣≤2N−2​∥∇s∥∥ℓ∥ as an upper bound on the magnitude of the (sign-controllable) trace shift. A positive trace shift requires (∇s)⋅ℓ<0(\nabla s)\cdot \ell < 0(∇s)⋅ℓ<0; a negative shift requires (∇s)⋅ℓ>0(\nabla s)\cdot \ell > 0(∇s)⋅ℓ>0. The bound on magnitude constrains how much shift the scalar learnable can produce in either direction.

Appendix C. Why r=1/(1+v)r = 1/(1 + v)r=1/(1+v) damps sharp directions

The damping factor rt=1/(1+vt)r_t = 1/(1 + v_t)rt​=1/(1+vt​) with vt=ξ ∑iesi gt,i2≥0v_t = \xi\,\sum_i e^{s_i}\,g_{t,i}^2 \ge 0vt​=ξ∑i​esi​gt,i2​≥0 has a geometric interpretation. Near (but not at) a sharp minimum, at a comparable displacement from the basin centre, the gradient is large in the high-curvature directions (the directions in which HiiH_{ii}Hii​ is large), and the metric weight esie^{s_i}esi​ tracks the gradient magnitude (the metric update pushes sis_isi​ up where gig_igi​ is large). Both factors combine: esi gt,i2e^{s_i}\,g_{t,i}^2esi​gt,i2​ is large in directions that are both sharp and currently being traversed quickly. The sum produces a large vtv_tvt​, which shrinks the step.

This is structurally what the Sherman-Morrison denominator on the loss embedding does for the rank-one metric: it bounds the step at 1/(2ξ)1/(2\sqrt{\xi})1/(2ξ​) regardless of the parameter-space gradient. With a learnable diagonal underneath, the bound becomes direction-aware: the directions that contribute most to vtv_tvt​ (sharp and active) are the directions that get most damped.

Combined with the candidate curvature correction CCC from Section 3 (which would, if it were the active mechanism, bias the Riemannian Hessian to be more positive-definite), the qualitative picture is implicit sharpness-aware behaviour: the metric prevents entry into sharp basins (via rtr_trt​) and (under the curvature-correction mechanism) bends the effective curvature toward flatter regions (via CCC). The empirical sharpness measurement in Section 9.2 is consistent with these mechanisms but does not isolate them; the curvature-aware variant was not the one tested, so CCC is a candidate mechanism rather than a confirmed one.

Appendix D. Attached materials

Scripts (scripts/):

  • scripts/jax_learn_diag.py: JAX implementation of the base learnable diagonal optimizer.
  • scripts/jax_learn_diag_curv.py: implementation with the curvature-aware update rule.
  • scripts/mnist_mlp_sweep.py: Optuna sweep entry point for the MNIST MLP results.
  • scripts/sharpness_comparison.py: the Section 9.2 sharpness measurement.
  • scripts/make_figures.py: reproduces every figure shown in this entry (PDF and PNG written to figures/).

Notebooks (notebooks/):

  • notebooks/optimal-correction.nb: symbolic derivation of the optimal σ\sigmaσ for sign-flipping, including the canonical-saddle worked example.
  • notebooks/hierarchy-verification.nb: numerical verification that the diagonal learnable achieves sign-flipping where the scalar cannot, across the four test saddles.

References

  • Foret, P., Kleiner, A., Mobahi, H., Neyshabur, B. (2021). Sharpness-aware minimization for efficiently improving generalization. ICLR.
  • Harvey, T. R. (2025). The optimiser hidden in plain sight: training with the loss landscape's induced metric. arXiv:2509.03594.
  • Kingma, D. P., Ba, J. (2014). Adam: A method for stochastic optimization. ICLR.
  • Keskar, N. S., Mudigere, D., Nocedal, J., Smelyanskiy, M., Tang, P. T. P. (2017). On large-batch training for deep learning: generalization gap and sharp minima. ICLR.

Metadata

Type
method
Visibility
public
Published
Mar 27, 2026
Last updated
Jun 14, 2026

Tags

diagonalinduced-metricJAXlearnable-metricoptimizerPyTorch