We usually treat memorization and reasoning as two separate problems. We use TriviaQA to benchmark factual recall and math like GSM8K to measure reasoning. Next, we assume that scaling up parameters buys you more of both.
Does it, though?
Measuring memorization and reasoning on different datasets can't tell you how they fight inside the same network on the same samples1. given that you know how to measure those 🙂. What happens when you turn up memorization pressure in the data? Do extra parameters contribute to memorization only? How reasoning ability is preserved?
That is the question I explored in my Master's thesis at EPFL. I built a synthetic graph dataset where memorization pressure is a controllable dial, set up rigorous information-theoretic metrics for both quantities, and tested three architecture families: Dense transformers, sparse Mixture-of-Experts, and looped (latent-reasoning) models.2. Morris et al. put the raw memorization ceiling at ~3.6 bits/param
All three architectures behave almost identically. Right up until they don't.
A dataset with memorization dial#
To measure memorization and generalization cleanly, you need the true data distribution 3. Intuitively, if we have a true data distribution , we can strictly measure magnitude of random noise in a sample memorized by a model. Natural language doesn't have one. Using something like another LLM as an oracle makes the measurements depend on that oracle's architecture and training set. This makes all conclusions conditioned on "what if estimate is wrong?"
So I went synthetic, while keeping the pieces that make language modeling hard. Every sample is split into two parts: a graph definition (Erdős–Rényi4. Connects each pair of vertices independently with probability . Here , scaled inversely with the mean vertex count (28) to keep graphs connected yet sparse., randomized 2-letter vertex names, either adjacency-list or edge-list encoding) followed by 10 queries and answers over that graph (Figure 1). What is good about this dataset is that we can calculate generating distribution exactly.

Here is what a real sequence from the generator looks like next to the 10-vertex graph it describes (whitespace is added only for readability):
— graph definition — <bos> <def_adj_erdos_renyi> v j d t l m p u y i k l e w l l b h c w <edges> e w b h l m p u <edges> y i l m <edges> k l b h c w <edges> b h l m y i <edges> v j e w <edges> c w p u <edges> p u k l <edges> d t l m p u d t <edges> l m l m <edges> l l e w p u k l — tasks — <query_shortest_path> y i l m <answer> l m <query_bfs> 1 l m <answer> <query_dfs> e w <answer> p u k l c w b h y i l m <query_bfs> 1 p u <answer> c w b h y i l m <query_bfs> 1 c w <answer> k l b h l m y i <query_bfs> 2 p u <answer> y i l m <query_random_walk> l m <answer> <query_bfs> 2 e w <answer> c w <query_shortest_path_len> y i e w <answer> <query_bfs> 0 c w <answer> p u k l b h l m y i <bos>
The 10-vertex directed graph encoded on the left (including two self-loops)
Each sample mixes five tasks: BFS (with configurable hop-skipping), DFS, random walk, shortest path, and shortest-path length. 5. I sample 10–100 vertices (power-law distribution, mean 28) -> ~955 tokens on average, 5.2k at p99. Mixing multiple tasks isn't just for realism. When I trained a small Llama-style transformer with standard CE loss on single task only, runs became wildly sensitive to initialization. Different seeds hit loss cliffs at different steps and converged to completely different losses, likely because some seeds randomly discovered brittle syntax circuits without learning graphs at all. Adding the other four tasks fixed it (Figure 2).


