NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Explaining grokking through circuit efficiency

Vikrant Varma, Rohin Shah, Zachary Kenton, János Kramár, Ramana Kumar

Abstract

Grokking—the sudden transition from memorization to generalization in neural networks—has remained a puzzle since its discovery. We propose that this phenomenon is driven by a competition for "circuit efficiency" under the pressure of weight decay. Generalizing circuits, while slower to learn, are more parameter-efficient than memorizing circuits, allowing them eventually to dominate. This framework not only explains standard grokking but also predicts two novel behaviors: ungrokking and semi-grokking.

Introduction: The Puzzle of Delayed Generalization

In classical machine learning, a model that reaches near-zero training loss is expected to have finished its learning process. Grokking defies this expectation: a model may achieve 100% training accuracy but 0% test accuracy for thousands of epochs, only to suddenly "click" and achieve perfect generalization much later.

Standard grokking behavior where test accuracy (dashed line) remains near zero long after training loss has flatlined, before suddenly jumping to 100%.

We investigate the "why" behind this dramatic transition, moving beyond simple representation learning to a theory of internal circuit competition.

The Theory of Circuit Efficiency

We hypothesize that neural networks develop two distinct types of internal mechanisms:

  1. Memorizing Circuits ($C_{mem}$): These learn training data by heart. Their efficiency decreases as the dataset grows because they require more parameters to store more points.
  2. Generalizing Circuits ($C_{gen}$): These learn the underlying logic (e.g., modular addition). Their efficiency is independent of dataset size.

We define efficiency as the ability of a circuit to produce large model outputs (logits) using a small parameter norm. Weight decay acts as a "budget enforcer," favoring the more efficient circuit. Grokking occurs when the generalizing circuit eventually becomes more efficient than the memorizing one, typically at a critical dataset size ($D_{crit}$).

Key Results and Novel Phenomena

Our theory was validated using 1-layer Transformer models on modular arithmetic tasks. By manipulating dataset size and training duration, we confirmed the existence of three distinct regimes.

Grokking, Ungrokking, and Semi-grokking

Our most striking findings are the confirmation of two novel behaviors predicted by the efficiency theory:

  • Ungrokking: When a grokked model is continued on a significantly smaller dataset ($D < D_{crit}$), it regresses from perfect to low test accuracy as the network reverts to a now-more-efficient memorization strategy.
  • Semi-grokking: At dataset sizes very close to $D_{crit}$, the two circuits reach an equilibrium, resulting in stable, partial test accuracy (e.g., 80%) that persists for millions of epochs.
Comparison of training dynamics across different regimes. Standard grokking (left) shows delayed generalization. Ungrokking (middle) shows a regression to memorization. Semi-grokking (right) demonstrates stable partial generalization.

Our empirical results confirm these phase transitions. As shown in the comparison above, the network can shift between perfect generalization and memorization depending on the dataset size and training duration.

Conclusion

The circuit efficiency framework provides a unified explanation for the phase transitions observed in neural network training. By viewing generalization as a competition for parameter efficiency, we can predict and observe complex behaviors like ungrokking and semi-grokking. This perspective suggests that the "simplicity bias" of neural networks is deeply tied to the relative parameter costs of different algorithmic solutions.

Summary updated

BibTeX
@misc{varma2023explaining,
  author = {Vikrant Varma and Rohin Shah and Zachary Kenton and János Kramár and Ramana Kumar},
  title = {{Explaining grokking through circuit efficiency}},
  year = {2023},
  eprint = {2309.02390},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2309.02390},
}
Figure