TL;DR
Reading a massive book doesn't mean giving every page equal focus—yet standard Large Language Models (LLMs) either waste effort skimming every single word or force themselves to pick a rigid, arbitrary number of pages to read closely. DashAttention introduces a fully differentiable, two-stage sparse attention mechanism that dynamically chooses how many chunks of text to inspect based on the complexity of the query. It matches the accuracy of full attention while skipping 75% of the context, running up to 3.36× faster than FlashAttention-3.
What Problem Does This Paper Address?
Processing long contexts in LLMs presents a tug-of-war between selectivity and flexibility. Standard dense softmax attention looks at every token, assigning nonzero probability everywhere. Over tens of thousands of tokens, this causes dispersion—the model’s focus spreads too thin, diluting important signals with noise and driving up compute costs.
To fix this, recent hierarchical sparse methods (like NSA and InfLLMv2) divide the context into blocks, score them coarsely, and apply fine-grained attention only to the top-$k$ blocks. While faster, hard top-$k$ routing introduces two major flaws:
- Rigid budgets: Every query is forced to read the exact same number of blocks ($k$), wasting compute on easy queries and starving complex ones.
- Broken gradients: Top-$k$ is discontinuous, severing the gradient path between the fine-grained token reading stage and the coarse block-selection router. The router can't directly learn from downstream mistakes.
Methods
DashAttention replaces the rigid top-$k$ switch with a smooth, adaptive, end-to-end differentiable pipeline built across three stages, implemented via three custom fused GPU kernels in Triton:
- Stage 0: Local Chunk Summarization (New). Instead of simple mean-pooling or heavy MLPs, each chunk of $B$ tokens is summarized using local attention driven by a learned query vector initialized at zero. Training starts cleanly as uniform mean-pooling and gradually learns to extract richer summaries.
- Stage 1: Entmax Block Routing (New). Queries attend to chunk summaries using $\alpha$-entmax—a sparse cousin of
softmaxthat naturally outputs exact zeros for irrelevant items. Depending on the geometry of the scores, $\alpha$-entmax dynamically selects a variable number of chunks per query, head, and layer. - Stage 2: Prior-Induced Sparse Softmax (Hybrid). Standard
softmaxattention runs only on the surviving chunks (plus immediate local diagonal tokens), making it compatible with FlashAttention. Crucially, the coarse probabilities from Stage 1 are injected as log-prior biases into Stage 2's attention logits. This keeps the entire hierarchy differentiable from end to end.
Datasets
No new datasets are introduced. For continual long-context pretraining and supervised fine-tuning (SFT), the authors use the InfLLMv2-5B dataset and the MiniCPM-4 dataset.
Evaluations span two categories:
- Long-context benchmarks: RULER (up to 128K tokens) and HELMET.
- Short-context general benchmarks: MMLU, MMLU-Pro, CSQA, IFEval, HellaSwag, GSM8K, MATH, DROP, MBPP, and HumanEval.
Key Insights and Ideas
- Preventing "stealth" dispersion in GQA: Modern LLMs use Grouped-Query Attention (GQA), averaging scores across query heads that share Key-Value heads. The authors prove theoretically that averaging dense softmax heads before top-$k$ selection re-introduces attention dispersion, leading to noisy block choices. Averaging sparse $\alpha$-entmax distributions preserves concentration.
- Emergent budget allocation: Without any manual tuning per layer, DashAttention naturally learns to keep early network layers denser (broadly gathering context) while making middle layers much sparser—automatically rediscovering heuristics that prior works had to hard-code.
- Train sparse, infer dense (if you want): Because Stage 2 is just prior-biased softmax, a DashAttention-trained model can seamlessly run standard, unrouted FlashAttention at test time—and actually outperforms models trained natively with full attention, likely because sparse training acts as a denoiser.
Key Results
Tested on MiniCPM-4 (1B, 3B, 8B) and a hybrid 4B Tiny-Aya-Base architecture:
- Near-lossless sparsity: At ~75.7% sparsity on RULER-16K, the 8B DashAttention model scores 83.6%, nearly matching Full Attention (85.3%) and decisively beating InfLLMv2 (78.9%) and NSA (55.0%).
- High-sparsity resilience: At ~90% sparsity on HELMET, DashAttention retains 39.4% accuracy, outperforming InfLLMv2 by 9 percentage points and NSA by 19 percentage points. It also leads sparse baselines when extrapolated to 128K context (39.0% at 95.3% sparsity vs. Full Attention's 39.5%).
- Hardware speedups: By packing active blocks into bitmasks and avoiding explicit top-$k$ sorting/indexing overhead, DashAttention achieves up to 3.09× prefill speedup and 3.36× decoding speedup over FlashAttention-3 (and up to 1.35× faster than InfLLMv2).
Limitations and Future Work
While the standalone Triton kernels are fast, the authors note that DashAttention has not yet been integrated into production LLM serving engines like vLLM or SGLang, leaving full end-to-end serving integration for future work.
Summary updated