When Memorization Breaks Reasoning: Dense vs. MoE vs. Latent-Reasoning LLMs

What happens when memorization and reasoning collide inside the same model on the same data? Our study pushed Dense, MoE, and looped transformers to their limits to answer this question

Alex Dremov
Alex DremovJUL 15, 2026 · 14 MIN READ
Editorial vector illustration of repeating directed-graph echoes where two paths fracture while a sage-green recurrent loop threads unbroken.

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 PθP_\theta 3. Intuitively, if we have a true data distribution PθP_\theta, 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 PθP_\theta 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 pp. Here p=log⁡2(28)28≈0.1717p = \frac{\log_2(28)}{28} \approx 0.1717, 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 PθP_\theta exactly.

Structure of one synthetic dataset sample: graph definition section followed by tasks section
Figure 1. Structure of one training sample. A graph definition is followed by 10 algorithmic queries over that graph. Topology, vertex names, encoding format, task types, task parameters, and non-deterministic answers are all sampled stochastically.

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 described by the sample, with vertex names vj, dt, lm, pu, yi, kl, ew, ll, bh, cw 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).

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 PθP_\theta, 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 PθP_\theta, so expected train entropy matches true entropy; only its variance grows as unique graphs shrink.

Memorization and generalization collide#

With an exact oracle PθP_\theta 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 xix_i and trained model θ^\widehat{\theta}, let lθ(xi)=−log⁡Pθ(xi)l_\theta(x_i) = -\log P_\theta(x_i) be the sample's negative log-likelihood under the true generator and lθ^(xi)=−log⁡Pθ^(xi)l_{\widehat{\theta}}(x_i) = -\log P_{\widehat{\theta}}(x_i) under the model. Per-sample unintended memorization is:

mem⁡UK(xi,θ^)=lθ(xi)−min⁡ ⁣(lθ(xi), lθ^(xi))=max⁡ ⁣(0, lθ(xi)−lθ^(xi))\operatorname{mem}_{\text{U}}^{\text{K}}(x_i, \widehat{\theta}) = l_\theta(x_i) - \min\!\left(l_\theta(x_i),\, l_{\widehat{\theta}}(x_i)\right) = \max\!\left(0,\, l_\theta(x_i) - l_{\widehat{\theta}}(x_i)\right)

The intuition is simple: lθ(xi)l_\theta(x_i) is the best code length any model could achieve knowing only the true distribution. If your trained model compresses xix_i below that floor, it must have memorized specifics of xix_i. Averaging over the training set gives our dataset memorization metric M‾\overline{M}.

For generalization, I use sequence-level KL divergence on held-out graphs, decomposed autoregressively token by token:

KL⁡(Pθ∥Pθ^)=EX∼Pθ ⁣[∑j=1m(log⁡Pθ(Xj∣X<j)−log⁡Pθ^(Xj∣X<j))]\operatorname{KL}(P_\theta \| P_{\widehat{\theta}}) = \mathbb{E}_{X \sim P_\theta}\!\left[ \sum_{j=1}^{m} \Big( \log P_\theta(X_j \mid X_{\lt j}) - \log P_{\widehat{\theta}}(X_j \mid X_{\lt j}) \Big) \right]

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(1−x/KL⁡uniform)100(1 - x/\operatorname{KL}_{\text{uniform}}): 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 U(xi)=max⁡(0,lθ^(xi)−lθ(xi))U(x_i) = \max(0, l_{\widehat{\theta}}(x_i) - l_\theta(x_i)). Writing empirical risk as 1N∑lθ(xi)−M‾+U‾\frac{1}{N}\sum l_\theta(x_i) - \overline{M} + \overline{U} and expanding KL as true risk minus data entropy gives an exact accounting identity:

KL⁡(Pθ∥Pθ^)=−M‾+U‾+G(θ^)+S(x)\operatorname{KL}(P_\theta \| P_{\widehat{\theta}}) = -\overline{M} + \overline{U} + G(\widehat{\theta}) + S(x)

where G(θ^)G(\widehat{\theta}) is the standard train–test generalization gap and S(x)S(x) is the sample entropy shift (zero in expectation under our dial). Because KL is non-negative, this yields an immediate upper bound in expectation: M‾⩽U‾+G(θ^)\overline{M} \leqslant \overline{U} + G(\widehat{\theta}). 8. Basically bias–variance per sample: U‾\overline{U} is bias, GG is variance, M‾\overline{M} is explicit overfitting.

💡
The intuition. A model cannot memorize more than the sum of its underfitting and its generalization gap. Small, underfitted models have large U‾\overline{U}—a "capacity slack" that absorbs memorization pressure without hurting test performance. Once a model fits the training set tightly (U‾≈0\overline{U} \approx 0), every extra bit of memorization must be paid out of the generalization gap GG.

That sets up the real question for the experiments: when memorization pressure forces GG 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.

