Abstract
Grokking—the phenomenon where a model suddenly generalizes after a prolonged period of overfitting—is widely believed to be driven by regularization techniques such as weight decay. This paper challenges that view, proposing that grokking is often hindered by "Softmax Collapse," a numerical failure where floating-point errors lead to vanishing gradients. By introducing a numerically stable activation function, StableMax, and a novel optimizer, ⊥Grad, we demonstrate that models can grok without any regularization or even skip the overfitting phase entirely. Our findings suggest that the characteristic delay in grokking is an artifact of numerical instability rather than an inherent requirement for generalization.
1. Introduction
In the study of deep learning dynamics, "grokking" refers to a transition where a model, having already achieved near-zero training loss and high validation error, suddenly "clicks" into a state of perfect generalization. Traditionally, this behavior is observed in algorithmic tasks, such as modular addition, and is thought to require specific regularization to push the model toward simpler, more generalizable representations.
This paper investigates the hypothesis that numerical precision, rather than just structural bias, is a primary gatekeeper for grokking. We argue that without regularization, models attempt to minimize loss by indefinitely scaling weight magnitudes to increase logit values. This process eventually triggers floating-point "absorption" errors, causing gradients to vanish and trapping the model in an overfit state.
2. The Problem: Softmax Collapse and Naïve Loss Minimization
The authors identify two primary obstacles to generalization:
2.1 Softmax Collapse (SC)
Standard Softmax utilizes the exponential function ($e^x$), which grows rapidly. When one logit significantly exceeds others, the denominator in the Softmax function becomes dominated by the largest term. In finite-precision floating-point arithmetic, smaller terms are "absorbed" (effectively treated as zero), leading to a gradient of zero. This "Softmax Collapse" prevents the model from further refining its internal logic.
2.2 Naïve Loss Minimization (NLM)
NLM occurs when a model reduces loss simply by increasing the magnitude of its weights without changing the direction of the weight vector. This increases the confidence of the current (potentially incorrect) predictions but does not improve the underlying representation. This scaling behavior is what eventually leads to Softmax Collapse.
3. Proposed Methods
To mitigate these issues, the authors propose two interventions:
3.1 StableMax
StableMax replaces the standard exponential activation with a function that scales linearly for positive values and approaches zero more gradually for negative values. This design ensures that smaller logits continue to contribute to the gradient, even when other logits are large, thereby preventing the numerical "death" of the learning process.
3.2 ⊥Grad (Ortho-Grad)
The ⊥Grad optimizer is designed to combat NLM. It works by projecting the calculated gradient onto a hyperplane orthogonal to the current weight vector. By removing the component of the gradient that merely scales the weights, ⊥Grad forces the optimizer to update the direction of the weights. This compels the model to find new logical features rather than simply increasing the magnitude of existing ones.
4. Experimental Evaluation
The methods were tested across a range of benchmarks:
- Algorithmic Tasks: Modular arithmetic (addition, subtraction, multiplication mod 113) and Sparse Parity.
- Computer Vision: MNIST, and ResNet-18 on CIFAR-10, CIFAR-100, and ImageNet-1k.
- Natural Language Processing: GPT-2 Small on WikiText-103.
5. Key Results
5.1 Grokking Without Regularization
Using StableMax, the authors successfully induced grokking on modular addition tasks that previously failed to generalize without weight decay. This suggests that weight decay's primary utility in these tasks may be its role as a "numerical hack" to prevent weights from reaching the threshold of Softmax Collapse.
5.2 Instant Generalization
The most striking result involves the use of ⊥Grad. While standard AdamW with weight decay might require over 50,000 epochs to reach the "click" point, ⊥Grad achieved 100% test accuracy in fewer than 400 iterations. By blocking the model's ability to waste time on NLM, the optimizer forces immediate structural learning.
5.3 Scaling to Realistic Tasks
The benefits of these methods extend beyond toy tasks. In ResNet-18 training on CIFAR-100, ⊥Grad improved accuracy from 59.98% to 62.69%. In GPT-2 experiments, StableMax and ⊥Grad maintained or slightly improved performance compared to standard baselines, indicating that these interventions are compatible with modern architectures and large-scale datasets.
6. Discussion and Limitations
The research highlights that the "delay" in grokking is largely optional. However, the authors note that their theoretical analysis of NLM is most robust for homogeneous models (e.g., ReLUs without biases). While empirical results show success in non-homogeneous models like Transformers (which use LayerNorm and biases), the formal link in those architectures remains an area for future study. Furthermore, the exact mechanics of the "suddenness" of generalization—the phase transition itself—warrants deeper investigation into how numerical stability interacts with effective learning rates.
7. Conclusion
By reframing grokking as a challenge of numerical stability rather than just regularization, this work provides a new lens through which to view model optimization. StableMax and ⊥Grad offer practical tools to avoid the pitfalls of Softmax Collapse and Naïve Loss Minimization, potentially leading to more efficient and robust training regimes across a variety of deep learning applications.
Summary updated