Do Dynamic Routers Need Memory? HeRo: History-Aware Routing for Efficient LLM Inference

Hongjin Lin, Wentao Wan, Keze Wang
9/8/2026
cs.AIcs.CL

No official code found. Best implementation: teddytennant/jax-hero (0 stars, MIT, last commit 2026-09-09).

Abstract

Dynamic layer routing reduces the inference cost of Large Language Models (LLMs) by learning to skip layers for individual tokens. Existing methods, however, treat each routing decision as a local operation conditioned solely on the current hidden state which is a formulation that overlooks the sequential, path-dependent nature of routing across depth: earlier decisions shape the representations seen by downstream routers, and the layer-usage objective couples all decisions jointly. We propose History-Aware Routing (HeRo), a dynamic routing framework that resolves this mismatch by introducing a router memory mechanism to maintain an explicit routing state across model depth. The memory is constructed via linear attention, incrementally aggregating preceding routing scores and their induced residual updates into a compact history representation. At each routed layer, the router conditions jointly on this accumulated state and the current hidden representation to select the executed branch. Instantiated for token-wise FFN routing, HeRo trains only lightweight routers and adapters on a frozen backbone, requiring no modification to pretrained parameters. Across Llama 3.1-8B, Llama 2-7B, and Llama 2-13B, HeRo consistently achieves the highest aggregate performance retention among ten baselines. On Llama 3.1-8B, it bypasses 26.87% of model parameters while achieving 100.24% of dense model performance across seven benchmarks, and retains 97.01% while bypassing 38.82% of model parameters under a tighter computation budget. Ablation studies confirm that removing routing history consistently degrades performance, most notably on multistep reasoning and code generation, validating that explicit routing memory enables more accurate and adaptive dynamic routing than solely conditioning on hidden state.

View on arXivView PDF

Code Implementations(1)

MIT

JAX implementation of Do Dynamic Routers Need Memory? HeRo: History-Aware Routing for Efficient LLM Inference (arXiv:2609.08189)

00Sep 9, 20261 months agoMIT

Similar Papers

Cite this paper

@article{lin2026dynamic,
  title  = {Do Dynamic Routers Need Memory? HeRo: History-Aware Routing for Efficient LLM Inference},
  author = {Hongjin Lin and Wentao Wan and Keze Wang},
  year   = {2026},
  eprint = {2609.08189},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2609.08189v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2609.08189.svg)](https://codeofpaper.com/paper/2609.08189)

Discussion