NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Unveiling Simplicities of Attention: Adaptive Long-Context Head Identification

Konstantin Donhauser, Charles Arnal, Mohammad Pezeshki, Vivien Cabannes, David Lopez-Paz, Kartik Ahuja · DOI

Introduction

As Large Language Models (LLMs) scale to context windows of 128k tokens and beyond, the computational and memory costs associated with the Key-Value (KV) cache and the quadratic complexity of attention mechanisms become significant bottlenecks. While previous research has identified that many attention heads exhibit "local" behavior—primarily attending to recent tokens and initial "sinks"—static pruning of these heads often degrades performance in tasks requiring specific long-range retrieval. This paper introduces Query-Adaptive Attention (QAdA), a novel approach that dynamically identifies which attention heads can bypass distant context on a per-token basis with minimal overhead.

Methodology: The QAdA Framework

The core of QAdA lies in its ability to predict, in real-time, whether a specific query requires information from the distant "bulk" of the context or can be satisfied by a local window.

1. The Attention Split

The attention mechanism is decomposed into two parts: a local window (comprising the most recent tokens and initial attention sinks) and the bulk (the remaining distant tokens).

Attention scores distribution: The bulk vs. local window.

2. Gaussian Approximation and Adaptive Switching

To avoid the $O(Td)$ cost of computing full attention scores for the bulk, QAdA models the distribution of distant keys as a Gaussian $\mathcal{N}(\mu_K, \Sigma_K)$. By leveraging the property that the expected sum of attention scores in the bulk follows a log-normal distribution, the model can estimate the "mass" of attention that would be allocated to the distant context using a closed-form prediction. This reduces the overhead to $O(d^2)$, which is negligible compared to full attention.

If the estimated bulk mass falls below a threshold $\tau$, the head is labeled "local" for that query, and the bulk is ignored. Otherwise, the head is treated as "long-context," and full attention is computed.

Experimental Evaluation

The researchers evaluated QAdA across several model families, including Llama 3-8B, Mistral-7B, and Qwen2-7B. Testing was conducted on benchmarks designed for long-context capabilities:

  • RULER: A benchmark for long-context retrieval and aggregation.
  • LongBench: A comprehensive suite of tasks including QA and summarization.
  • Long-Context GSM8k & MBPP: Modified reasoning tasks where few-shot examples are hidden within 10k+ tokens of irrelevant text.

Results and Discussion

QAdA demonstrates a significant improvement over static pruning methods. While static methods typically fail beyond 60-70% sparsity, QAdA maintains near-baseline performance even at 85-90% sparsity.

QAdA maintains performance at high sparsity levels and reveals the query-dependent nature of attention heads.

Key Insights

  • Query-Dependent Nature: The study reveals that many heads are not strictly local or long-context; their behavior varies depending on the specific query. Approximately 31.2% of heads vary between these states, necessitating an adaptive approach.
  • Pruning as a Denoiser: In certain models like Qwen, QAdA actually improved performance by filtering out irrelevant distant noise, allowing the model to focus more effectively on relevant local information.
  • Efficiency: QAdA consistently matched or outperformed "Oracle Static" methods, which represent the theoretical upper bound for fixed-head pruning.

Conclusion

QAdA provides a robust, mathematically grounded framework for adaptive attention sparsity. By identifying the "simplicities" in how attention heads interact with distant context, it paves the way for more efficient long-context LLM inference without sacrificing the ability to perform complex retrieval and reasoning tasks. Future work will focus on optimized CUDA implementations to translate these FLOP reductions into tangible wall-clock speedups.

Summary updated

BibTeX
@inproceedings{donhauser2025unveiling,
  author = {Konstantin Donhauser and Charles Arnal and Mohammad Pezeshki and Vivien Cabannes and David Lopez-Paz and Kartik Ahuja},
  title = {{Unveiling Simplicities of Attention: Adaptive Long-Context Head Identification}},
  booktitle = {SLLM @ ICLR},
  year = {2025},
  url = {https://openreview.net/forum?id=kQxAWOl1HK},
}
Figure