The observation: most of the attention is zero
Researchers looked at the attention matrices of trained Transformers. Surprise: the overwhelming majority of attention weights are close to zero.
Each token really listens to only a small fraction of the others. The rest of the computation? Wasted. It's as if, in a room of 1000 people, each person only listened to a few dozen voices. Why compute the interaction of each person with all 999 others?
Remember the complexity of standard attention: in memory and compute, where is the sequence length. For 4096 tokens, that's ~16 million interactions (4096 × 4096). For 16K tokens, ~256 million. For 1M tokens, a trillion. Sparse attention (a matrix that is mostly zeros you never compute) starts from a simple observation: why compute millions of interactions if most are useless?
The idea: connect strategically
Instead of O(L^2) computed pairs, compute just the relevant ones. But which ones? You need predefined connectivity patterns.
Three patterns emerge from empirical observations:
-
Local: a token looks at its close neighbors. This is natural (in language, nearby words often have the most interaction ("the black cat") "black" mostly needs to see "cat"). Think of it as conversations between neighbors in a neighborhood.
-
Global: certain special tokens (such as CLS and SEP, the classification and separator markers that BERT inserts into its inputs) have the right to see and be seen by everyone. These are the "megaphones" of the sequence, they aggregate and broadcast global information. Without them, distant tokens could never communicate.
-
Random: a few long-range connections drawn at random. This might seem weird, but it's crucial to ensure information can travel from one end of the sequence to the other. It's the "small world" principle from graph theory: a few random shortcuts are enough to connect a network.
Longformer: three types of attention combined
Longformer, developed by Allen AI, combines three attention mechanisms in each layer:
Longformer: The Long-Document TransformerLocal attention (sliding window): 512-token window. Each token sees its 256 neighbors before and 256 after. This is the foundation, most useful interactions are local.
Dilated attention: in addition to the contiguous window, the token skips ahead, keeping only one token out of every few, over a larger window. Like looking into the distance with binoculars: you don't see everything, but important distant elements become accessible without excessive cost.
Global attention: certain designated tokens (the CLS token for classification, question tokens in QA) have full attention, they see everything and are seen by everyone.

Result: complexity O(L * (W + G)) where W = window size, G = global tokens. If both are constant relative to L, you get linear complexity O(L). You go from quadratic to linear, that's a fundamental change.
Longformer processes 4K tokens (8x more than BERT-512) with comparable memory. On long document tasks (TriviaQA, WikiHop), it significantly outperforms baselines that truncate documents. Proof that seeing more context helps, even with restricted attention.
BigBird: rigorous theory
BigBird, developed by Google Research, formalizes sparse attention with random graph theory. The idea is to mathematically prove that sparse attention can be as expressive as full attention.
Big Bird: Transformers for Longer SequencesThree components:
- Local: window of size W around each token
- Global: designated tokens that attend to everyone
- Random: each token attends to R randomly drawn tokens in the sequence

Key theorem: this combination forms an "expander graph", a graph with the property that information can propagate from any node to any other in very few hops. Concretely, this means that despite sparsity, the model retains the same theoretical power as full attention for approximating any sequence function.
BigBird vs Longformer
| Aspect | Longformer | BigBird |
|---|---|---|
| Local | Yes | Yes |
| Global | Fixed tokens | Fixed tokens |
| Random | No | Yes |
| Dilated | Yes | No |
| Theory | Empirical | Rigorous (expanders) |
Adding randomness seems counterintuitive, but it's mathematically smart. In graph theory, a few random connections transform a local network into a "small world" network where each node can reach every other node in few hops. It's the same phenomenon as the "six degrees of separation" between humans: a few random links are enough to connect everyone.
Other notable approaches
Sparse Transformer (OpenAI, 2019): the pioneer. Combines local + strided attention (every tokens). Complexity O(L * sqrt(L)). The first demonstration that you could break the quadratic barrier without losing quality.

