← Kristian Schwethelm

Depth-Adaptive Inference of Looped LMs

via Continuous Depth Batching

Preprint 2026

1Technical University of Munich · 2Imperial College London · 3MCML · 4Hasso Plattner Institute, University of Potsdam

TL;DR

We introduce the first efficient end-to-end inference method for depth-adaptive looped language models, which are taking less compute for "easy" tokens and more for "hard" tokens, translating per-token compute savings into practical inference speedups through continuous depth batching.

Read full abstract Hide abstract

Abstract

A main promise of looped language models is depth-adaptive inference. By looping a block of shared layers a variable number of times, the model can use less compute for “easy” tokens and more for “hard” ones. However, tokens with different numbers of loops cannot share a uniform forward pass and therefore cannot be handled by standard batching systems such as vLLM. The practical value of depth-adaptive inference thus hinges on whether batching can be made efficient.

We introduce the first efficient method for depth-adaptive looped LMs via continuous depth batching (CDB), which forms new batches between loop steps. Our method dynamically schedules looped and non-looped parts of the architecture, manages looped KV-caching, and predicts which tokens will exit the loop in advance so it can prepare batches asynchronously.

Experiments on Ouro 1.4B and Huginn 3.5B show that fully looped architectures are best suited to depth-adaptive inference, as large non-looped layers outside the recurrent core (e.g., token embedding, LM head, and unshared transformer blocks) slow down and complicate scheduling. Overall, CDB realizes up to 99% of the estimated maximum speedup available, leaving further gains primarily dependent on model architecture and exit behavior.

See how it works

What is depth-adaptive decoding?

Looped LMs repeatedly execute a block of shared layers, called the recurrent core, to scale effective computation with loop steps without increasing parameter count. Outside the recurrent core, unshared layers in the prelude and coda process each token before it enters the loop and predicts the next token after exiting the loop, respectively.

Depth-adaptive decoding allows tokens to exit the recurrent core after different depths (different number of loop steps). The model can use fewer loops and less compute for “easy” tokens, and more loops for “hard” ones, improving the compute–accuracy trade-off. But can we serve these dynamic forward passes efficiently?

Prelude Recurrent core Coda P 1 2 exit C It P 1 exit C is P 1 2 3 exit C 60 What is 12 × 5? prompt sampled token
The prompt is “What is 12 × 5?” The tokens “It”, “is”, and “60” use 2, 1, and 3 loop steps, respectively. Each token passes through prelude and coda.

Colors show 1 to 4 loop steps per token. In the math answer, “The” uses 4 steps, “result” uses 3, and “60” uses 2.

Loop steps per token 1 2 3 4
$ What is 12 × 5?
The result of 12 multiplied by 5 is **60**.

Run it with Loop-SGLang: uv run loopsgl serve --model "KristianS7/Ouro-1.4B-Thinking" --exit-threshold 0.1 --shell

Problem: Batching tokens with different forward passes

In depth-adaptive decoding, tokens within a batch can have different numbers of loops and thus different forward passes: exited tokens need to run the coda, while remaining tokens need another loop step. Standard serving systems like vLLM assume a uniform forward pass and cannot batch these tokens together. Our inference method based on continuous depth batching (CDB) can do it by forming new batches between loop steps within the forward pass and refilling batch slots as tokens exit.

We propose three components to make this efficient:

Stage-wise scheduling

Exited tokens need to run the coda, while remaining tokens need another loop step. Our scheduler decides which stage to run next and batches its waiting tokens. It interleaves prefill, prelude, core, and coda to refill freed slots and keep batch size high.

Four tokens start in the core. Two exit while two wait for another loop step. Coda and prelude prepare two next tokens, which refill the core batch to four.

Depth-aware KV cache

Our cache manager handles the missing KV states left by early exits. Last-exited maps skipped depths to the final KV state and returns their slots to the cache pool. Shared caching updates one slot per token and recurrent layer at each loop step.

Tokens exit after 2, 1, and 3 loop steps. Last-exited keeps 6 KV slots and frees 3; Shared uses 3 slots. At skipped depths, later tokens attend to the last KV state computed before exit.

Lookahead gate

With standard early exit gates, the CPU must wait for the exit decisions after each loop step. It then prepares the next batch while the GPU is idle. Our lookahead gate predicts exits one loop step earlier, so batch preparation overlaps GPU execution.

Both examples run three GPU loop steps. Standard gating leaves gaps while the CPU prepares batches. Lookahead overlaps CPU preparation with GPU work.

Main findings

To analyze CDB, we derive a prefill-corrected bound that estimates the maximum achievable speedup and a hardware-aware latency model that predicts when refill helps. We then evaluate CDB in offline throughput and online serving benchmarks on two prominent looped models with different architectures: Ouro is fully looped, while Huginn loops only its middle transformer block with non-looped blocks in prelude and coda.

We make the following main findings:

Depth-adaptive decoding can be served efficiently

Our CDB implementation solves the batching problem posed by variable-depth forward passes. CDB with refill is near-optimal for fully looped models and can realize up to 99% of the speedup available from early exits.

Ouro 1.4B: refill stays close to the estimated maximum, with about 1.5× throughput across batch sizes 16 to 512. Without refill, throughput rises from about 1.25× to 1.42×.
Refill helps most at small batch sizes.

Co-designing looped LMs and inference systems is important.

Our results offer concrete guidance for designing looped models that benefit even more from depth-adaptive inference: cheap prelude and coda, lookahead exit decisions, and memory-efficient KV cache support.

Huginn 3.5B: refill and no-refill converge at larger batches, reaching about 1.4× throughput at batch size 512, below the estimated maximum.
Huginn's costly prelude and coda slow refill.

Improved the compute-accuracy trade-off

CDB preserves the model’s predictions and exit decisions. However, early-exits and KV cache sharing affect accuracy. Meaningful speedups require models like Ouro that provide enough early exits at the desired accuracy.

Ouro 1.4B GSM8K accuracy versus mean loop steps. Depth-adaptive decoding retains high accuracy down to about 2.5 mean loop steps and outperforms fixed-depth decoding at comparable mean depths.
High accuracy until ~2.5 mean loop steps.

Throughput speedup is relative to full-depth continuous batching at 1× and includes prefill.

  • CDB with refill
  • CDB without refill
  • Estimated maximum

Citation

BibTeX

@misc{schwethelm2026cdb,
  title={Depth-adaptive Inference of Looped Language Models via Continuous Depth Batching},
  author={Kristian Schwethelm and Daniel Rueckert and Georgios Kaissis},
  year={2026},
  eprint={2608.09444},
  archivePrefix={arXiv},
  primaryClass={cs.LG},
  url={https://arxiv.org/abs/2608.09444}
}