IndexCache: Accelerating Sparse Attention via Cross-Layer Index Reuse

Yushi Bai, Qian Dong, Ting Jiang, Xin Lv, Zhengxiao Du, Aohan Zeng, Jie Tang, Juanzi Li

TL;DR

IndexCache significantly accelerates long-context LLM inference by exploiting the fact that different layers in a transformer often attend to the same tokens. By computing sparse attention indices at only a fraction of layers and reusing them elsewhere, the authors achieve up to a 1.82× prefill speedup and 1.48× decode speedup with negligible loss in model quality.

What Problem Does This Paper Address?

As Large Language Models (LLMs) move toward "agentic" workflows requiring massive context windows, the quadratic cost of standard self-attention ($O(L^2)$) becomes a brick wall. Sparse attention mechanisms, like DeepSeek Sparse Attention (DSA), solve this by using a lightweight "indexer" to select only the top-$k$ most relevant tokens for each query, reducing the core attention cost to $O(Lk)$.

However, there is a hidden catch: the indexer itself still performs a quadratic operation to score all tokens. As context length grows, this "lightweight" module starts to dominate the total latency. Profiling a 30B model reveals that at 200K tokens, the indexer accounts for a staggering 81% of prefill time.

The indexer's share of latency grows sharply with context length.

Methods

The authors introduce IndexCache, which partitions model layers into Full (F) layers (which run their own indexers) and Shared (S) layers (which simply reuse the indices from the nearest preceding Full layer). They propose two ways to optimize this:

  1. Training-free IndexCache: Designed for off-the-shelf models. Instead of simple uniform skipping (e.g., keeping every 4th layer), they use a greedy search algorithm. This algorithm evaluates the impact of removing specific indexers by measuring Language Modeling (LM) loss on a small calibration set, identifying "critical" layers that must retain their indexers to maintain performance.
  2. Training-aware IndexCache: For models undergoing training or fine-tuning, they introduce a multi-layer distillation loss. This trains a single indexer to predict a "consensus" set of top-$k$ tokens that are useful for all the layers it serves, rather than just its own.

Datasets

The researchers evaluated IndexCache on a 30B DSA model and the production-scale 744B GLM-5 model. They used a variety of benchmarks to ensure no loss in capability:

  • Long-Context: MRCR v2, GraphWalks, LongBench v2, RULER, and AA-LCR.
  • General & Reasoning: AIME 2025, GPQA-Diamond, LiveCodeBench v6, and IFBench.
  • Calibration: SFT (Supervised Fine-Tuning) data was used for the greedy search and distillation processes.

Key Insights and Ideas

  • Cross-Layer Stability: The "aha moment" is the empirical verification that adjacent layers in sparse models select 70-100% of the same tokens. This redundancy means most indexer computations are simply doing the same work over and over.
  • Not All Layers are Equal: A key finding is that uniform interleaving (skipping indexers at regular intervals) performs poorly. The greedy search reveals a clear distinction between "easy" layers and "critical" layers (often in the early or transitional parts of the network) that are highly sensitive to indexer removal.
  • Distillation as a Centroid: Mathematically, the authors prove that their multi-layer distillation loss is equivalent to training the indexer against the average attention distribution of all layers it serves. This allows even simple uniform patterns to match full-model accuracy when trained appropriately.

Key Results

IndexCache delivers impressive efficiency gains without sacrificing the "intelligence" of the model:

  • Computation Reduction: It can remove up to 75% of indexer computations.
  • End-to-End Speedup: On a 30B model at 200K context, it achieves a 1.82× speedup in prefill and a 1.48× speedup in decode throughput.
  • Performance Parity: On the 744B GLM-5 model, IndexCache (1/2 retention) maintained nearly identical performance across long-context and reasoning tasks while providing a ~1.2× end-to-end speedup.
Figure 1: Benchmark comparison between GLM-5 and GLM-5 + IndexCache. IndexCache removes 50% of indexer computations while maintaining comparable performance across both long-context and reasoning tasks, delivering ∼1.2× end-to-end speedup.
Detailed relative speedup across different context lengths.

Limitations and Future Work

While highly effective, the paper notes a few areas for further exploration:

  • Extreme Sparsity: When pushing to 1/8 indexer retention (removing 87.5% of indexers), the training-free version begins to show non-negligible degradation in long-context tasks, though reasoning remains robust.
  • Static Patterns: The current patterns are fixed after search/training. Future work could explore dynamic index reuse, where the model decides on-the-fly whether a new index is needed based on the current hidden states.
  • Architecture Specificity: The study focuses on DeepSeek-style sparse attention; applying these principles to other sparse variants (like block-sparse or sliding window) remains an open research direction.

Summary updated

BibTeX
@inproceedings{bai2026indexcache,
  author = {Yushi Bai and Qian Dong and Ting Jiang and Xin Lv and Zhengxiao Du and Aohan Zeng and Jie Tang and Juanzi Li},
  title = {{IndexCache: Accelerating Sparse Attention via Cross-Layer Index Reuse}},
  booktitle = {COLM},
  year = {2026},
  url = {https://openreview.net/forum?id=74886M5htU},
}
Figure