Scout Before You Attend: Sketch-and-Walk Sparse Attention for Efficient LLM Inference
Hoang Anh Duy Le, Sahil Joshi, Zeyu Yang, Zhaozhuo Xu, Anshumali Shrivastava
TL;DR
This work tackles the quadratic cost of self-attention in long-context LLM inference by arguing that per-layer one-hop sparsification misses multi-hop dependencies that emerge via attention composition. It introduces Sketch&Walk, a training-free method that combines Small-World Sketching to cheaply estimate block-level interactions with a Sketch-Determined Walk that accumulates cross-layer influence to select top-$\tau$ blocks for sparse attention, applicable to both prefill and decode without training. Theoretical guarantees show that, under reasonable assumptions, the top-$\tau$ blocks identified by the walk recover the essential attention structure and that the resulting outputs approximate full attention within provable bounds; empirically it achieves near-lossless accuracy at $80\%$ sparsity and up to $6\times$ end-to-end speedups on long-context benchmarks. This approach enables robust, scalable long-context inference without training, with speedups that grow with context length and broad applicability across models such as Llama-3 and Qwen2.
Abstract
Self-attention dominates the computational and memory cost of long-context LLM inference across both prefill and decode phases. To address this challenge, we introduce Sketch&Walk Attention, a training-free sparse attention method that determines sparsity with lightweight sketches and deterministic walk. Sketch&Walk applies Hadamard sketching to get inexpensive approximations of attention scores, then aggregates these estimates across layers via a walk mechanism that captures attention influence beyond direct interactions between tokens. The accumulated walk scores are used to select top-k attention blocks, enabling dynamic sparsity with a single training-free algorithm that applies uniformly to both the prefill and decode phases, together with custom sparse attention kernels. Across a wide range of models and tasks, Sketch&Walk maintains near-lossless accuracy at 20% attention density and can slightly outperform dense attention in some settings, while achieving up to 6x inference speedup.