Figure 2. Single-task vs. multi-task seed stability. Training loss across random seeds for BFS-only training (left) vs. the 5-task mixture (right). Varying the task itself eliminates seed-dependent loss cliffs.
Training setup & hyperparameters
- Backbone: Llama-2-style decoder-only transformers (SwiGLU, RoPE, RMSNorm, tied embeddings), character-level tokenizer (vocab padded to 64).
- Optimization: Adam (β₁ = 0.9, β₂ = 0.95), decoupled weight decay 0.01, peak LR 10⁻⁴ with Warmup-Stable-Decay (300 warmup steps), grad clip 5.0, bf16.
- Budget: 4M samples (~192M tokens) per run; batches of 200 full untruncated samples (~195K tokens), trained with Optimus-DL.
- Scale: ~10M to 425M parameters for Dense models (up to ~1B total parameters for MoE), corresponding to roughly 10¹⁶ to 10¹⁸ training FLOPs per run.
The dial: permutations count#
As described so far, every training sample is a brand-new random graph, so there is nothing to memorize. To control memorization pressure, I added one knob: permutations count. That is a training data parameter, when set to 5, each underlying graph topology appears in 5 training samples (so 20% of training graphs are unique). Still, each time fresh encoding order, queries, and answers are sampled. In language terms, it is rephrasing the same information: the underlying structure repeats, the exact token sequence never does.
Crucially, every permutation is equally likely under , so turning this dial introduces no global distribution shift between train and eval. Still, it introduces a coverage shift, because the training set spans fewer unique graphs. 6. All permutations have the exact same probability under , so expected train entropy matches true entropy; only its variance grows as unique graphs shrink.
Memorization and generalization collide#
With an exact oracle in hand, we can measure memorization and generalization on the exact same sequences.
For memorization, I adopt the Kolmogorov unintended memorization metric of Morris et al. (2025). For a training sample and trained model , let be the sample's negative log-likelihood under the true generator and under the model. Per-sample unintended memorization is:
The intuition is simple: is the best code length any model could achieve knowing only the true distribution. If your trained model compresses below that floor, it must have memorized specifics of . Averaging over the training set gives our dataset memorization metric .
For generalization, I use sequence-level KL divergence on held-out graphs, decomposed autoregressively token by token:
Because each sample has two cleanly separated halves, summing this KL only over the graph-definition tokens gives a Graph Encoding metric, and summing it only over the query-and-answer tokens gives a Reasoning (task-level KL) metric. 7. Plots rescale KL to 0–100 via : 100 = oracle, 0 = random guessing. This way, KL is more interpretable.
These two quantities are algebraically coupled. Define per-sample underfitting symmetrically to memorization as . Writing empirical risk as and expanding KL as true risk minus data entropy gives an exact accounting identity:
where is the standard train–test generalization gap and is the sample entropy shift (zero in expectation under our dial). Because KL is non-negative, this yields an immediate upper bound in expectation: . 8. Basically bias–variance per sample: is bias, is variance, is explicit overfitting.
That sets up the real question for the experiments: when memorization pressure forces up, do different architectures pay that bill in the same place, or does architecture decide whether memorization eats graph encoding or breaks reasoning?
Models memorize graph topology#
Before running architecture comparisons, I wanted to check a basic question: when we repeat topologies, do models memorize syntax, or the actual graph?
To test this, I pushed the setup to its harshest variant. Let every permutation also re-randomize all vertex names, so two samples of the same graph share zero token-level cues. Even then, memorization on the graph-definition tokens still grows cleanly with permutation count and model size, while memorization on the query tokens barely moves (Figure 3). The models aren't memorizing only token strings—they are memorizing abstract topology too.

Width vs depth barely changes anything#
Common intuition says wide, shallow transformers memorize more than deep, narrow ones. To test that, I swept dense models across four width-to-depth ratios (): deep (~51), balanced (~90), wide (~183), and extra-wide (>500), from 10 to 250 permutations.
The intuition didn't hold up. In generalization–memorization coordinates, every dense shape lands in roughly the same region at every permutation count (Figure 4). Width vs. depth barely moves the needle; the dataset's memorization pressure dominates. 9. This was kind of expected as the whole area of scaling laws is based on parameters count and not on specific architecture

Splitting total KL into its two halves shows where the generalization penalty actually goes (Figure 5). Up through 100 permutations, almost all of the drop happens on the stochastic graph-encoding tokens, while reasoning keeps improving with scale. Only at the extreme 250-permutation regime does memorization finally spill over into reasoning, causing every dense configuration to fluctuate and crack.

