NEATdocs

Algorithm

How the NEAT update works, from conflict detection to the parameter step (nce_spec_v2).

NEAT detects directional conflict between a gradient gtg_t and an opponent proxy oto_t. When conflict is present, it applies a bounded correction, called Nash Conflict Elimination (NCE), before momentum and weight decay. The current specification is nce_spec_v2.

Update rule

The measured conflict is non-zero only when the gradient points against the opponent:

ct=max⁡(0,  −cos⁡(gt,ot))c_t = \max\big(0,\; -\cos(g_t, o_t)\big)

Next comes the projection of the gradient onto the opponent direction:

pt=proj⁡ot(gt)=gt⋅otot⋅ot+ϵ otp_t = \operatorname{proj}_{o_t}(g_t) = \frac{g_t \cdot o_t}{o_t \cdot o_t + \epsilon}\, o_t

The correction removes the conflicting component, scaled by αt\alpha_t and the conflict:

ncet=−αt ct pt,∥ncet∥≤nce_clip_ratio⋅∥gt∥\mathrm{nce}_t = -\alpha_t \, c_t \, p_t, \qquad \lVert \mathrm{nce}_t \rVert \le \texttt{nce\_clip\_ratio} \cdot \lVert g_t \rVert

Finally, the corrected update passes through momentum and decoupled weight decay:

ut=gt+ncetmt=β mt−1+(1−β) utθt+1=(1−ηλ) θt−η mt\begin{aligned} u_t &= g_t + \mathrm{nce}_t \\ m_t &= \beta\, m_{t-1} + (1 - \beta)\, u_t \\ \theta_{t+1} &= (1 - \eta \lambda)\, \theta_t - \eta\, m_t \end{aligned}

Here η\eta is the learning rate and λ\lambda is the weight decay. If there is no conflict, ncet=0\mathrm{nce}_t = 0 and NEAT reduces to standard momentum SGD.

Math spec: nce_spec_v2

nce_spec_v2
o_t        = opponent_proxy(g_t, m_{t-1})   # momentum, gradient EMA, previous gradient, or blended
conflict_t = relu(-cos(g_t, o_t))
alpha_t    = adaptive_alpha(alpha, rho_t, eta_t, a_t)   # = alpha unless adaptive_alpha=True
proj_t     = proj_{o_t}(g_t)
nce_t      = -alpha_t * conflict_t * proj_t             # clipped to nce_clip_ratio * ||g_t||
u_t        = g_t + nce_t
m_t        = beta * m_{t-1} + (1 - beta) * u_t
theta'     = (1 - lr * wd) * theta_t
theta_t+1  = theta' - lr * m_t

Worked example

With θt=[1.0,2.0]\theta_t = [1.0, 2.0], gt=[1.0,0.0]g_t = [1.0, 0.0], mt−1=[−1.0,0.0]m_{t-1} = [-1.0, 0.0], α=0.5\alpha = 0.5, β=0\beta = 0 and learning rate 0.10.1:

conflict_t = 1.0
proj_t     = [1.0, 0.0]
nce_t      = [-0.5, 0.0]
u_t        = [0.5, 0.0]
m_t        = [0.5, 0.0]
theta_t+1  = [0.95, 2.0]

The gradient points straight against the momentum, so half of it is removed before the step.

Optional extensions

All of these default to off.

Adaptive alpha (adaptive_alpha=True) makes the correction strength tensor-local and data-dependent. Conflict and gradient noise increase it; stable positive alignment reduces it:

αt=clip⁡ ⁣(α (1+ρt+ηt−0.5max⁡(at,0)), αmin⁡, αmax⁡)\alpha_t = \operatorname{clip}\!\big(\alpha\,(1 + \rho_t + \eta_t - 0.5\max(a_t, 0)),\ \alpha_{\min},\ \alpha_{\max}\big)

where ρt\rho_t, ηt\eta_t and ata_t are running averages of conflict, gradient noise and alignment.

Adaptive preconditioning (adaptive_preconditioning=True) keeps an Adam-style second moment vt=β2vt−1+(1−β2)gt2v_t = \beta_2 v_{t-1} + (1-\beta_2) g_t^2 and divides the step by vt+ϵ\sqrt{v_t} + \epsilon. It rescales coordinates by observed squared gradients; it is not a Hessian or curvature estimate.

Stabilizers: update_mode="lion" applies a sign update after the correction, nesterov=True uses Nesterov-style momentum, and lookahead_k syncs slow weights every kk steps. See Configuration.

Opponent sources

The opponent proxy oto_t is selected with opponent_source: momentum (default), gradient_ema, previous_gradient, or blended. In player-aware mode, the default opponent is the mean of the other players.

Why "Nash-inspired"

NEAT interprets directional disagreement as an interaction between two signals, the current gradient and the trajectory so far. It does not compute a Nash equilibrium or inherit the guarantees of Nash-bargaining methods such as Nash-MTL.

The closest relatives are multi-task gradient-surgery methods like PCGrad and CAGrad. Those compare gradients from separate tasks at the same step; NEAT's standard optimizer compares the gradient against its own history. The full comparison is in related work.

Spec versions

nce_spec_v2 is the frozen default. Pass spec_version="nce_spec_v3" to opt in to additive research controls: conflict granularity, an L2 trust-region correction bound, scheduled momentum/gradient-EMA opponent ensembles, correction/preconditioner ordering, and deterministic reference reductions. v3 is not used for any headline claim, and some v3 combinations are reference-engine-only; framework adapters reject them explicitly.

The executable specification lives in docs/research/math-spec.md.

On this page