Introduction: The Mystery of Grokking
In classical machine learning, overfitting is traditionally viewed as a dead end: once a model memorizes the noise in its training data, its ability to generalize to unseen data is compromised. However, recent observations in deep learning have revealed a counterintuitive phenomenon known as grokking. In this scenario, a model achieves near-perfect training accuracy almost immediately, yet its test accuracy remains abysmal for thousands of iterations before suddenly "clicking" and achieving excellent generalization.
While grokking has been observed across various domains—from modular arithmetic tasks to Large Language Models—the underlying mechanisms have remained elusive. Is it a mysterious property of deep, non-linear architectures, or something fundamental to optimization itself? To Grok Grokking: Provable Grokking in Ridge Regression strips away the complexity of modern neural networks to provide the first rigorous mathematical proof that grokking occurs even in the simplest of settings: over-parameterized linear regression.
Stripping Down the Complexity: The Setup
To isolate the mechanics of grokking, the authors employ a teacher-student framework using ridge regression.
The setup involves a student linear model attempting to learn a "teacher" function (a ground-truth linear relationship). Crucially, the model operates in an over-parameterized regime, where the number of parameters ($m$) vastly exceeds the number of training samples ($n$). The model is trained using standard Gradient Descent (GD) coupled with weight decay ($\ell_2$ regularization).
By focusing on this foundational machine learning setup, the researchers demonstrate that grokking does not require deep or non-linear components; it is a fundamental property of over-parameterized optimization with regularization.
The Mechanics of Grokking: A Tale of Two Subspaces
The core theoretical breakthrough of the paper relies on decomposing the model's weight vector into two distinct components:
- The Data-Spanning Subspace: The portion of the weights that directly interacts with the training data.
- The Null Space: The excess parameters that do not affect the training loss but significantly impact generalization.
The "Aha!" moment comes from realizing that optimization occurs at two vastly different speeds across these subspaces. Gradient descent minimizes the training loss extremely quickly by adjusting weights in the data-spanning subspace, leading to rapid overfitting. However, the "messy" weights in the null space—which cause the model to generalize poorly—are only constrained by weight decay. Because weight decay operates much more slowly than gradient descent's initial fitting phase, a massive delay emerges between overfitting and generalization.
Key Findings and the "Grokking Time" Formula
Through this subspace analysis, the authors mathematically prove an "end-to-end" grokking process consisting of three distinct stages:
- Early Overfitting: The model rapidly memorizes the training data.
- Persistent Poor Generalization: The model remains in an overfitted state with high test error for a prolonged period.
- Eventual Generalization: Weight decay finally shrinks the null space components, leading to a sudden drop in test error.
Furthermore, the paper provides the first quantitative bounds for the generalization delay, or "grokking time" ($t_2 - t_1$). The authors prove that grokking is not an uncontrollable anomaly but a phase transition that can be tuned. Specifically, the time to generalize is inversely proportional to the weight decay ($\lambda$) and directly proportional to the initialization scale ($\nu^2$). By decreasing weight decay or increasing the initialization scale, practitioners can artificially extend the grokking period—even making it last indefinitely.
Empirical Validation and Non-Linear Extensions
To validate their theoretical proofs, the authors conducted experiments using synthetic datasets with Gaussian features and realizable linear ground truths. The empirical results aligned with their theoretical bounds for grokking time with high precision.
More importantly, to ensure their findings hold water in more complex scenarios, the researchers extended their experiments to two-layer ReLU neural networks and Random Fourier Feature (RFF) models. Remarkably, the qualitative predictions derived from the linear model held true in these non-linear settings, reinforcing the idea that grokking is a universal consequence of specific training conditions rather than an architectural quirk.
Limitations and the Path Forward
While this paper marks a significant step forward in optimization theory, it acknowledges a few limitations:
- Realizable Setting: The current proofs focus on scenarios where a perfect linear solution exists. Extending these proofs to "agnostic" learning—where the teacher isn't perfectly linear or the data contains significant noise—remains an open challenge.
- Kernel Matrix Dependencies: Some quantitative bounds depend on the smallest positive eigenvalue of the empirical kernel matrix, which can be difficult to estimate for arbitrary, non-Gaussian data distributions.
- Beyond Regression: Although empirical evidence suggests the theory applies to neural networks, an end-to-end mathematical proof for complex architectures like Transformers or deep Convolutional Neural Networks is still the "holy grail" of this research trajectory.
Conclusion
To Grok Grokking successfully demystifies one of deep learning's most perplexing phenomena. By proving that grokking is a predictable, controllable outcome of gradient descent and weight decay in over-parameterized spaces, the authors show that it is not an inherent failure mode of deep learning. Instead, it is a natural consequence of optimization dynamics—one that requires no fundamental changes to model architectures or learning algorithms to understand and manage.
Summary updated