MoE turns parameters into memory and then fails on reasoning#
If dense shape doesn't change the trade-off, what about changing how parameters are allocated? Sparse Mixture-of-Experts lets you scale total parameters while keeping active parameters fixed. Jelassi et al. (2025) showed on separate benchmarks that MoE total parameters drive memorization while active parameters constrain reasoning. I built DeepSeek-V3-style MoE blocks to see how both interact on the same data. 10. 1 shared expert + top-k sigmoid routing, aux-loss-free balancing. Matched by active params, train loss matches Dense.
Just as expected, unintended memorization scales cleanly with total parameter count regardless of sparsity level, until it hits the dataset's memorization ceiling (the finite entropy of the unique training graphs at that permutation count; Figure 6).

Global generalization initially follows active parameters too, matching the dense baseline at low permutation counts.
At identical active-parameter budgets, dense models keep solving tasks through 100 permutations and only degrade at 250. MoE starts losing reasoning at 100 permutations and collapses completely at 250. Reasoning (task-level) KL blows up to ~2217 versus ~198 for the matched dense model (lower KL means higher Reasoning score; Figure 7). MoE's extra parameters make it so efficient at memorizing training topologies that it actively destroys the algorithms needed to reason over unseen ones.

Muon pushes MoE deeper into the trap#
Ok, maybe Adam is just under-optimizing the sparse routing. What happens if we swap in a stronger optimizer?
I re-ran the 16%-active MoE with Muon, an orthogonalized-momentum optimizer that converges faster than Adam on matrix weights. As expected, Muon drives training loss noticeably lower than Adam (1.29 vs. 1.54 at 50 permutations).
Reasoning gets worse.
Average task-level KL jumps from 364 (Adam) to 598 (Muon), while unintended memorization ticks up along the same trade-off curve (Figure 8). Better optimization doesn't rescue MoE—it just pushes it into the memorization trap faster. Lower training loss is not the same thing as a better model.


Figure 8. Muon vs. Adam on 16%-active MoE. Left: lower training loss translates directly into higher unintended memorization. Right: both sit on the same trade-off curve, with Muon pushed deeper into memorization.
Recurrence shields reasoning#
So far the picture is sad: dense shape doesn't help, MoE makes it worse, and stronger optimization accelerates the collapse. Both Dense and MoE entangle two things: adding compute depth also adds parameters, and extra parameters expand the memorization budget.
What if you scale compute depth without adding parameters?
To test that, I used Parcae, a Llama-style looped (recurrent-depth) transformer built for stable training at scale. A prelude of unique blocks projects tokens into a latent state, a shared block loops for iterations, and a coda reads the result out. To stop hidden states from exploding across iterations, Parcae uses a state-space-style Zero-Order-Hold update with learned per-channel decay : 11. Loop counts are Poisson-sampled per sequence during training, with BPTT truncated to the last half.
Here is the recurrent block's output at step , and are learned per-channel step-size and decay parameters. Training loss drops cleanly as you increase either parameter count or loop depth, confirming that extra loops are real compute.
First check: does looping increase memorization?
Barely. Across permutation counts, unintended memorization is dictated almost entirely by total parameter count, not recurrence depth (Figure 9). Adding loops gives only a small bump at low permutations, which is likely because deeper compute helps the model parse the graph structure, while global generalization stays on the same universal curve as Dense and MoE.

Now the obvious objection: "Isn't Parcae just getting more FLOPs per token?" To rule out that, I matched Parcae against deep Dense models by effective depth. For a model with unique layers (split evenly into prelude, looped core, and coda), effective depth is . Same effective depth, same compute per token. At 250 permutations, the depth-matched Dense model still collapses, while Parcae holds steady (Figure 10).

