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 5.49× operator speedup and 2.97× whole-model decoding speedup over FlashInfer, including selection overhead.
Figures & tables
Fig. 1: Observations on Qwen3-8B. (a) Retained attention mass relative to oracle TopK under a shared 32-coordinate budget; dots denote documents and diamonds denote means. (b) A representative example of the regional coverage differences between Avg and MinMax observed across profiled queries. (c) Regional attention patterns over contiguous query windows, summarized by median attention mass for each task and layer (F: far; N: near). Profiling settings are given in Section IV-A .
Fig. 2: Overview of NFA. (a) Prefill-time regional attention statistics determine per-layer skip flags, which remain fixed during decoding (1: skip; 0: compute). (b) Compact query and key representations are shared by both selection levels. (c) Region-specific page selection is followed by joint token ranking; selected and protected positions participate in full-dimensional attention.
Fig. 3: Qwen3-8B task quality: (a) LongBench v1 average; (b) LongBench v2 accuracy; (c) RULER scores across context lengths. Vertical dashed lines in (a) and (b) mark FullKV. Configurations are given in Section IV-A .
Method
S-Doc QA
M-Doc QA
Summ.
Few- shot
Syn.
Code
Avg.
Qwen3-32B (GQA; 16 tasks)
FullKV
40.88
47.73
27.47
59.61
59.25
16.20
42.37
Quest
36.13
38.96
27.20
49.53
51.88
26.51
38.26
JSSA
42.17
50.53
27.44
60.48
58.25
15.55
43.09
AsyncTLS
37.53
43.36
27.02
55.01
49.16
16.95
38.81
NFA
39.97
46.83
27.19
60.52
57.75
15.68
41.90
TABLE I: LongBench v1 scores across models. Categories average their constituent tasks; Avg. is the unweighted mean over 16 tasks. Bold and underlined values mark the best and second-best sparse methods; FullKV is the dense reference.
Fig. 4: NFA speedup over FlashInfer: (a) operator time including selection; (b) whole-model decoding. Dashed lines denote parity. Missing points exceed GPU memory capacity.
Fig. 5: Whole-model decoding latency of NFA, JSSA, Quest, and AsyncTLS on Qwen3-8B at batch size one with a total attention budget of 1024 tokens, including protected positions. Latency includes selection overhead. Lower is better.
Fig. 6: Gate ablation on Qwen3-8B. (a) Selection latency under forced skip states, normalized to no skip. (b) Threshold sensitivity at K2=1024 . Lines: HotpotQA F1 (Hot) and GovReport ROUGE-L (Gov), 200 examples each. Bars: all-layer L1+L2+attention latency per decode step on one 32K input per task at BS1. The dotted line marks the default τ=0.1 .
Fig. 7: Subspace ablation. (a) GLM average over HotpotQA/GovReport (200 examples each); all subsets use 32 NoPE coordinates. (b) Qwen3-8B scoring latency at 64K, gating disabled.
Fig. 8: NFA regional page selection versus single-pool Avg and MinMax on Qwen3-8B across RULER context lengths.