To Grok Grokking: Provable Grokking in Ridge Regression

Mingyue Xu, Gal Vardi, Itay Safran · DOI

Abstract

We study grokking, the onset of generalization long after overfitting, in a classical ridge regression setting. We prove end-to-end grokking results for learning over-parameterized linear regression models using gradient descent with weight decay. Specifically, we prove that the following stages occur: (i) the model overfits the training data early during training; (ii) poor generalization persists long after overfitting has manifested; and (iii) the generalization error eventually becomes arbitrarily small. Moreover, we show, both theoretically and empirically, that grokking can be amplified or eliminated in a principled manner through proper hyperparameter tuning. To the best of our knowledge, these are the first rigorous quantitative bounds on the generalization delay (which we refer to as the "grokking time") in terms of training hyperparameters. Lastly, going beyond the linear setting, we empirically demonstrate that our quantitative bounds also capture the behavior of grokking on non-linear neural networks. Our results suggest that grokking is not an inherent failure mode of deep learning, but rather a consequence of specific training conditions, and thus does not require fundamental changes to the model architecture or learning algorithm to avoid.

Introduction

Since its discovery in 2022, "grokking" has fascinated researchers because it defies classical intuition: why would a model that has already achieved 100% training accuracy suddenly start improving its test performance thousands of iterations later? Most existing theories attribute this to complex "phase transitions" in neural networks or specific algorithmic tasks like modular addition. However, these theories often lack rigorous mathematical guarantees or are too specific to be generalized. This paper addresses the gap by asking: Can grokking be explained and proven in the most fundamental setting of statistical learning—linear ridge regression? The authors aim to move grokking from a "mysterious deep learning quirk" to a "provable statistical phenomenon" with predictable hyperparameters.

Theoretical Framework

The authors study an over-parameterized linear regression problem using a teacher-student framework. A student linear model is trained using Gradient Descent (GD) with $L_2$ regularization (weight decay $\lambda$). The model is over-parameterized, meaning the number of features ($m$) is much larger than the number of training samples ($n$).

The core insight is a decomposition of the student's weight vector into two orthogonal components:

  1. The Data-Spanning Subspace ($\theta_\parallel$): The part of the weights that aligns with the training data.
  2. The Null Subspace ($\theta_\perp$): The part of the weights orthogonal to the training data, which contains the "noise" from random initialization.

GD fits the data-spanning subspace very quickly (leading to early overfitting), but the weight decay only slowly "washes away" the initialization noise in the null subspace. Generalization only happens once this noise is sufficiently suppressed.

The Grokking Phenomenon

The paper mathematically proves that grokking is a "subspace race." Overfitting is fast because the model only needs to move a small number of weights to fit $n$ points. Generalization is slow because the model must wait for weight decay to shrink the $m-n$ "useless" dimensions of the initialization.

Grokking in ridge regression: training loss drops quickly while test loss remains high before eventually decreasing.

As shown in Figure 1, the authors prove three distinct stages: (i) rapid overfitting, (ii) persistent poor generalization, and (iii) eventual generalization. This confirms that grokking is not an inherent failure of deep architectures but a natural result of training over-parameterized models under specific conditions.

Quantitative Scaling Laws and Empirical Validation

A key contribution of this work is the derivation of explicit quantitative bounds for the "grokking time" ($t_2 - t_1$). The authors show that the time to generalize ($t_2$) is inversely proportional to the weight decay ($\lambda$). If $\lambda$ is very small, the grokking period becomes arbitrarily long.

Dependence of overfitting time ($t_1$) and generalization time ($t_2$) on hyperparameters $\lambda, n, m, \nu^2$.

Figure 4 illustrates these dependencies. Key findings include:

  • Weight Decay ($\lambda$): Grokking time scales as $\approx 1/\lambda$.
  • Initialization Scale ($\nu^2$): Increasing the scale of initial weights increases both $t_1$ and $t_2$ at a logarithmic rate, stretching the grokking period.
  • Sample Size ($n$): Decreasing $n$ speeds up initial overfitting ($t_1$), which amplifies the grokking effect by widening the gap between overfitting and generalization.

To verify these findings beyond the linear setting, the authors tested two-layer ReLU neural networks. Their theoretical bounds showed a striking qualitative and quantitative match with empirical observations in these non-linear networks, suggesting the linear theory captures the essence of the phenomenon.

Discussion and Future Work

While this work provides a rigorous foundation for grokking, several open questions remain. The current proof assumes a "realizable" case where the teacher's function exists within the student's hypothesis space. In "agnostic" settings with noise, small weight decay might prevent generalization entirely. Additionally, reconciling this weight-decay-driven explanation with theories focused on the transition from "lazy" to "rich" regimes is a major future direction. Finally, extending these bounds to models where the feature map itself evolves during training (feature learning) remains a challenge.

Summary updated

BibTeX
@inproceedings{xu2026grok,
  author = {Mingyue Xu and Gal Vardi and Itay Safran},
  title = {{To Grok Grokking: Provable Grokking in Ridge Regression}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=5nNNVY8NW4},
}
Figure