Understanding Dynamic Compute Allocation in Recurrent Transformers

Ibraheem Muhammad Moosa, Suhas Lohit, Ye Wang, Moitreya Chatterjee, Wenpeng Yin

Abstract / TL;DR Most Large Language Models (LLMs) allocate a fixed amount of computational power to every token, regardless of its complexity. "Adaptive compute" models attempt to solve this inefficiency by spending more time on difficult tokens. However, evaluating these models on standard natural language benchmarks obscures whether they truly align their effort with underlying task complexity. By introducing ANIRA, a recurrent Transformer framework tested on algorithmic tasks with measurable difficulty, researchers demonstrate that while models naturally learn to spend more compute on harder problems, this alignment does not translate to out-of-distribution generalization.

The Problem: Unobservable Difficulty in Natural Language

Standard LLMs are "fixed-depth," meaning they expend the exact same processing power on a simple word like "the" as they do on a complex mathematical step. Adaptive computation aims to optimize this by dynamically allocating more layers (or compute steps) to "hard" tokens and fewer to "easy" ones.

Historically, researchers have evaluated these adaptive models on natural language benchmarks. The flaw in this approach is that "difficulty" in natural language is subjective and unobservable. It is often impossible to determine whether a token requires more compute because of complex underlying logic or simply because of unusual sentence structure. To address this, the authors propose a complexity-controlled evaluation paradigm. By utilizing tasks with mathematically defined difficulty, they can directly test whether a model learns to "think longer" when the underlying logic becomes more demanding.

Methods: The ANIRA Framework

To systematically study compute allocation, the authors introduce ANIRA (Adaptive Neural Iterative Reasoning Architectures). ANIRA is a unified framework built on a "Prelude-Recurrent-Coda" structure, where the core reasoning engine is a single Transformer block applied recursively.

The framework isolates compute allocation decisions from other architectural factors by comparing two distinct decision-making mechanisms:

  1. ANIRA-E (Early Allocation): The model evaluates the input token and immediately predicts a fixed "compute budget" (the number of times to run the recurrent block).
  2. ANIRA-O (Online Halting): The model processes the token step-by-step, deciding after each iteration whether it has gathered enough information to halt.

These models are trained using a standard loss function combined with a compute regularizer that penalizes excessive steps. A passthrough mechanism ensures that tokens finishing early remain visible to tokens still undergoing processing.

Datasets for Controlled Complexity

Moving away from the confounding variables of natural language, the study employs datasets where complexity can be precisely parameterized:

  • MANO & BREVO: Synthetic tasks focused on modular arithmetic and graph dependency traversal.
  • CLRS-Text: A suite of 30 classic algorithms (e.g., sorting, shortest path) adapted into a text format.
  • LANO: A synthetic language generated from formal grammars, tying difficulty directly to syntactic ambiguity.
  • GSM-Symbolic: A natural language math dataset used to test whether findings hold in more realistic, albeit noisier, settings.

Key Insights and Results

Emergent Alignment Without Generalization

The most striking finding is that models successfully learn to allocate more compute to harder tokens—such as larger graphs or longer arithmetic chains—purely through trial and error. They achieve this emergent alignment without any explicit supervision regarding which tokens are "hard."

However, this alignment reveals a critical limitation: Alignment does not equal generalization. Even though a model learns to spend more time on a problem as it grows in size, it still fails to solve problems larger than those encountered during training. Instead of learning a universal algorithm, the model learns "size-specific" shortcuts.

Heuristics vs. Algorithmic State

The timing of the compute decision fundamentally changes how the model operates. ANIRA-E (early allocation) relies heavily on structural heuristics; for instance, it might see a large graph and preemptively assume it needs more time. Conversely, ANIRA-O (online halting) tracks actual algorithmic progress, stopping only when the internal logic of the calculation reaches a valid conclusion. Consequently, ANIRA-O consistently proves more efficient than its early-decision counterpart.

The Two-Phase Training Regime

The researchers also observed a fascinating training dynamic. Models consistently undergo a two-phase learning process: they first learn to solve the task by utilizing the maximum available compute, and only later do they learn to prune unnecessary steps to optimize for efficiency.

Limitations and Future Directions

While ANIRA models achieve near-perfect accuracy on algorithmic tasks with significantly fewer recurrent steps than fixed-budget baselines, the study highlights several ongoing challenges:

  1. The Generalization Gap: Adaptive compute does not inherently solve out-of-distribution (OOD) extrapolation. Models still struggle to apply their reasoning to significantly larger inputs.
  2. Natural Language Proxies: On datasets like GSM-Symbolic, the correlation between compute and difficulty is much weaker. Natural language remains too confounded by other factors for current adaptive models to track difficulty cleanly.
  3. Hardware Constraints: Modern high-performance inference engines (like vLLM) are optimized for fixed-depth architectures. Realizing the theoretical speedups of ANIRA in production will require novel, flexible serving frameworks.

Future research may explore applying these controlled evaluations to diffusion-based language models or developing stronger inductive biases that force models to learn true, generalizable algorithms rather than size-specific heuristics.

Summary updated

BibTeX
@inproceedings{moosa2026understanding,
  author = {Ibraheem Muhammad Moosa and Suhas Lohit and Ye Wang and Moitreya Chatterjee and Wenpeng Yin},
  title = {{Understanding Dynamic Compute Allocation in Recurrent Transformers}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=vzzTxg0cbU},
}
Figure