Match each sparse attention pattern to its design and exemplar architecture.
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Sparse attention patterns differ in which slice of the n × n grid they compute: diagonal band, strided band, band plus VIP tokens, or block structured.
Picture a huge grid asking, for each word, which other words it should look at. The standard kernel fills the whole grid. Sparse attention keeps most of the grid blank to save effort, and different designs pick different shapes to keep. A narrow band along the diagonal lets each word peek at nearby neighbors only, like reading with a small window. A strided band skips some neighbors but reaches further. A band plus a few full rows treats a handful of words as VIP guests everyone gets to talk to. Chunked patterns slice the sequence into groups and only check inside each group plus a few cross-links. Same idea everywhere, different geometry.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
Walk each pattern with geometry, per-layer reach, and exemplar; explain BigBird's universal approximator motivation for global tokens; discuss why frontier LLMs use FlashAttention + ring + YaRN instead of heavy sparsity now.
| Pattern | Geometry | Single layer reach | Exemplar |
|---|---|---|---|
| Sliding window | Diagonal band, width W | W tokens | Mistral 7B (W=4096) |
| Dilated | Strided band | W × stride | Longformer dilated heads |
| Global + local | Band + a few full rows/cols | Effectively n (via globals) | BigBird, Longformer |
| Block sparse | Dense blocks + sparse cross-block | n via cross-block pattern | Sparse Transformer, GPT-3 ablations |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Conflating 'sparse attention' with 'efficient attention', sparse attention is one family (approximate, fewer pairs computed); FlashAttention is exact (same pairs, different I/O). They're different layers of the stack.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.