Mamba with Hierarchical Memory: Solving Representation Bottleneck in Long Sequence Modeling

Qinwen Wang, Jieping Luo, Aoxiang Qin, Ruoyu Zhao, Jianxiong Tang, Wei Zhang, Zhichao Lu, Luziwei LengarXiv 2026

TL;DR

While linear-time recurrent models like Mamba offer an efficient alternative to Transformers, their fixed-capacity hidden states create a representation bottleneck over long sequences. This paper introduces Hierarchical Memory Mamba (HMM), a brain-inspired architecture that extracts, compresses, and retrieves paragraph-level semantics to bypass this bottleneck. HMM improves long-context reasoning accuracy by up to 14.2% and retrieval success by over 34% while adding only 2% extra parameters and zero memory overhead during inference.

What Problem Does This Paper Address?

Transformer-based Large Language Models (LLMs) excel at processing context but suffer from a quadratic computational complexity ($O(L^2)$) that makes long-sequence modeling prohibitively expensive. Recurrent Linear Attention models (RLAs) and State-Space Models (SSMs) like Mamba solve this by scaling linearly ($O(L)$). However, they introduce a different flaw: they compress an ever-expanding history into a fixed-dimensional hidden state.

The authors reveal two critical issues with current long-context Mamba variants:

  1. The Illusion of Low Perplexity: Simply reducing numerical decay improves perplexity (PPL) but does not translate to better long-context reasoning.
  2. Semantic Aliasing: Because a fixed-size state manifold must map an exponentially expanding history space, distinct historical trajectories inevitably become indistinguishable over long horizons.

Methods

Inspired by the multi-stage nature of human memory, the authors propose Hierarchical Memory Mamba (HMM), which decouples token-level recurrence from long-term semantic storage.

Figure 2: Overview of HMM. (a) Cognitive Inspiration: Multi-stage human memory involving sensory, working, and long-term memory. (b) Technical Pipeline: Through a trainable working memory network, HMM firstly maps pre-trained Mamba hidden states (ht) (resembling sensory memory) to high-level semantic representation as long-term memory via Semantic Encoding (red arrow, Sec. 5.1), then retrieves and broadcasts them back to late layers of the pretrained backbone via Semantic Retrieval (green arrow, Sec. 5.2) to enhance the capability for long-context reasoning.

HMM operates via two core procedures:

  • Semantic Encoding:
  • Segmentation: The hidden states of a pre-trained Mamba backbone act as "sensory memory." A lightweight working memory tracks these states and uses cosine similarity to detect "semantic drift." When the topic shifts, it segments the text into Paragraph-Level Semantics (PLS).
  • Compression: A small feed-forward network downsamples these PLS vectors into a highly compressed Long-Term Memory (LTM) array.
  • Semantic Retrieval:
  • Selection: The model uses a similarity ranking (Top-$K$ cosine similarity) to find historical LTM elements relevant to the current paragraph.
  • Injection: The selected long-term memories are averaged and broadcasted back into the later layers of the Mamba backbone as an external additive bypass.

Datasets

The model was trained (adapted) using 6,000 long-context sequences sampled from The Pile. It was evaluated across three distinct benchmarks without any downstream task-specific fine-tuning:

  • PG-19: Used to measure language modeling perplexity up to 32k context lengths.
  • LongBench-E: A comprehensive benchmark evaluating real-world long-context reasoning tasks like QA and summarization.
  • Passkey Retrieval: A diagnostic task testing the exact retrieval of a hidden key across sequence lengths spanning from 1k to 64k tokens.

Key Insights and Ideas

  • Performance Decoupling: The paper proves both empirically and theoretically that statistical fluency (low perplexity) does not equal semantic utility in recurrent models.
  • Bypassing the Jacobian Collapse: In standard SSMs, the mathematical sensitivity (Jacobian) to distant tokens decays exponentially. HMM introduces an external additive bypass that provides a non-recursive shortcut, preserving a constant-rank Jacobian component regardless of sequence length.
  • Cross-Task Generalization: Unlike other long-context Mamba adaptations that rely on training-free heuristics or task-specific fine-tuning, HMM achieves cross-task generalization through parametric learning of the working memory module.

Key Results

HMM significantly outperforms vanilla Mamba2 and other competitive long-context variants (like LongMamba and MambaExtend):

  • Reasoning Accuracy: On LongBench-E, HMM achieved the highest average accuracy among Mamba variants, reaching 20.40% on the 780M model scale and 22.50% on the 1.3B scale.
  • Passkey Retrieval: HMM boosted exact retrieval success by 34.3% to 37.1% compared to vanilla baselines, maintaining strong recall even at 64k context lengths.
Passkey retrieval accuracy heatmaps comparing vanilla Mamba2 with HMM.
  • Efficiency: The architecture achieves these gains while adding only ~2% extra parameters and maintaining the exact same peak GPU memory footprint as the baseline Mamba2 model during inference.

Limitations and Future Work

The authors note that HMM is designed to improve semantic accessibility rather than fine-grained, exact factual retrieval over massive external databases (such as legal or regulatory document analysis). For tasks requiring pinpoint accuracy across millions of tokens, the current segmentation and top-$K$ retrieval mechanisms might still fall short.

Future work will focus on refining the segmentation strategies, enhancing the retrieval modules, and extending the framework to better support strict, exact-fact retrieval tasks.

Summary updated

BibTeX
@misc{wang2026mamba,
  author = {Qinwen Wang and Jieping Luo and Aoxiang Qin and Ruoyu Zhao and Jianxiong Tang and Wei Zhang and Zhichao Lu and Luziwei Leng},
  title = {{Mamba with Hierarchical Memory: Solving Representation Bottleneck in Long Sequence Modeling}},
  year = {2026},
  eprint = {2608.02347},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2608.02347},
}
Figure