Memorization with vertex names re-sampled across permutations still grows with permutation count
Figure 3. Memorization survives complete token-level resampling. Unintended memorization across model sizes and permutation counts when vertex labels are re-randomized on every permutation. Graph-definition memorization still scales with permutation count; query-section memorization stays flat.

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 (dmodel/nlayerd_{\text{model}} / n_{\text{layer}}): 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

Models with different width-to-depth ratios occupy the same region in generalization-memorization coordinates
Figure 4. Dense models across width-to-depth ratios. Generalization score vs. unintended memorization for deep (~51), balanced (~90), wide (~183), and extra-wide (>500) dense transformers across permutation counts. All shapes trace the same trajectory.

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.

Per-component performance: graph encoding degrades under memorization pressure while task solving improves until collapse
Figure 5. Where dense models pay the memorization bill. Total, graph-encoding, and reasoning scores for the same width-to-depth sweep. Graph encoding degrades steadily with permutation count; reasoning holds up until 250 permutations.

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).

MoE memorization increases with total parameter count and saturates
Figure 6. MoE memorization tracks total parameters. Unintended memorization vs. total parameter count across sparsity levels and permutation counts. Sparsity barely shifts the curves—total parameters set memorization.

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.

MoE reasoning collapses at 100 permutations while dense models hold until 250
Figure 7. The MoE reasoning collapse. Reasoning score vs. active parameters by permutation count, with the balanced dense baseline dashed. MoE diverges sharply at 100 permutations and collapses across scales at 250.

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.

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 μrec\mu_{\text{rec}} 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 Aˉ=exp⁡(−ΔA)\bar{A} = \exp(-\Delta A): 11. Loop counts are Poisson-sampled per sequence during training, with BPTT truncated to the last half.

ht=Aˉ⋅ht−1+Bˉ⋅e,Bˉ=1−AˉAh_t = \bar{A} \cdot h_{t-1} + \bar{B} \cdot e, \qquad \bar{B} = \frac{1 - \bar{A}}{A}

Here ee is the recurrent block's output at step tt, and Δ,A\Delta, A 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.

Parcae memorization is mainly dictated by total parameter count, not recurrence depth
Figure 9. Parcae memorization follows parameters, not loops. Unintended memorization vs. parameter count across mean recurrence depths. Increasing loop count barely shifts memorization.

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 LL unique layers (split evenly into prelude, looped core, and coda), effective depth is 23L+13Lμrec\tfrac{2}{3}L + \tfrac{1}{3}L\mu_{\text{rec}}. Same effective depth, same compute per token. At 250 permutations, the depth-matched Dense model still collapses, while Parcae holds steady (Figure 10).

Matched by effective depth, dense models collapse under memorization pressure while Parcae does not
Figure 10. Matched by effective depth, Dense still breaks. Reasoning score vs. effective depth across permutation counts (Recurrence = 1 is the deep Dense baseline). The resilience comes from weight-shared latent recurrence, not raw FLOPs.

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.

Parcae preserves task-solving under extreme memorization pressure where dense and MoE collapse
Figure 11. Latent compute as a shield. Reasoning score vs. parameter count across recurrence levels and permutation counts. Unlike Dense and MoE, Parcae maintains high reasoning performance through the 250-permutation regime.

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.

Reasoning reaches a stable plateau when extrapolating inference recurrence from 1 to 24 steps
Figure 12. Test-time loop extrapolation. Parcae trained at mean recurrence 16 and evaluated from 1 to 24 loops across permutation counts. Reasoning reaches a stable plateau after ~5–7 iterations with no late-step degradation.

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.

Reasoning score versus memorization for Dense, MoE, and Parcae models across dataset permutation counts
Figure 13. All three architectures side by side. Reasoning score vs. unintended memorization across permutation counts for Dense (balanced), MoE (28% active), and Parcae (mean 8 recurrences). One universal trade-off—three very different breaking points.
Model @ 250 permutationsTask-level KL (lower = better)Outcome
Parcae (extrapolated to 24 loops)≈ 104Flat plateau at test time
Parcae (mean 8 recurrences)≈ 107Solves tasks despite heavy memorization
Dense (balanced)≈ 198Degrades, cracks at high scale
MoE (28% active)≈ 2217Complete reasoning collapse

Three takeaways:

  • Parameters are a memory budget, not a reasoning budget. Past the point of tight fit (U‾≈0\overline{U} \approx 0), 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 KL⁡=−M‾+U‾+G+S\operatorname{KL} = -\overline{M} + \overline{U} + G + S shows memorization only hurts when it forces GG 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.

WRITTEN BY

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 →

Recommended Read

BibTeX Citation
@online{dremov2026memorization,
  author  = {Alex Dremov},
  title   = {When Memorization Breaks Reasoning: Dense vs. MoE vs. Latent-Reasoning LLMs},
  year    = {2026},
  month   = {jul},
  url     = {https://alexdremov.me/memorization-vs-generalization-llm-architectures/}
}
1×
CAD X-RAY

SESSION TELEMETRY RECEIPT

ALEXDREMOV.ME · LOCAL ONLY

    ↑↓ NavigateEnter Select#tag FilterEsc Close