Near-Far Attention: Region-Aware Sparse Retrieval for Long-Context LLM Decoding
YuanShuo Wang, Jianchao Tan, Lei Gong, Teng Wang, Wenqi Lou, Xuehai Zhou
Abstract
Sparse attention reduces the cost of long-context decoding, but token selection introduces additional scoring and ranking overhead. Moreover, uniform page scoring overlooks differences in relevance between near and far context. We propose Near-Far Attention (NFA), which adapts retrieval to regional attention patterns while keeping candidate scoring lightweight. During prefill, the Lightweight Gate Estimator identifies regions that can be skipped during decoding, adding less than 1% to dense-prefill time. For the remaining regions, the Calibration-Free Subspace Extractor supplies compact features shared by page-level and token-level scoring without offline calibration. The Distance-Aware Two-Level Selector then scores near and far pages differently and jointly ranks candidate tokens under a shared budget. Evaluations across model families, parameter scales, and GQA/MLA architectures show aggregate task quality comparable to full attention. On Qwen3-8B at 512K context length, NFA achieves up to operator speedup and whole-model decoding speedup over FlashInfer, including selection overhead.
Create a lesson
Metadata
- Comments
- 7 pages, 8 figures
Related papers
Attention Temperature Confounds Zero-Shot Context Extension
Shared title terminologycs.LGRuben Navasardyan
Composing Independently Distilled Memory and Retrieval Policies for Long-Term Agents
Shared title terminologycs.LGGrigorii Davydenko, Artem Sakhno, Igor Pavlov et al.
QASparse: Query-Adaptive Sparse Attention with Tailored Budgets and Tokens
Shared title terminologycs.LGZhiyuan Chen, Zihao Yang, Quanjiang Li et al.
TrialAgentBench: Evaluating AI Agents for Clinical-Trial Analysis and Long-Horizon Drug-Development Decisions
Shared title terminologycs.LGBradley Segal, William Bolton, Philip Torr et al.
NeuroMotion: Aligning EEG to Discrete Motion Primitives for Continuous Motion Decoding
Shared title terminologycs.LGYi Liu, Qi Zhang, HaoLin Li et al.
Rewirable Circuits in Transformers with Loom Attention
Shared title terminologycs.LGDa Xiao, Qingye Meng, Shengping Li et al.