Abstract
The grokking phenomenon refers to a regime where a long period of overfitting is followed by a seemingly sudden transition to perfect generalization. In this paper, we attempt to reveal the underpinnings of Grokking via a series of empirical studies. Specifically, we uncover an optimization anomaly plaguing adaptive optimizers at extremely late stages of training, referred to as the Slingshot Mechanism. A prominent artifact of the Slingshot Mechanism can be measured by the cyclic phase transitions between stable and unstable training regimes, and can be easily monitored by the cyclic behavior of the norm of the last layers weights. We empirically observe that without explicit regularization, Grokking almost exclusively happens at the onset of Slingshots, and is absent without it. Our work points to a surprising and useful inductive bias of adaptive gradient optimizers at late stages of training, calling for a revised theoretical analysis of their origin.
Introduction
In 2022, researchers discovered Grokking: a phenomenon where a neural network, after long periods of overfitting (100% training accuracy but 0% validation accuracy), suddenly achieves perfect generalization. While fascinating, the underlying mechanics remained a mystery. Most optimization theories assume training should be stable and gradients should diminish over time. Grokking defies this, occurring long after the model has seemingly "finished" learning the training set. This study identifies the specific optimization anomaly—the Slingshot Mechanism—that serves as the mechanical engine behind these sudden leaps in generalization.
The Slingshot Mechanism
By monitoring the Terminal Phase of Training (TPT)—the period after the model reaches perfect training accuracy—we identified a recurring cyclic behavior in adaptive optimizers like Adam and RMSProp. This cycle consists of three distinct phases:
- Norm Growth: Driven by the pressure of cross-entropy loss, the $L_2$ norm of the last layer's weights grows rapidly.
- Loss Spike (The Slingshot): Eventually, the weights enter a region of high curvature (sharpness). This triggers a massive, sudden spike in training loss.
- Norm Plateau: The spike "flings" the weights into a new region of the parameter space where the norm stabilizes and the loss recovers.
Empirical Evidence and Grokking
Our experiments across algorithmic datasets (modular arithmetic), vision benchmarks (CIFAR-10 with ViTs), and synthetic data reveal a consistent pattern: the "aha moment" of generalization almost exclusively occurs at the onset of these Slingshots. The instability is not a failure of the optimizer but a catalyst that forces the network to abandon overfitted solutions and find more generalizable features.
Key Findings
- No Slingshot, No Grokking: In every instance where Grokking occurred, it was preceded by a Slingshot. When Slingshots were suppressed, Grokking disappeared.
- The $\epsilon$ Parameter: The $\epsilon$ (epsilon) parameter in Adam, typically treated as a minor stability constant, acts as a "Grokking switch." Increasing $\epsilon$ stabilizes the optimizer, preventing Slingshots and, consequently, preventing Grokking.
- Optimizer Specificity: The Slingshot Mechanism is a unique inductive bias of adaptive optimizers. Standard Stochastic Gradient Descent (SGD) does not exhibit this cyclic instability and failed to grok in our experiments.
- Late-Stage Feature Adaptation: Internal representations remain largely static during the stable norm growth phase but undergo rapid, beneficial adaptation immediately following a Slingshot loss spike.
Conclusion
The Slingshot Mechanism suggests that late-stage training instability is a critical component of generalization in deep learning. While computationally expensive, these cycles allow models to escape local minima in favor of more robust solutions. Future work should focus on developing formal theories for this mechanism and exploring ways to harness this inductive bias more efficiently without requiring hundreds of thousands of extra training steps.
Summary updated