DashAttention: Differentiable and Adaptive Sparse Hierarchical Attention

Yuxiang Huang, Nuno Gonçalves, Federico Alvetreti, Lei Li, Xu Han, Edoardo Ponti, Andre Martins, Marcos Vinicius TrevisoNeurIPS 2026

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:

  1. Rigid budgets: Every query is forced to read the exact same number of blocks ($k$), wasting compute on easy queries and starving complex ones.
  2. 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:

Figure 1: High-level overview of DashAttention. Stage 0 builds chunk summaries by local SDPA; Stage 1 routes with α-entmax to obtain an adaptively sparse support; Stage 2 refines at token resolution with a softmax whose logits are biased by di,j, derived from the router weights, maintaining full differentiability and FlashAttention compatibility. See Section 3 for details.
  • 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 softmax that 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 softmax attention 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

Abstract

Current hierarchical attention methods, such as NSA and InfLLMv2, select the top-$k$ relevant key-value (KV) blocks based on coarse attention scores and subsequently apply fine-grained softmax attention on the selected tokens. However, the top-$k$ operation assumes the number of relevant tokens for any query is fixed and it precludes the gradient flow between the sparse and dense stages. In this work, we propose DashAttention (Differentiable and Adaptive Sparse Hierarchical Attention), which leverages the adaptively sparse $\alpha$-entmax transformation to select a variable number of blocks according to the current query in the first stage. This in turn provides a prior for the second-stage softmax attention, keeping the entire hierarchy fully differentiable. Contrary to other hierarchical attention methods, we show that DashAttention is non-dispersive, translating to better long-context modeling ability. Experiments with large language models (LLMs) show that DashAttention achieves comparable accuracy as full attention with 75% sparsity and a better Pareto frontier than NSA and InfLLMv2, especially in high-sparsity regimes. We also provide an efficient, GPU-aware implementation of DashAttention in Triton, which achieves a speedup of up to $3.3\times$ over FlashAttention-3 at inference time. Overall, DashAttention offers a cost-effective strategy to model long contexts.
BibTeX
@inproceedings{huang2026dashattention,
  author = {Yuxiang Huang and Nuno Gonçalves and Federico Alvetreti and Lei Li and Xu Han and Edoardo Ponti and Andre Martins and Marcos Vinicius Treviso},
  title = {{DashAttention: Differentiable and Adaptive Sparse Hierarchical Attention}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=axGCEGSg4a},
}
Figure