What is block-sparse attention?

Definition

Block-sparse attention groups tokens into contiguous blocks and selects which blocks should interact. Computation is performed only for the selected block pairs, avoiding a large number of individual token comparisons. Block-level operations also map efficiently to matrix hardware, which can make the theoretical reduction useful in real deployments.

Different implementations use fixed local blocks, global blocks, learned relevance scores, or a hybrid pattern. The method is well suited to long sequences, but its usefulness depends on selecting blocks that contain the necessary context. Coarse blocks may include irrelevant tokens, while aggressive pruning may exclude an important passage.

Frequently asked questions

How does block-sparse attention select context?

It first groups tokens into blocks, then applies a fixed or learned rule to choose which blocks participate in attention for a given query.

Why use blocks instead of selecting individual tokens?

Block operations are easier to execute efficiently on modern accelerators and reduce indexing overhead, although they provide a coarser selection boundary.

Videos explaining block-sparse attention