Longhorn: State Space Models are Amortized Online Learners

Bo Liu, Rui Wang, Lemeng Wu, Yihao Feng, Peter Stone, Qiang Liu · DOI

Introduction

While Transformer architectures have set the standard for sequence modeling, their quadratic computational complexity relative to sequence length presents a significant barrier for long-context applications. State Space Models (SSMs), such as Mamba, have emerged as a linear-scaling alternative. However, the internal state-transition dynamics of these models are often designed using heuristic or "artisanal" rules. Longhorn addresses this theoretical gap by framing SSM recurrence as a principled online learning problem, deriving its update rules from a formal optimization objective.

Methodology: SSMs as Online Learners

The core innovation of Longhorn is the conceptualization of the sequence-mixing layer as a "meta-module" that performs amortized online learning. Instead of using hand-crafted recurrence relations, Longhorn defines an online learning objective based on associative recall—the fundamental ability to retrieve a specific value given a corresponding key.

Conceptual framework of Longhorn, where the sequence-mixing layer updates the internal state $S_t$ by solving an online learning objective.

By solving this objective in closed form, the authors derive a stable recurrence rule that naturally balances the retention of historical information with the integration of new tokens. This approach eliminates the need for a separately parameterized forget gate; the "forgetting" mechanism emerges mathematically from the optimization dynamics, leading to a more parameter-efficient and stable architecture.

Experimental Evaluation

Longhorn was evaluated across a wide spectrum of tasks to test its efficiency, memory, and scalability:

  • Synthetic Tasks: Multi-Query Associative Recall (MQAR) to evaluate core memory capabilities.
  • Language Modeling: Small-scale training on OpenWebText and large-scale training on SlimPajama (up to 100B tokens) for a 1.3B parameter model.
  • Downstream Benchmarks: Standard NLP evaluations including PIQA, HellaSwag, and ARC.
  • Computer Vision: ImageNet-1K classification to assess the model's versatility beyond text.

Key Results and Discussion

Longhorn demonstrates significant improvements in both training efficiency and inference-time flexibility. A primary finding is its 1.8x improvement in sample efficiency compared to Mamba, reaching equivalent perplexity levels with nearly half the training data.

Furthermore, Longhorn exhibits remarkable robustness in context extrapolation. While many models fail when processing sequences longer than their training window, a Longhorn model trained on 2,048 tokens can extrapolate to 32,768 tokens with minimal performance degradation. This stability is attributed to the update rule being grounded in a well-defined optimization problem rather than heuristic dynamics.

Longhorn demonstrates superior sample efficiency (1.8x speedup) and robust context extrapolation up to 32k tokens compared to Mamba and LLaMA.

In vision tasks, "Vision Longhorn" (ViL) slightly outperformed Vision Mamba (ViM) on ImageNet-1K while utilizing fewer parameters, suggesting that the principled recurrence rule generalizes well across modalities.

Conclusion and Future Work

Longhorn provides a unifying theoretical foundation for designing SSM state-transition dynamics. By viewing the hidden state as a set of weights updated via Online Convex Programming, the architecture achieves superior efficiency and extrapolation. Current limitations include the use of a diagonal approximation for parallel efficiency, which may constrain expressive power. Future research could explore more complex online learning objectives or hybrid architectures to further extend the capabilities of long-context modeling.

Summary updated

BibTeX
@inproceedings{liu2025longhorn,
  author = {Bo Liu and Rui Wang and Lemeng Wu and Yihao Feng and Peter Stone and Qiang Liu},
  title = {{Longhorn: State Space Models are Amortized Online Learners}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=8jOqCcLzeO},
}
Figure