Block Sparse Attention with Log-Linear Complexity
AuthorsBohao Tang, Zhen Qin, Yuqi Pan, Zheng Li, Pengfei Liu
Resources
PISA makes long-context attention more scalable by hierarchically narrowing relevant key blocks instead of comparing every query with every block.
Key results
PISA block-selection latency speedup over BSA at 256K tokens
PISA block-selection latency speedup over BSA at 64K tokens
PISA block-selection recall against Full Attention reference blocks
PISA average retrieval accuracy for the 2.67B model across RULER task families and context lengths
Model scale used in long-context retrieval evaluation
Tokens used for initial pretraining across model scales
What the paper found
Researchers at ByteDance introduce PISA, or Pyramid Sparse Attention, to remove the quadratic bottleneck in block-sparse attention: conventional methods score every query against every key block, while PISA builds a mean-pooled key pyramid and performs coarse-to-fine Top-K routing with LogSumExp scores. Because each query evaluates only a bounded candidate set across O(log N) levels, selection scales as O(N log N) for prefill and O(log N) per decoding step. Fused Triton kernels avoid materializing the dense query-key score matrix, and a two-stage prefill kernel reuses key blocks across grouped-query attention heads. Across 418M, 1.47B, and 2.67B decoder models trained on 100B tokens, PISA matches block-sparse baselines on language modeling and commonsense reasoning while improving retrieval-oriented block selection: on a diagnostic using Full Attention references, Recall@8 reaches 90.95 percent versus 85.91 percent for BSA. After 10B tokens of continued pretraining at 16K context, PISA records a 62.80 percent average on the RULER needle-in-a-haystack suite for the 2.67B model, above BSA’s 54.99 percent, though below Full Attention’s 66.24 percent. Hardware measurements show the largest gains at long contexts: PISA is 2.86× faster than BSA at 64K tokens and 9.95× faster at 256K, demonstrating that hierarchical routing becomes advantageous as sequences grow.
Original abstract
Scaling language models to long contexts is limited by the quadratic cost of self-attention. Block sparse attention offers an efficient alternative, but selecting the retained blocks remains a bottleneck. Conventional block selection requires scoring all query-block pairs and therefore remains quadratic in sequence length. To address this issue, we propose PISA, a block-sparse attention mechanism that employs a pyramid Top-$K$ selection strategy. The main idea is to gradually narrow down the candidates across different levels, making it more efficient to find the most relevant keys. Specifically, we construct a coarse-to-fine hierarchy of keys and perform selection from the coarsest level. At each level, LogSumExp scoring is applied to a bounded candidate set to select candidates for the next finer level, continuing until the finest level is reached. Through pooling, we construct $O(\log N)$ levels of keys, yielding an overall complexity of $O(N\log N)$, where $N$ denotes the sequence length. We develop hardware-aware Triton kernels for both training and inference, fusing hierarchical routing and LogSumExp scoring without materializing the query-key score matrix. We further evaluate our method on language modeling tasks. Compared with the baseline, our method achieves comparable performance on benchmarks such as commonsense reasoning while delivering better results on retrieval tasks.
Read the original paperMore in Attention Mechanisms
Browse all 27 papers →Hard Sample-Conditioned Decorrelated Attention for Robust Face Recognition
Tahar Chettaoui, Guray Ozgur, Eduarda Caldeira, Naser Damer, Fadi Boutros
ViT-HarDis encourages attention heads to specialize more on difficult face samples, improving recognition without extra inference cost.
Muir: Linear Attention with Sensitivity-Allocated Gating and Matched-Filter Readout
Tushaar Gangavarapu, Gil Tabak, Clemens JS Schaefer
Muir redesigns linear attention’s gates and readout to improve language-model quality and long-context retrieval while preserving efficient training and inference.
Training Vision Transformers to Focus: Emergence of Spatial Attention Head Specialization
Yuji Nozawa, Yu-Chieh Lin, Youyang Ng
The method encourages Vision Transformers to develop distinct, spatially focused attention heads without image annotations.