Shattered Compositionality: Counterintuitive Learning Dynamics of Transformers for Arithmetic

Xingyu Zhao, Darsh Sharma, Rheeya Uppaal, Yiqiao Zhong

TL;DR

When humans learn multi-digit addition, we start at the ones place and carry leftward; transformers, bizarrely, learn from the thousands place downward or grab subskills in chaotic parallel. Because models greedily latch onto the easiest statistical correlations in the data rather than causal rules, their half-baked subskills end up competing—explaining why modern LLMs ace math benchmarks yet crumble when a word problem gets just a tiny bit longer.

What Problem Does This Paper Address?

Anyone who has played with Large Language Models (LLMs) knows a frustrating paradox: a model can ace an Olympiad-level math benchmark, yet stumble when you slightly reword a grade-school problem. Recent interpretability studies suggest this happens because LLMs don't learn unified algorithms; instead, they assemble a messy "bag of heuristics."

However, prior work mostly dissected static, fully trained models—like examining a fossil without knowing how the creature grew. That leaves a massive blind spot: How do these non-human skill compositions actually emerge during training, and why does optimization prefer them over clean, textbook rules?

Methods

To watch skill acquisition unfold in real time, the authors step away from impenetrable internal circuits and use black-box, model-agnostic diagnostics on standard 10.63M-parameter NanoGPT transformers trained from scratch.

Using character-level (digit-wise) tokenization, they break elementary arithmetic down into measurable subskills—such as predicting individual digit places, handling carries, comparing number lengths, and ranking digits. What is novel here is pairing fine-grained training trajectories with information-theoretic metrics (specifically, unconditional and conditional Mutual Information between input and output digits) and controlled contrast pairs (e.g., testing numbers that differ in only one digit) to expose exactly when subskills emerge and how they interfere with each other.

Datasets

  • Synthetic Arithmetic Suite: Four controlled datasets generated from scratch—4-operand addition (1M samples), multi-digit by single-digit multiplication (100K samples, up to 40 digits), 4-digit comparison (45K samples, using "balanced sampling" to guarantee shared leading digits), and 3-to-4-digit sorting (100K "doubly balanced" samples).
  • Clause-Extended GSM8K (New Benchmark): Derived from the standard GSM8K math word-problem dataset, the authors curated 50 multi-operand addition templates and appended 1 to 6 extra narrative clauses (e.g., "his next $m$ customers buy $k$ DVDs each") to test pretrained LLMs under mild compositional shifts.

Key Insights and Ideas

  • Shattered Compositionality: Instead of building sequential hierarchies, transformers learn addition backwards (thousands place down to units place) and multiplication bidirectionally from both ends at once. Even when the authors reversed the output digits so left-to-right generation matched the human right-to-left carry rule, the models still learned higher digits first—and actually converged slower!
Digit-wise error rates across training steps for plain addition, showing the thousands-place error dropping to zero first while the units-place learns last.
Figure 2: Transformers learn digits in two-way order for simple multiplication. The model learns from both ends: learning spreads from the most significant end while the units place is acquired early in parallel. Multiplication therefore exhibits a bidirectional acquisition pattern rather than a single human-like or reverse order.
  • Optimization Chases Correlations, Not Causality: Why learn backwards? Under uniform sampling, the highest input and output digits share strong unconditional Mutual Information, whereas lower digits have zero unconditional correlation until carry information is resolved. Maximum-likelihood training greedily fits the loudest statistical signal first, which then unlocks conditional signals for lower digits.
Figure 3: Transformer’s learning behavior is captured by mutual information (MI) metrics. Top: We track the MI metrics I(a1, bp0) (highest digit) and I(ai, bpi | Ki−1) (other digits) using the model’s prediction probabilities across training (solid curves), which are compared against the corresponding I(a1, e0) and I(ai, ei | Ki−1) based on the training data (dashed line). Bottom: Sharp descents of training loss are matched with changes of MI metrics at each output digit, indicating skill acquisition.
  • Parallel Learning Breeds Skill Competition: In comparison and sorting, models learn multiple digit-comparison rules simultaneously rather than hierarchically. Early in comparison training, learning to output = when digits match temporarily wrecks the model's already-learned ability to spot differences in the thousands place. In sorting, competing parallel skills literally splice different inputs together into "Frankenstein" numbers (mixing errors).
  • Scale and Scratchpads Don't Magically Fix It: Scaling NanoGPT up to 100M parameters, fine-tuning a pretrained Pythia-1B model, or supervising with place-value scratchpads reshapes the training path, but fails to restore clean, human-like sequential skill acquisition.

Key Results

  • Gated Dependencies: In an ablation where the thousands-place output digit in addition was randomized (or its loss zeroed out), the model completely failed to learn lower digits—leaving hundreds, tens, and units stuck near the 90% random-guessing error baseline even after 400,000 steps.
  • Quantifying Skill Interference: In sorting, overall in-distribution test error reached 1.7%. Yet on out-of-distribution test groups where two digit-comparison cues conflicted, the model produced chimeric "mixing errors" 6.63% of the time, nearly double the 3.61% rate when those cues agreed.
  • Modern LLM Brittleness: Across 10 open-source LLMs (including Llama-3.1-8B-Instruct, Gemma-2-9B-it, Qwen2.5-Math-7B, and DeepSeek-Math-7B), accuracy steadily degraded on Clause-Extended GSM8K as 1 to 6 clauses were added, frequently failing by omitting or repeating terms in the final sum—echoing the synthetic mixing errors.

Limitations and Future Work

Because the analysis is intentionally black-box, it tracks what skills emerge and when, without mapping the exact internal attention heads or MLP circuits implementing them. Additionally, the deep training-dynamics experiments rely on small transformers and synthetic tasks rather than full-scale LLM pretraining runs. For future work, the authors suggest marrying these training-trajectory diagnostics with white-box mechanistic interpretability, and exploring interventions like structured curricula (teaching component skills before composition), column-level carry supervision, and task-aligned architectural biases.

Summary updated

BibTeX
@inproceedings{zhao2026shattered,
  author = {Xingyu Zhao and Darsh Sharma and Rheeya Uppaal and Yiqiao Zhong},
  title = {{Shattered Compositionality: Counterintuitive Learning Dynamics of Transformers for Arithmetic}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=VUD0RWdAEz},
}
Figure