Looked at by parameter count, the separation is notable (Figure 11). Even at 250 permutations—where MoE is completely broken (task-level KL ≈ 2217) and Dense is degrading (≈ 198)—an 8-recurrence Parcae model holds task-level KL at ≈ 107. It memorizes the training topologies just as hard as the others, yet memorizing doesn't corrupt its learned algorithms.

One more bonus: latent compute extrapolates cleanly at inference time. Taking a Parcae model trained at mean recurrence 16 and evaluating it from 1 to 24 loops (1.5× its mean training horizon), reasoning fails only if you starve it at 1–3 steps, stabilizes around 5–7 steps, and then stays completely flat out to 24 loops (KL ≈ 104 at 250 permutations, Figure 12). Extra test-time loops don't destabilize the algorithm.

All in all#
Putting all three families on the same canvas answers the opening question (Figure 13 and the summary table below). Every architecture starts on the exact same global memorization–generalization trade-off curve. Where they diverge is who breaks when memorization pressure climbs: MoE snaps at 100 permutations, Dense holds until 250, and Parcae refuses to collapse at all.

| Model @ 250 permutations | Task-level KL (lower = better) | Outcome |
|---|---|---|
| Parcae (extrapolated to 24 loops) | ≈ 104 | Flat plateau at test time |
| Parcae (mean 8 recurrences) | ≈ 107 | Solves tasks despite heavy memorization |
| Dense (balanced) | ≈ 198 | Degrades, cracks at high scale |
| MoE (28% active) | ≈ 2217 | Complete reasoning collapse |
Three takeaways:
- Parameters are a memory budget, not a reasoning budget. Past the point of tight fit (), extra parameters primarily buy memorization. In MoE, that capacity actively inflates the generalization gap on reasoning tasks.
- Memorization itself isn't the enemy. The identity shows memorization only hurts when it forces up on the reasoning tokens. Architectures differ in how much of that spillover they isolate.
- Weight-shared compute behaves fundamentally differently from parameter scaling. Looping a shared block adds reasoning depth without expanding the memorization budget, decoupling knowledge storage from algorithm execution. That is the road to success under heavy memorization pressure.
Limitations#
First, this is a synthetic graph benchmark: multi-task sampling, power-law lengths, and stochastic encodings narrow the gap to natural language, but don't prove the exact same collapse dynamics occur on web text. Second, sweeping this many architectures made per-architecture hyperparameter tuning infeasible. Learning rates and batch sizes were shared across families and are sub-optimal. Still we expect the qualitative results to hold.
Credits & further reading#
This post condenses my master's thesis, Exploring Memorization and Generalization in Large Language Models Across Architectures, written at EPFL's Machine Learning and Optimization Laboratory under Alexander Hägele and Kaustubh Ponkshe, directed by Prof. Martin Jaggi. Full derivations, per-model tables, and appendices are in the thesis.
- How much do language models memorize? — Morris et al., 2025
- Mixture of Parrots: Experts improve memorization more than reasoning — Jelassi et al., 2025
- Parcae: Scaling Laws for Stable Looped Language Models — Prairie et al., 2026
- Generalization vs. Memorization: Tracing LLMs' capabilities back to pretraining data — Wang et al., 2025
- Physics of Language Models 4.1: Architecture design and the magic of canon layers — Allen & Su, 2025
- Muon is Scalable for LLM Training — Liu et al., 2025
I'm an AI scientist at Mistral AI, working on frontier AI models. I hold an M.Sc. in Data Science from EPFL and a B.Sc. in CS from MIPT. Over the last couple of years, I've built real-time speech recognition systems from the ground up at Yandex and researched compute-optimal quantization at Apple. My academic work on efficient training dynamics and scaling laws has been published at ICLR and TMLR. When I'm not doing research or contributing to open-source projects, I write here about whatever I'm currently exploring—from optimizing GPU kernels with Triton to the scaling laws behind efficient training.
View all articles by Alex Dremov →




