AIAny
Icon for item

Block Sparse Attention with Log-Linear Complexity

Reduces self-attention complexity to O(N log N) by using a coarse-to-fine (pyramid) Top-K block selection with LogSumExp scoring, implemented with hardware-aware Triton kernels for fused routing and scoring—aimed at long-context LMs and retrieval tasks.

Introduction

Most Transformer scaling work focuses on lowering the quadratic cost of attention; this paper's core insight is that you can find relevant key blocks with a logarithmic-depth, coarse-to-fine selection instead of scoring every query-block pair. That shift turns block-sparse attention’s remaining bottleneck (block selection) into an O(N log N) procedure while still preserving the important blocks for exact computation.

Key Findings
  • Pyramid Top-K selection: builds an O(log N) hierarchy of pooled keys and progressively narrows candidates from coarse to fine, so each query only scores a bounded set per level—this yields O(N log N) selection complexity rather than O(N^2).
  • LogSumExp scoring on bounded candidate sets: uses stable LogSumExp aggregation at each level to rank blocks without materializing the full QK score matrix, enabling efficient hardware fusion.
  • Hardware-aware implementation: custom Triton kernels fuse hierarchical routing and LogSumExp scoring for both training and inference, reducing memory traffic and avoiding full score matrix materialization.
  • Empirical behavior: matches baseline performance on commonsense reasoning benchmarks and improves retrieval-oriented tasks, showing the selection scheme preserves retrieval-relevant context.
Who it's for & trade-offs

Great fit if you need to extend Transformer contexts to very long sequences where naive attention is infeasible, or if retrieval-style relevance matters and you want a training-free sparse attention that keeps exact computation on critical blocks. Look elsewhere if your sequences are short (where quadratic attention is acceptable), if you need a strictly linear-time attention with simpler kernels, or if you cannot invest engineering effort to integrate custom Triton/CUDA kernels. Practical trade-offs include non-negligible constant factors from hierarchical pooling and kernel complexity, implementation and tuning effort for thresholds/level sizes, and potential task-dependent sensitivity of the Top-K strategy (very high sparsity can still harm dense-context tasks).

Where it fits

This approach occupies the middle ground between full attention (exact but quadratic) and simpler sparse or approximate schemes: it keeps exact values for selected blocks while routing selection to a coarse-to-fine search to avoid full pairwise scoring. Compared with single-pass block selection methods, the pyramid selection reduces scoring overhead at the cost of added pooling levels and routing logic—making it attractive when sequence length N is large enough that O(N log N) wins in practice.

Information

  • Websitearxiv.org
  • AuthorsBohao Tang, Zhen Qin, Yuqi Pan, Zheng Li, Pengfei Liu
  • Published date2026/09/25

More Items

Shows that Transformer LLMs output a superposition of next-token distributions when token embeddings from distinct text streams are linearly combined, finds this property is architectural but weakened by pretraining, and demonstrates it can be restored by lightweight fine-tuning and disentangled at decode time.

Edits an LLM agent's internal task state and action continuations to remove unsupported assumptions and noisy plans, improving downstream decisions instead of reconstructing high-entropy tool outputs. Combines Action Judge, State Revision, and EditAct and shows consistent gains across benchmarks and agent backbones.

Adds token-conditioned quantum residual branches to a frozen masked-diffusion language model: a lightweight hypernetwork emits continuous quantum-circuit coordinates per token, executes a shared sparse IQP-style circuit, and injects classically-expressible expectation readouts back into transformer blocks. Trains only the added branches, scaling to 16–64 qubits with analytic, linear-cost readouts.