TL;DR
Why do neural networks generalize long after completely memorizing the training set? This paper proves that post-memorization training under weight decay operates as constrained optimization: the loss keeps the model pinned to the zero-loss manifold, while weight decay drives gradient descent on the parameter norm along this surface. By decoupling layers under a fast/slow learning assumption, the authors derive an explicit dynamical equation for the embedding layer that fully reproduces grokking and circular representation learning.
What Problem Does This Paper Address?
In a phenomenon called grokking, a neural network achieves near-zero training error rapidly, but takes thousands or millions of additional steps before test accuracy suddenly jumps to 100%. Prior research established that weight decay plays a pivotal role in this delayed generalization, but the exact mathematical mechanics behind the post-memorization phase remained poorly understood.
Specifically, this paper tackles two questions:
- What exact mathematical role does weight decay play once training loss is zero?
- Can we decouple and isolate the learning dynamics of individual components (like an embedding layer) from the rest of the deep network?
Methods
The authors analyze gradient flow under mean-squared error (MSE) loss with weight decay coefficient $\lambda$:
$$\mathcal{L}_\lambda(\theta) = \mathcal{L}(\theta) + \lambda \|\theta\|^2$$
- Constrained Optimization on the Zero-Loss Manifold ($Z$):
- The authors prove that when $\lambda \to 0$, the loss gradient $\nabla \mathcal{L}(\theta)$ becomes strictly orthogonal to the tangent space of the zero-loss manifold $Z$.
- Consequently, the loss does not push the model along the manifold—it only acts as a restoring force keeping parameters on $Z$. The parameter updates along the manifold are driven purely by weight decay minimizing the Euclidean parameter norm $\|\theta\|^2$.
- Using the Morse–Sard theorem, the authors show that for almost all datasets, $Z$ is a smooth manifold free of singular points.
- Decoupled / Isolated Dynamics:
- Because the second layer in a two-layer network ($\hat{Y} = \sigma(X W_1) W_2$) is linear, its weights adapt much faster than the first layer. The authors model $W_2$ as instantaneously optimal for any current $W_1$ via ridge regression/pseudo-inverse: $W_2 \approx H^+ Y$, where $H = \sigma(X W_1)$.
- In the overparameterized ($d_h > n$), zero-loss limit, the effective objective for $W_1$ simplifies to: $$\mathcal{R}(W_1) = \lambda \|W_1\|_F^2 + \lambda \operatorname{Tr}\left(Y^\top (H H^\top)^{-1} Y\right)$$
- Differentiating $\mathcal{R}(W_1)$ yields an explicit closed-form gradient update for the embedding layer $W_1$ alone: $$\dot{W}_1 \approx X^\top \left( (A Y Y^\top A H) \odot \sigma'(X W_1) \right) - W_1$$ where $A = (H H^\top)^{-1}$.
Datasets
The authors evaluate their theory on synthetic algorithmic arithmetic tasks:
- Toy Linear Addition: Single-sample linear models trained on $1+1=2$ and $1+1+1=3$ to visualize 2D and 3D trajectories toward minimum-norm solutions.
- Modular Addition Modulo $p$:
- $p = 11$ ($77$ total pairs, $70$ train / $7$ test) for tracking alignment with theoretical gradient projections.
- $p = 37$ ($d_h = 512$, $70\%$ train split, $30\%$ test split) used to validate the simulated first-layer closed-form dynamics.
Key Insights and Ideas
- Grokking is a Two-Stage Process: In Stage 1, standard empirical loss minimization rapidly pulls the weights onto the zero-loss manifold $Z$. In Stage 2, the loss gradient becomes orthogonal to the manifold; weight decay then slowly navigates along $Z$ to find the minimum-norm solution.
- Alignment Peaks at Generalization: Measuring the cosine similarity between actual parameter updates and the theoretical norm-minimizing direction on the tangent space shows that the direction of training updates matches the theoretical constrained norm-minimizing direction precisely during the grokking transition (jumping from near $0$ to over $0.75$).
- Embedding Dynamics Suffice for Grokking: Simulating only the first layer's closed-form update equation (with $W_2$ computed instantaneously) reproduces both delayed generalization and the emergence of structured representations without ever running standard end-to-end backpropagation.
- Symmetric Circular Representations: Discrete Fourier transforms of the learned embedding matrix show that grokking equalizes the norms of real/imaginary Fourier components and drives them into mutually orthogonal planes—mirroring mechanistic interpretability findings of "clock" algorithms.
Key Results
- Delayed Generalization in Isolation: In modular addition ($p = 37$), simulated first-layer dynamics maintained an exact $0$ training loss throughout, stayed near random guessing accuracy ($\sim 3\%$) on the test set for the first $500$ steps, and then rapidly achieved $100\%$ test accuracy between steps $1000$ and $2000$.
- Empirical Tangent Alignment: On $p = 11$, cosine similarity between the actual training step $\Delta \theta_t$ and the projected norm-minimizing direction $\tilde{g}_t$ reached $\approx 0.75$ right as the test loss dropped toward zero.
Limitations and Future Work
- Loss Function: The theory strictly relies on mean squared error (MSE); it does not currently cover cross-entropy loss, where zero loss occurs only at infinite weight norms.
- Architecture Depth: The closed-form decoupling is derived specifically for two-layer networks where the second layer is linear. Extending this framework to deep multi-layer perceptrons or Transformers remains an open challenge.
- Vanishing Decay Limit: The proofs assume continuous gradient flow and infinitesimally small weight decay ($\lambda \to 0$), whereas practical training uses discrete learning rates and non-vanishing regularization.
Summary updated