ETC (Extended Transformer Construction): introduces auxiliary "global" tokens that serve as communication hubs. Local tokens talk to globals, globals talk among themselves, and redistribute information, like a telephone relay network.
LongT5: local attention combined with "transient global attention" with dynamic segment summaries. Particularly effective for summarization tasks.
The big problem: GPU implementation
Theoretically, sparse attention should be ultra-fast. In practice? It's much more complicated.
Irregular patterns = chaotic memory accesses = GPUs hate them. GPUs are massive parallel compute machines, optimized for regular and predictable operations. When you tell the GPU "read positions 3, 17, 42, 891," it has to make lots of small scattered memory accesses, which kills performance.
The paradoxical result: Flash Attention on dense attention is often faster than poorly implemented sparse attention, even on sequences of several tens of thousands of tokens. Flash Attention avoids materializing the attention matrix in memory and perfectly exploits the GPU's memory hierarchy, which compensates for computing "too many" pairs.
GPUs are optimized for dense, regular operations. Sparse attention fragments operations into small irregular pieces. Without specialized, optimized kernels, sparse attention can be SLOWER than dense attention. It's a classic case where algorithmic complexity ( vs ) doesn't tell the whole story, hidden constants and hardware efficiency matter enormously.
Why it stopped dominating... until the 2026 comeback
With Flash Attention (hyper-optimized dense attention) and SSMs like Mamba (native linear complexity, no sparse pattern), sparse attention lost relevance for general-purpose LLMs for several years.
Niches where sparse attention stayed relevant:
- Encoders for long documents: classification or information extraction on documents of hundreds of pages
- Vision: images have natural 2D structure (a pixel mostly interacts with its spatial neighbors)
- Specialized domains: proteins (local interactions in the chain + 3D contacts), molecules, graphs
The comeback: DeepSeek V4 and hybrid compressed attention (April 2026)
Then, in April 2026, DeepSeek V4 resurrects sparse attention at the largest scale. The architecture alternates two kinds of layers:
- Compressed Sparse Attention (CSA): the K/V of every group of consecutive tokens are compressed into a single entry by a learned compressor, and each query then consults only the entries ranked most relevant by an indexer. It's sparse attention, but where the sparsity is learned rather than frozen into a pattern (local + global + random).
- Heavily Compressed Attention (HCA): much more aggressive compression, alternated with CSA layer by layer.
The result at 1M tokens, per the technical report: only 27% of the inference FLOPs per token and 10% of the KV cache compared to V3.2 (which used dense attention with MLA). A top-tier open model (1.6T parameters, mixture of experts) runs with sparse attention at the heart of its architecture, and claims the level of the best dense models at a fraction of the cost.
The classic sparse pattern (local + global + random) was frozen in advance. CSA learns where to compress during training. It's the same evolution computer vision went through, from the hand-crafted SIFT descriptor (Scale-Invariant Feature Transform, interest points defined by engineers) to features learned by convolutional networks: when the pattern becomes a model parameter instead of an engineering choice, quality leaps. Sparse attention may have lost the 2020-2025 battle of fixed patterns, but it is winning the 2026 one of learned compression.
Sparse attention showed that you don't need the full attention matrix, a revolutionary idea at the time. This intuition directly paved the way for Flash Attention (which never materializes the matrix, just blocks), SSMs like Mamba (implicit linear attention with fixed memory), and modern hybrid architectures. Sparse attention may have lost the practical battle, but it won the intellectual war.
The movement continues in September 2026 with DeepSeek V4.1-Flash, where sparse attention indices are shared across layers and the cache is projected once from a causal encoder: see the dedicated lesson.
1. BigBird adds a few randomly drawn connections on top of the local and global patterns. What are they for?
2. Why can sparse attention, which computes far fewer pairs, end up slower than dense attention like Flash Attention?
3. Longformer goes from quadratic to linear complexity. Thanks to what?
4. What sets DeepSeek V4's Compressed Sparse Attention apart from the classic sparse patterns of 2020?