Table of Contents
Fetching ...

Grokking in LLM Pretraining? Monitor Memorization-to-Generalization without Test

Ziyue Li, Chenrui Fan, Tianyi Zhou

TL;DR

The paper addresses grokking in practical LLM pretraining, showing that memorization and delayed generalization occur locally across heterogeneous data groups during one-epoch pretraining of a 7B MoE model. It develops two pathway-based metrics, $D_{\mathrm{path}}$ and $C_i$, to monitor memorization-to-generalization without finetuning and demonstrates strong correlations between these metrics and downstream generalization across math, code, commonsense, and domain-specific benchmarks. The authors provide a theoretical link via a routing kernel $\Theta_{\text{route}}$ and an effective dimension $d_{\rm eff}$, arguing that a collapse of routing complexity under NTK-like assumptions drives the generalization boost after memorization. Practically, the work offers zero-cost, real-time monitoring tools for pretraining, with implications for more transparent, scalable evaluation and guidance on when and how pretraining data contribute to downstream capabilities, while outlining future work to extend these insights to dense architectures.

Abstract

This paper presents the first study of grokking in practical LLM pretraining. Specifically, we investigate when an LLM memorizes the training data, when its generalization on downstream tasks starts to improve, and what happens if there is a lag between the two. Unlike existing works studying when a small model generalizes to limited and specified tasks during thousands epochs' training on algorithmic data, we focus on a practical setting for LLMs, i.e., one-epoch pretraining of next-token prediction on a cross-domain, large-scale corpus, and generalization on diverse benchmark tasks covering math/commonsense reasoning, code generation, and domain-specific retrieval. Our study, for the first time, verifies that grokking still emerges in pretraining mixture-of-experts (MoE) LLMs, though different local data groups may enter their grokking stages asynchronously due to the heterogeneity of their distributions and attributions to others. To find a mechanistic interpretation of this local grokking, we investigate the dynamics of training data's pathways (i.e., expert choices across layers in MoE). Our primary discovery is that the pathways evolve from random, non-smooth across layers, instance-specific to more structured and transferable across samples, despite the converged pretraining loss. This depicts a transition from memorization to generalization. Two novel metrics are developed to quantify these patterns: one computes the pathway similarity between samples, while the other measures the consistency of aggregated experts between subsequent layers for each sample. These training data based metrics induce zero cost but can faithfully track and monitor the generalization of LLMs on downstream tasks, which, in conventional settings, requires costly instruction tuning and benchmark evaluation.

Grokking in LLM Pretraining? Monitor Memorization-to-Generalization without Test

TL;DR

The paper addresses grokking in practical LLM pretraining, showing that memorization and delayed generalization occur locally across heterogeneous data groups during one-epoch pretraining of a 7B MoE model. It develops two pathway-based metrics, and , to monitor memorization-to-generalization without finetuning and demonstrates strong correlations between these metrics and downstream generalization across math, code, commonsense, and domain-specific benchmarks. The authors provide a theoretical link via a routing kernel and an effective dimension , arguing that a collapse of routing complexity under NTK-like assumptions drives the generalization boost after memorization. Practically, the work offers zero-cost, real-time monitoring tools for pretraining, with implications for more transparent, scalable evaluation and guidance on when and how pretraining data contribute to downstream capabilities, while outlining future work to extend these insights to dense architectures.

Abstract

This paper presents the first study of grokking in practical LLM pretraining. Specifically, we investigate when an LLM memorizes the training data, when its generalization on downstream tasks starts to improve, and what happens if there is a lag between the two. Unlike existing works studying when a small model generalizes to limited and specified tasks during thousands epochs' training on algorithmic data, we focus on a practical setting for LLMs, i.e., one-epoch pretraining of next-token prediction on a cross-domain, large-scale corpus, and generalization on diverse benchmark tasks covering math/commonsense reasoning, code generation, and domain-specific retrieval. Our study, for the first time, verifies that grokking still emerges in pretraining mixture-of-experts (MoE) LLMs, though different local data groups may enter their grokking stages asynchronously due to the heterogeneity of their distributions and attributions to others. To find a mechanistic interpretation of this local grokking, we investigate the dynamics of training data's pathways (i.e., expert choices across layers in MoE). Our primary discovery is that the pathways evolve from random, non-smooth across layers, instance-specific to more structured and transferable across samples, despite the converged pretraining loss. This depicts a transition from memorization to generalization. Two novel metrics are developed to quantify these patterns: one computes the pathway similarity between samples, while the other measures the consistency of aggregated experts between subsequent layers for each sample. These training data based metrics induce zero cost but can faithfully track and monitor the generalization of LLMs on downstream tasks, which, in conventional settings, requires costly instruction tuning and benchmark evaluation.

Paper Structure

This paper contains 22 sections, 2 theorems, 12 equations, 8 figures, 3 tables.

Key Result

Theorem 4.1

Under NTK regime with $K$ experts, with probability $1-\delta$ over $n$ samples, where $C_1, C_2$ are NTK-dependent constants and $\lambda$ is the regularization parameter:

Figures (8)

  • Figure 1: Memorized training samples at different pretraining steps and the generalization performance on standard benchmarks for each domain. It shows asynchronous memorization of different data in each domain and a delayed generalization leap after memorizing a certain amount of data.
  • Figure 2: Pretraining objective (blue) and benchmark performance (red) across four paired training-test data groups from the math domain. We observe local grokking on each pair: a delayed generalization leap on benchmark tasks after the pretraining objective plateaued. From left to right, more difficult data memorized (converged) later associate with a longer delay towards grokking.
  • Figure 3: Pathway Complexity Metrics to Monitor Grokking. (a) Pathway similarity between samples is measured by edit distance on their sequences of expert choices across layers. (b) Pathway consistency quantifies the smoothness of expert transitions between subsequent layers for the same sample by cosine similarity of their weighted expert embeddings.
  • Figure 4: Pathway edit distance and pretraining objective of two data groups (memorized at $125k$ and $245k$ steps) during pretraining across four domains. The global panel (leftmost) fits the overall quadratic trend over all domains, while domain panels fit separate trends after the corresponding convergence step. Despite early training objective plateauing, pathway edit distance continues to decline, indicating a declining complexity of internal memorization.
  • Figure 5: Layer-wise evolution of pathway edit distance during pretraining for the data group memorized at $245k$ step. Overall distance decreases from early to later layers, indicating higher complexity in early layers. After pretraining objective convergence, early-layer routing among similar samples simplifies quickly, later layers adapt more gradually, and the final layer diversifies after memorization.
  • ...and 3 more figures

Theorems & Definitions (3)

  • Theorem 4.1: Generalization Bound
  • Theorem C.1: Generalization Bound for MoE Experts
  • proof