TL;DR
Grokking—the sudden, delayed generalization of a model long after achieving perfect training accuracy—is widely seen as a unique quirk of neural networks and gradient descent. This paper turns that assumption on its head by demonstrating that kernel machines can also grok modular arithmetic. The authors show that grokking is driven entirely by the gradual learning of structured, block-circulant features, a process captured by the Average Gradient Outer Product (AGOP).
What Problem Does This Paper Address?
Grokking and "emergence" are major talking points in modern machine learning, often described as sudden phase transitions where a model abruptly "clicks" and learns a skill. However, the underlying mechanics remain heavily contested. Some researchers argue that emergence is a "mirage" caused by analyzing discontinuous metrics like accuracy rather than continuous loss. Others believe grokking is inherently tied to deep learning phenomena, such as representation learning via stochastic gradient descent (SGD) or weight decay dynamics.
The authors of this paper investigate a fundamental question: Is grokking unique to neural networks and gradient-based optimization? By decoupling feature learning from neural architectures, they test whether simpler, non-neural models can exhibit the same sudden leaps in generalization.
Methods
The authors employ Recursive Feature Machines (RFM), an iterative algorithm designed to enable feature learning in kernel machines (which natively lack a mechanism to alter their representations).
RFM works by alternating between three steps:
- Training a standard kernel machine (using quadratic or Gaussian kernels) to fit the training data.
- Computing the Average Gradient Outer Product (AGOP) matrix over the data to identify the most task-relevant feature directions.
- Transforming the input data using this learned feature matrix.
Crucially, because RFM solves kernel ridgeless regression exactly at each step, the training loss is identically zero from the very first iteration.
To peek under the hood during training, the authors introduce two "hidden progress measures":
- Circulant deviation: A metric quantifying how close a feature matrix is to having constant diagonals (a circulant structure).
- AGOP alignment: The cosine similarity between the feature matrix at iteration $t$ and the final matrix of a fully trained model.
Datasets
The paper evaluates these methods on synthetic modular arithmetic tasks—specifically addition, subtraction, multiplication, and division—using prime moduli (such as $p = 59, 61,$ and $97$). The inputs are formatted using standard one-hot encodings of integer pairs concatenated together (e.g., $e_a \oplus e_b$).
Key Insights and Ideas
- Grokking is Not Neural: RFM exhibits classic grokking behavior, sharply transitioning from random guessing to 100% test accuracy. Because this happens in a kernel machine with zero training loss throughout, grokking cannot be blamed on SGD optimization paths or neural-specific regularization.
- The Secret is Block-Circulant Features: To solve modular arithmetic, both RFM and neural networks naturally learn feature matrices with a "block-circulant" (striped) structure.
- The Discrete Logarithm Trick: For multiplication and division, the block-circulant structure is initially invisible. It only reveals itself when the rows and columns are reordered using the discrete logarithm—mathematically transforming the multiplication problem into an addition problem (see Figure 6).
- Grokking is Not a Mirage: Even though standard metrics like test loss and test accuracy look completely flat before the model "groks" the task, the hidden progress measures improve linearly from day one. The sudden phase transition in accuracy is just the visible threshold of a steady, continuous feature-learning process (see Figure 2).
Key Results
- Sharp Transitions: On a modular addition task ($mod\ 59$), RFM maintains near-zero test accuracy for the first 10 iterations before abruptly climbing to 100% accuracy by iteration 15 (see Figure 1).
- Bypassing Grokking Entirely: When the authors bypassed RFM training and simply initialized standard kernel machines with random block-circulant features, the models generalized perfectly without needing any iterations.
- Algorithmic Convergence: The authors mathematically prove that kernel machines utilizing these block-circulant features implicitly implement the Fourier Multiplication Algorithm (FMA). This matches prior mechanistic interpretability work showing that neural networks learn the FMA to solve modular math.
Limitations and Future Work
- Model Size Constraints: Kernel machines can be viewed mathematically as infinite-width neural networks. As a result, this framework cannot be used to analyze how model size parameters (like width or depth thresholds) impact emergence.
- Task-Specific Progress Measures: While AGOP alignment is a general metric, circulant deviation relies entirely on knowing the mathematical symmetries of modular arithmetic beforehand. Developing task-agnostic progress measures that can detect hidden feature structures in more complex domains (like natural language) remains an open challenge.
Summary updated