Learned Sparse Attention: Mechanisms and Applications
- Learned Sparse Attention mechanisms are designed to reduce irrelevant interactions by learning which parts of the input are relevant to a particular task. This is achieved using various methods such as exact-zero normalizers, differentiable permutations, and sparse routing over experts.
- Applications of Learned Sparse Attention include autonomous driving, language modeling, and graph-based tasks. For example, Adaptive Spare Hyperlayers apply to spatial attention mechanisms for cluttered MNIST, and MoSA treats each attention head as an expert, selecting tokens based on learned routers for efficiency.
- Methods like Smart Bird and Sparsifiner have shown that learned sparse attention can significantly improve computational efficiency and performance on various benchmarks. Smart Bird performs sampling at a low dimension and Sketched Transformers applied this for agile sampling and reduced time complexity.
Learned sparse attention is a family of attention mechanisms in which the support, connectivity, normalization, or computational routing of attention is determined by learned representations or task-dependent signals rather than by a permanently dense interaction pattern. Depending on the method, sparsity may arise from exact-zero normalizers such as sparsemax, learned binary edge gates, content-dependent block or token selection, differentiable permutations, sparse routing over experts, or learned mixtures of global and local branches. The central objective is to reduce irrelevant query–key interactions while preserving task-relevant information, although “learned” encompasses distinct regimes ranging from end-to-end trainable sparse architectures to post-training calibration and inference-time approximation.
1. Conceptual foundations and taxonomy
Standard softmax attention assigns a positive weight to every available key. For query , key matrix , and value matrix , the usual operation is
Its dense support provides maximal pairwise connectivity but entails quadratic interaction growth for sequence length . Learned sparse attention instead constructs an input-, query-, head-, layer-, or task-dependent support set and evaluates attention only over selected interactions, or uses a sparse normalization whose output contains exact zeros.
The principal dimensions along which methods differ are:
| Dimension | Alternatives |
|---|---|
| Selection unit | Individual token, edge, block, spatial region, graph edge, expert-selected token set |
| Learning regime | Joint end-to-end training, distillation, calibration, inference-time heuristic |
| Sparsity structure | Unstructured, local, block-sparse, permutation-induced, global–local hybrid |
| Attention normalization | Softmax over a sparse support, sparsemax, entmax, ReLU, binary or gated aggregation |
| Execution strategy | Dense masked kernels, sparse gather, indexed attention, block-sparse kernels, specialized routing |
A strict distinction is required between sparse attention weights and sparse attention computation. ReLU attention produces exact-zero weights but retains the token-wise score computation, whereas SeerAttention, Sparsifiner, and block-sparse methods seek to avoid computing or loading omitted regions. Conversely, a fixed sliding-window architecture may have sparse computation without learning its connectivity geometry. SparseCoder, for example, combines prescribed sliding-window attention with learned token pruning; its attention pattern is structured rather than fully learned (Yang et al., 2023).
A second distinction separates attention sparsity from token sparsity. Edge-level sparsity retains tokens while removing selected query–key interactions. Token pruning removes complete rows and columns of the attention matrix. Sparsifiner emphasizes that preserving a token can remain useful even when that token is unimportant to a particular query, whereas token pruning removes all of its possible interactions (Wei et al., 2023). VideoNSA likewise retains video tokens while routing each query through compressed, selected, and local representations (Song et al., 2 Oct 2025).
2. Sparse normalization and differentiable selective attention
One early route to learned sparse attention replaces softmax with a normalization or activation capable of producing exact zeros.
Sparsemax and entmax
Sparsemax maps a score vector onto the probability simplex:
where is chosen so that the nonzero entries sum to one. The support is therefore
Unlike softmax, sparsemax can eliminate low-scoring positions exactly while preserving a probability-distribution interpretation. Its adaptive support is an implicit top- operation: the number of selected positions is determined by the threshold rather than fixed in advance.
“Aggregated Sparse Attention for Steering Angle Prediction” applies sparsemax to spatial VGG16 features for autonomous-driving steering prediction. The attention distribution is learned from the steering objective rather than gaze supervision, and it commonly concentrates on lane markings, road boundaries, and other steering-relevant geometry. The architecture uses a frozen VGG16 feature extractor, sparse attention conditioned on an LSTM state, temporal modeling, and a two-layer regression head. Three independently initialized sparse models are trained and their steering predictions averaged. Aggregated sparse attention outperforms the reported no-attention and soft-attention comparisons, with the strongest findings concerning smoother predictions, diverse attention supports, and improved robustness (He et al., 2018).
Sparsemax is piecewise linear and differentiable almost everywhere, but its support changes introduce nondifferentiable boundaries. The steering study attributes sensitivity to random initialization to sparsemax’s support behavior and exploits this variability through model-level aggregation. No explicit sparsity penalty or gaze loss is required; sparsity arises from the normalization function.
Adaptive 0-entmax generalizes the continuum between softmax and sparsemax. It satisfies
1
and
2
Intermediate values, such as 3, produce partial sparsity. In Transformer ASR, each attention head or module learns its own sparsity parameter. Early encoder layers tend to remain closer to softmax, while later layers can become more selective. Adaptive entmax outperforms fixed sparsemax, fixed 4-entmax, and temperature-scaled softmax on the reported AISHELL-1, WSJ, and LibriSpeech experiments. On AISHELL-1, the proposed system improves test CER from 5 for the Transformer baseline to 6; on WSJ eval93, it improves WER from 7 to 8 (Zhao et al., 2022).
Rectified Linear Attention
Rectified Linear Attention (ReLA) replaces softmax with an elementwise ReLU:
9
The resulting output is not a probability distribution. Attention weights need not sum to one, and an entire query row can become zero when all query–key scores are nonpositive. This permits null attention, in which a head switches off for a query.
Because unnormalized ReLU outputs have variable magnitude, ReLA uses RMSNorm and either specialized initialization or a learned gating function. In the reported machine-translation experiments, ReLA achieves translation quality comparable to softmax and entmax while avoiding the sorting or support-selection procedures associated with sparsemax and entmax. On WMT14 English–German, ReLA-0 obtains 1 SacreBLEU versus 2 for softmax, but is substantially faster than the tested sparsemax and entmax implementations. ReLA also produces high sparsity, greater measured head diversity, improved reported source–target alignment, and query-dependent null attention (Zhang et al., 2021).
ReLA’s efficiency advantage is primarily operational rather than asymptotic: it replaces the activation and normalization while retaining token-wise query–key interactions. It does not by itself eliminate the quadratic score matrix. Its observed gains cannot therefore be attributed exclusively to sparse support; normalization, activation scale, gating, and null-attention behavior also change.
3. Learning sparse transformations, graphs, and permutations
A second family learns the connectivity structure itself rather than merely applying a sparse normalizer.
Adaptive sparse hyperlayers
“Learning sparse transformations through backpropagation” represents a sparse tensor by continuous proto-connections, associated values, and uncertainty parameters. Continuous locations are mapped to legal integer index-tuples, while deterministic local support, local random samples, and global random samples produce a sparse computation graph. The sampled topology is treated as fixed during a forward/backward pass, but the values attached to sampled edges remain differentiable functions of the continuous parameters.
This procedure distinguishes topology sampling from value sampling. Gradients do not pass through rounding, integer indexing, random tuple generation, or duplicate removal; they pass through the differentiable mixture values on the sampled graph. The method is used to construct an adaptive spatial attention mechanism for cluttered MNIST and a differentiable sorting system. In the attention experiment, a source network predicts bounding boxes, constructs spatial sampling grids, and routes selected image locations into glimpses. A one-glimpse model reports 3 error and an eight-glimpse model 4 error on cluttered MNIST-100, compared with 5 for the cited RAM result. The paper nevertheless notes that high classification accuracy does not guarantee object-level interpretability: a sparse transformation may select a discriminative subpart rather than a complete object (Bloem, 2018).
Sparse graph attention
Sparse Graph Attention Networks (SGAT) learn a binary gate 6 for each directed graph edge. The masked adjacency is
7
One gate and one normalized coefficient are shared across all GNN layers and attention heads, yielding a permanent edge-sparsified graph rather than a different sampled subgraph at every iteration. The model optimizes a supervised objective with an 8 penalty:
9
Because binary gates are nondifferentiable, SGAT uses a Bernoulli variational formulation and the hard-concrete reparameterization. At inference, the learned gates form a deterministic sparse graph.
On dense assortative graphs, SGAT removes approximately 0 of PPI edges and 1 of Reddit edges while retaining reported accuracies of 2 and 388.1\%493.9\%595.0\%691.9\%\operatorname{Attention}(q_i,K,V) = \operatorname{softmax}\left(\frac{q_iK^\top}{\sqrt d}\right)V.$7 pruning, and layer-specific subgraph generators. Its key properties are joint $\operatorname{Attention}(q_i,K,V) = \operatorname{softmax}\left(\frac{q_iK^\top}{\sqrt d}\right)V.$8 optimization, one shared graph pattern across layers and heads, and separate treatment of directed edges.
Learned permutations and sorting
Sparse Sinkhorn Attention learns a relaxed permutation of sequence blocks using a meta-sorting network and Sinkhorn normalization. Sequence blocks are pooled, assigned scores, and transformed into an approximately doubly stochastic matrix. Local attention is then applied after the learned block rearrangement. Distant tokens in the original sequence can become neighbors in the sorted coordinate system.
For a sequence of length $\operatorname{Attention}(q_i,K,V) = \operatorname{softmax}\left(\frac{q_iK^\top}{\sqrt d}\right)V.$9, block-level sorting produces an $L$0 assignment matrix, while local attention operates within sorted windows. The method therefore provides quasi-global connectivity with lower memory than dense attention. Causal Sinkhorn balancing modifies both the sorting network and the normalization procedure to prevent future information from influencing the learned ordering. SortCut further truncates the sorted sequence to a selected budget.
The method outperforms fixed local attention and is competitive with dense and hand-designed sparse Transformers in algorithmic sorting, language modeling, image generation, document classification, and natural-language inference. Its limitations include $L$1 sorting overhead, block granularity, temperature sensitivity, and the difficulty of causal normalization. The method demonstrates that learned sparse connectivity can be expressed as a learned reordering followed by ordinary local attention rather than as direct pairwise token selection (Tay et al., 2020).
4. Learned content-dependent routing and sparse support prediction
A more direct approach predicts the support of full attention from the current input.
Low-dimensional sketches and randomized token selection
Smart Bird uses a low-dimensional single-head Transformer to generate a sketched attention matrix. A learned transformation of its attention weights produces sampling scores
$L$2
For each query, random scores are sampled from $L$3, and the $L$4 largest are selected. Each attention head independently samples a sparse index matrix, producing head diversity. The high-dimensional Transformer then performs ordinary attention over only the selected tokens.
The method has complexity
$L$5
where $L$6 and $L$7. With $L$8, $L$9, and $z$0, the sketch remains quadratic in sequence length but is much cheaper than full-dimensional attention. Smart Bird reports the best results among the compared models on the stated classification, news-recommendation, and summarization benchmarks, including AG’s News, Amazon, IMDB, MIND, CNN/DailyMail, and PubMed. Its limitations are the remaining quadratic sketching cost and the absence of a documented differentiable relaxation for discrete top-$z$1 routing (Wu et al., 2021).
Vision Transformers
Sparsifiner predicts an instance-dependent binary attention mask for every image, layer, head, and query token. It first computes a low-rank attention approximation over learned basis representations, thresholds the basis coefficients, projects them back toward the original token dimension, and selects the top-$z$2 connectivity scores for each query. Full-dimensional attention is then evaluated only on the selected edges.
The method does not use the low-rank matrix directly for value aggregation. The low-rank module predicts the support, while the retained entries use ordinary full-rank attention. On DeiT-S, an attention keep rate of $z$3 reduces MHSA FLOPs from $z$4 to $z$5 MFLOPs while top-1 accuracy changes from $z$6 to $z$7. The reported operating range reduces MHSA FLOPs by approximately $z$8–$z$9 with accuracy degradation within $\operatorname{sparsemax}(z)_i=\max(z_i-\tau,0),$0, although these are FLOP estimates rather than universal wall-clock speedups. Unstructured sparsity requires suitable kernels and can incur irregular memory-access overhead (Wei et al., 2023).
Learned block routing for LLMs
SeerAttention learns block-level sparsity by pooling queries and keys along the sequence dimension, applying learned projections, and producing a block score matrix. For block size $\operatorname{sparsemax}(z)_i=\max(z_i-\tau,0),$1, it selects the top-scoring key blocks for every query block and invokes a block-sparse FlashAttention kernel.
Its gate is trained by self-distillation from dense attention. A two-dimensional max-pooled dense attention map serves as the target, and the gate minimizes an attention-map MSE objective. Post-training calibration updates only the gate, whereas long-context fine-tuning jointly updates the LLM and gate. At 32K, the paper reports perplexities of $\operatorname{sparsemax}(z)_i=\max(z_i-\tau,0),$2 for PG19/Proof-Pile at $\operatorname{sparsemax}(z)_i=\max(z_i-\tau,0),$3 sparsity after joint fine-tuning, compared with $\operatorname{sparsemax}(z)_i=\max(z_i-\tau,0),$4 for dense YaRN. At 128K, a block-sparse kernel achieves a reported $\operatorname{sparsemax}(z)_i=\max(z_i-\tau,0),$5 speedup over FlashAttention-2 at $\operatorname{sparsemax}(z)_i=\max(z_i-\tau,0),$6 sparsity, while end-to-end prefill for Llama-3.1-8B falls from $\operatorname{sparsemax}(z)_i=\max(z_i-\tau,0),$7 seconds to $\operatorname{sparsemax}(z)_i=\max(z_i-\tau,0),$8 seconds at the reported high-sparsity setting (Gao et al., 2024).
VideoNSA extends Native Sparse Attention to video-LLMs. It applies sparse routing to video tokens while retaining dense grouped-query attention for text. Its compression, selection, and sliding-window branches are combined using learned gates. The compression branch provides coarse global coverage, selection retains salient uncompressed blocks, and the local branch covers recent temporal context. VideoNSA is trained end to end on 216K video instruction examples and reports performance improvements across long-video, temporal, and spatial benchmarks, including a LongVideoBench score of $\operatorname{sparsemax}(z)_i=\max(z_i-\tau,0),$9, TimeScope score of $\tau$0, and LongTimeScope score of $\tau$1 (Song et al., 2 Oct 2025).
Mixture-of-experts routing over attention heads
Mixture of Sparse Attention (MoSA) treats each attention head as an expert. A router scores all tokens and selects exactly $\tau$2 per head:
$\tau$3
The selected tokens undergo ordinary attention, after which router-weighted outputs are scattered back to the original positions. Each sparse head has complexity $\tau$4 instead of $\tau$5. The method combines four dense heads with additional sparse heads to stabilize training and reinvest saved computation in increased head specialization.
At compute-matched settings, MoSA improves reported perplexity over dense baselines by $\tau$6 for Tiny, $\tau$7 for Small, $\tau$8 for Medium, and $\tau$9 for Large models. It also reduces KV-cache size by $\mathcal S(z)=\{i:z_i>\tau\}.$0–$\mathcal S(z)=\{i:z_i>\tau\}.$1 in the reported matched-perplexity comparisons. However, pure MoSA is difficult to train because routing and attention must bootstrap one another, and non-autoregressive top-$\mathcal S(z)=\{i:z_i>\tau\}.$2 routing requires adaptation for strict autoregressive generation (Piękos et al., 1 May 2025).
5. Training-free and post-training sparse attention
Not all adaptive sparse methods are learned in the strict end-to-end sense. Several infer sparse structure from pretrained attention or activation statistics.
Faster VGGT uses pooled query–key similarity and CDF/top-$\mathcal S(z)=\{i:z_i>\tau\}.$3 criteria to construct dynamic block masks for pretrained multi-view geometry transformers. It sparsifies patch-to-patch interactions while retaining all special-token interactions densely. The method requires no backbone retraining and obtains up to approximately $\mathcal S(z)=\{i:z_i>\tau\}.$4 faster inference with comparable task performance in the reported VGGT and $\mathcal S(z)=\{i:z_i>\tau\}.$5 experiments. Because the selector is not learned jointly with the backbone, the method is best classified as a post-hoc dynamic block-sparse approximation to an emergent attention pattern (Wang et al., 8 Sep 2025).
SparseD calibrates head-specific block patterns for diffusion LLMs from attention scores at a transition denoising step. It retains full attention during early denoising, when errors are particularly damaging, then reuses the selected block masks across later steps. The reported design combines isolated prefill and generation selection, block pooling, head-specific masks, and pattern reuse. At 64K context and 1,024 denoising steps, SparseD achieves $\mathcal S(z)=\{i:z_i>\tau\}.$6 speedup for Dream-7B-Instruct and $\mathcal S(z)=\{i:z_i>\tau\}.$7 for LLaDA-1.5, while maintaining near-dense benchmark quality. Its central assumption—that important block locations remain stable within a head over denoising steps—is empirical rather than guaranteed (Wang et al., 28 Sep 2025).
Adamas is a training-free, query-adaptive token selector. It applies a Hadamard transform to queries and keys, bucketizes transformed coordinates into four levels, stores keys in 2-bit codes, and ranks candidates using packed Manhattan distance. Exact full-precision attention is then computed over the selected original keys and values. The auxiliary representation is not a learned replacement for $\mathcal S(z)=\{i:z_i>\tau\}.$8; it is used only for candidate ranking. Adamas reports near-lossless LongBench quality with $\mathcal S(z)=\{i:z_i>\tau\}.$9–$k$0 selected tokens in several settings and up to $k$1 kernel-level self-attention speedup (Yan et al., 21 Oct 2025).
SpecAttn uses attention distributions produced by a draft model during speculative decoding to select tokens for the target model’s verification attention. KL-based offline layer alignment maps verifier layers to draft layers, and sorting-free top-$k$2 selection produces dynamic KV masks. At $k$3, it reports a $k$4 reduction in KV-cache access with a $k$5 relative perplexity increase on PG-19. At $k$6, the relative perplexity increase is $k$7 with a $k$8 KV reduction. The method remains heuristic and can weaken the exactness guarantees normally associated with speculative decoding (Shah, 31 Oct 2025).
JSSA calibrates a shared low-dimensional query–key subspace for each layer and KV head. It minimizes a query–key score-preservation objective through a tractable marginal upper bound whose solution is given by the top eigenvectors of the sum of normalized query and key second moments. Runtime selection occurs over all projected keys, but final attention uses the original full-dimensional keys and values. A gather-free indexed-attention kernel directly reads selected KV entries, supporting distinct selections under GQA.
JSSA remains close to full-KV accuracy on LongBench, RULER, and PG-19, and reports up to $k$9 decoding throughput at 128K context for GLM-4.7-Flash. Its limitations include calibration cost, the need for deployment-length activation statistics, an $K$00 projected-key scan, and dependence on specialized kernels. It is “learned” through calibrated activation statistics rather than gradient-based model training (Song et al., 13 Oct 2026).
6. Efficiency, evaluation, and unresolved issues
Computational efficiency
The computational claims of learned sparse attention vary substantially by method. Sparse normalization alone does not remove quadratic score computation. ReLA retains dense token interactions, while adaptive entmax changes support but not automatically the asymptotic attention cost (Zhang et al., 2021). Smart Bird retains a quadratic low-dimensional sketching term (Wu et al., 2021). SparseCoder obtains linear attention scaling from a fixed local window and gains additional reductions from token pruning, but its local pattern is architectural rather than fully learned (Yang et al., 2023).
Block sparsity is more directly compatible with hardware than unstructured token sparsity. SeerAttention, VideoNSA, Faster VGGT, SparseD, and Sparsifiner rely on block structure or hardware-aware kernels to convert omitted interactions into practical savings (Gao et al., 2024, Song et al., 2 Oct 2025, Wang et al., 8 Sep 2025, Wei et al., 2023). Token-level methods such as Adamas and JSSA can achieve finer selection, but their performance depends on compressed scoring, indexed memory access, and gather-free execution (Yan et al., 21 Oct 2025, Song et al., 13 Oct 2026).
Selection itself can become the bottleneck. HyScale addresses this training problem by treating sparse selection as a discrete index operation. HyTopK computes exact top-01 without materializing a dense score table, while selection replay reuses forward-pass indices during activation recomputation. On million-token sequences, the system reports a 02 training speedup for GLM-5.1, 03 for the CSA layers of DeepSeek-V4-Flash, and 04 for the QSA layers of Qwen3.8-Flash-Next (Deng et al., 23 Oct 2026).
Interpretability
Sparse supports can expose task-dependent structure, but support is not automatically a causal explanation. Steering models attend to lane markings and road geometry, SGAT identifies graph edges whose removal affects classification, and VideoNSA reveals branch and attention-sink behavior. Nevertheless, several supplied studies caution that attention maps and retained tokens do not establish causal faithfulness without intervention.
Interpretability is also affected by the granularity of selection. A block mask can include irrelevant tokens within a selected block; a token-pruning mask can remove evidence irreversibly; a sparse normalizer can identify support without proving that omitted features are causally unnecessary. Learned supports should therefore be evaluated with masking, deletion, insertion, perturbation, or counterfactual tests rather than visualization alone.
Accuracy–sparsity trade-offs
Across domains, moderate sparsity is often substantially safer than extreme sparsity. SeerAttention preserves quality at moderate block sparsity but degrades at 05 sparsity for some 128K evaluations. VideoNSA requires an appropriate allocation between global blocks and local windows. MoSA exhibits a U-shaped relationship in which excessive sparsity leaves each head with too few tokens. SGAT can over-prune informative graph edges when 06 is too large. Adaptive entmax outperforms sparsemax in ASR because exact sparsity can discard essential acoustic context.
A recurring result is that learned selection can outperform post-hoc pruning or fixed patterns when the support predictor is well aligned with the downstream objective. SGAT outperforms GAT top-07 pruning at high sparsity; Smart Bird outperforms deterministic top-08 selection; Sparsifiner outperforms direct low-rank attention at comparable MHSA complexity; and JSSA outperforms alternative low-dimensional selectors by optimizing query–key score preservation rather than independent key reconstruction.
Open problems
Several problems recur across the literature:
- Selection fidelity: low-dimensional, pooled, or draft-model selectors can miss rare but important interactions.
- Autoregressive causality: routing decisions must not depend on future tokens, complicating MoSA, Sinkhorn attention, and speculative methods.
- Dynamic execution: unstructured indices, per-head masks, and changing supports require kernels that avoid gather and scheduling overhead.
- Calibration and distribution shift: post-training methods can fail when context length, model behavior, denoising phase, or deployment domain differs from calibration.
- Sparsity allocation: optimal budgets may vary by head, layer, modality, query, task, context length, and phase of inference.
- Training scalability: when every query scores every prior token, selection can dominate long-context training even if sparse attention reads only a small subset.
- Evaluation beyond perplexity: long-context retrieval, reasoning accuracy, generation length, alignment, safety, and closed-loop control can respond differently to sparse approximations.
- Causal interpretation: sparse supports provide an operational explanation of what the model used, but not necessarily why the prediction was made.
- Joint model–hardware design: theoretical edge reduction is insufficient without measurements of memory traffic, kernel occupancy, indexing overhead, latency, and end-to-end throughput.
- Training versus post-training sparsification: methods such as VideoNSA and MoSA adapt the model to sparsity during training, whereas Adamas, SparseD, SpecAttn, JSSA, and Faster VGGT target pretrained models. The relative benefits depend on whether retraining is available and whether the deployed architecture supports specialized sparse kernels.
Learned sparse attention is therefore not a single algorithmic category but a spectrum of techniques for learning or inferring selective connectivity. Its strongest general principle is that attention should allocate computation according to task-relevant content rather than treating every available interaction identically. The most successful systems combine this principle with structural constraints—blocks, local windows, shared subspaces, expert capacity, modality partitions, or sparse kernels—that make the learned selection executable. The central unresolved question is not whether sparse patterns exist, but how to learn, validate, and execute them without sacrificing rare long-range information or allowing selection overhead to dominate the computation they are intended to save.