Summary
HiLS-Attention is a novel native sparse attention mechanism that enables ultra-long context modeling through end-to-end learnable chunk selection. Key contributions:
- Hierarchical factorization: Attention is decomposed into inter-chunk (chunk-level) and intra-chunk (token-level) softmax operations, making chunk selection differentiable under the language-modeling loss.
- Expressiveness-driven design: A learnable chunk summary derived from the first-order Taylor expansion of the full-attention chunk mass (Proposition 3.1), using landmark tokens and an entropy-calibrated bias term.
- Strong length extrapolation: Trained on only 8K context, HiLS extrapolates to 4M tokens (512×) with over 90% retrieval accuracy on needle-in-a-haystack tasks.
- Efficient inference: Constant per-token decoding latency and 13.5–15.7× speedup over full attention at 512K context on a single H800 GPU.
- Lightweight conversion: Full-attention models can be adapted with ≤50B continued-training tokens, preserving short-context performance while surpassing full attention on long-context benchmarks.
Introduction and Theoretical Foundation
Modern LLMs require long-context modeling but full attention suffers from quadratic complexity, poor length extrapolation, and growing KV cache costs. Chunk-wise sparse attention offers a constant cost per token, but existing methods (e.g., NSA, DashAttention, InfLLMv2) fail to match full attention because of inaccurate chunk selection. The core problem lies in using non-parametric chunk summaries (e.g., mean pooling) that have limited expressiveness and are not optimized end-to-end. The authors show that mean-pooled keys approximate the mean of token-level logits, but the true chunk mass is a LogSumExp function whose behavior depends on the logit distribution:
This mismatch causes important chunks to be missed, especially in long-context retrieval tasks. The paper motivates two desiderata: trainable chunk summaries that are both expressive and end-to-end optimized.
Methodology
1. Surrogate Chunk Mass (Proposition 3.1)
The LogSumExp chunk mass is linearized via a first-order Taylor expansion around a learned query :
where
is an attention-weighted key summary, and is the entropy of the distribution, which interpolates between the two regimes of Eq. (5). is obtained by appending a landmark token to each chunk.
2. Hierarchical Softmax
To make learnable end-to-end, the attention weight is factorized as:
where with , and normalizes over selected chunks and the sliding window. This allows gradients from the LM loss to directly supervise chunk retrieval.
3. Practical Enhancements
- Low-Rank Query Calibration (Q-Cal): to better align queries for chunk-level scoring.
- GQA adaptation: Maximum of chunk scores over heads in a group to select shared chunks.
- Hardware kernel: Groups adjacent queries and computes attention over the union of their selected chunks, achieving Tensor Core utilization with .
Empirical Validation / Results
Small-scale (345M, 8K training)
Table 1: Perplexity across context lengths
| Model | 64 | 128 | 512 | 8K | 32K | 128K | 512K |
|---|---|---|---|---|---|---|---|
| Full-Attn RoPE | 33.92 | 26.89 | 18.68 | 4.96 | >10² | >10² | >10² |
| NSA-RoPE | 34.15 | 27.11 | 18.85 | 5.01 | 7.62 | 11.75 | 19.14 |
| HiLS-Attn-HoPE | 33.97 | 26.91 | 18.65 | 4.94 | 4.34 | 4.71 | 5.95 |
Table 2: RULER average exact match (%)
| Model | 8K | 16K | 32K | 128K | 512K | 1M | 2M | 4M |
|---|---|---|---|---|---|---|---|---|
| Full-Attn HoPE | 78 | 72 | 31 | 0 | 0 | – | – | – |
| HiLS-Attn-HoPE | 89 | 86 | 88 | 85 | 85 | 83 | 78 | 76 |
HiLS is the only native sparse method achieving in-domain NIAH performance comparable to full attention, and it extrapolates to 4M with 90%+ retrieval accuracy.
Long-context scaling (345M, 256K training)
Table 3: Perplexity (256K training)
| Model | 8K | 32K | 128K | 256K | 512K | 1M |
|---|---|---|---|---|---|---|
| Full-Attn RoPE (θ=1e7) | 9.11 | 8.86 | 8.11 | 7.49 | 7.54 | 8.61 |
| HiLS-Attn-HoPE (θ=1e7) | 9.08 | 8.88 | 8.15 | 7.45 | 7.37 | 8.08 |
HiLS outperforms full attention even at 1M context, and achieves substantially better variable tracking (VT) scores.
7B continued pretraining (from Olmo3-7B)
Table 9: Downstream tasks (selected)
| Benchmark | Olmo3-Base | HiLS-Attn-HoPE |
|---|---|---|
| RULER (avg) | 3.75 | 97.42 |
| MMLU | 59.90 | 56.58 |
| GPQA | 29.29 | 34.34 |
| Average (all tasks) | 43.88 | 43.35 |
Table 11: LongBench-v1 overall score
| Method | Score |
|---|---|
| Olmo3-Base | 29.0 |
| Olmo3-512swa-CPT + YaRN | 31.7 |
| HiLS-Attn-HoPE | 33.2 |
HiLS-Attention surpasses strong baselines (including YaRN-extended full attention) on LongBench while maintaining comparable general performance.
Inference Efficiency
Figure 6 shows HiLS-Attention achieves parity with full attention at ~16K context and is 13.5×/15.7× faster (prefill/decode) at 512K context.
Theoretical and Practical Implications
- Theoretical: The paper establishes a formal connection between chunk-level attention mass (LogSumExp) and a linearizable surrogate (Eq. 7), showing that an effective chunk summary must capture both the attention-weighted key mean and the entropy of the intra-chunk distribution.
- Practical: HiLS-Attention breaks the usual efficiency-performance trade-off: it is both more efficient and more effective than full attention on long-context tasks. Its strong extrapolation ability (512× training length) opens a practical path toward infinite-context training by learning retrieval patterns in short contexts and generalizing them.
- Conversion: Full-attention models can be cost-effectively converted with ≤50B tokens and frozen base parameters, enabling seamless adoption.
- Hardware alignment: The query-packing kernel design makes HiLS efficient even with small GQA group sizes, overcoming limitations of prior sparse attention kernels.
Conclusion
HiLS-Attention introduces a hierarchical softmax + expressiveness-enhanced chunk summaries that enables native sparse training with end-to-end retrieval learning. Comprehensive experiments (345M to 7B) show it matches or surpasses full attention in in-domain performance, provides unprecedented length extrapolation (up to 512×), and yields substantial inference speedups. The approach is compatible with continued pretraining of existing models. Limitations include lack of context parallelism support and incomplete understanding of the Q-Cal mechanism. Future work includes scaling training to ultra-long contexts and improving theoretical understanding of the extrapolation source.
Related papers
- ELDR: Expert-Locality-Aware Decode Routing for PD-Disaggregated MoE Serving
ELDR reduces median decode latency by 5.9–13.9% via expert locality routing, grouping requests by prefill-predicted expert activations.
- ReFreeKV: Towards Threshold-Free KV Cache Compression
ReFreeKV achieves near-lossless KV cache compression across diverse inputs without pre-defined budgets, using a universal 1% Frobenius norm threshold.
- Embodied.cpp: A Portable Inference Runtime of Embodied AI Models on Heterogeneous Robots
Embodied.cpp unifies VLA and world-action model deployment on edge devices, achieving 100% success rates and 71.8% memory reduction via modular multi-rate execution.