Accelerating Prefilling via Decoding-time Contribution Sparsity

Zhiyuan He, Yike Zhang, Chengruidong Zhang, Huiqiang Jiang, Yuqing Yang, Lili Qiu

TL;DR

Prefilling long contexts in Large Language Models (LLMs) is notoriously slow due to the quadratic complexity of attention. While existing acceleration methods skip blocks with low attention scores, this paper introduces decoding-time contribution sparsity—revealing that many blocks with high attention scores actually have negligible impact on final decoding. By leveraging this insight, the authors propose TriangleMix, a training-free method that applies a static triangle attention pattern to selected layers, achieving up to a 15.3× attention kernel speedup with near-lossless accuracy.

What Problem Does This Paper Address?

When an LLM processes a long prompt (the "prefilling" stage), it computes attention across all input tokens. This operation scales quadratically ($O(N^2)$) with prompt length, creating a massive computational bottleneck.

To mitigate this, current state-of-the-art methods use dynamic sparse attention to identify and compute only the blocks with high attention scores, skipping the rest. However, these methods rely on a fundamental assumption: if an attention block has a high score, it must be important. The authors challenge this assumption by asking a deeper question: Must we compute all non-trivial blocks during prefilling to preserve decoding accuracy?

Methods

The authors introduce a gradient-based probing framework to measure how much an attention block actually influences the final output token. They partition the causal attention matrix into three distinct regions:

  1. Streaming region: The initial tokens (attention sinks) and a local sliding window.
  2. Last Q-K region: The most recent queries and keys.
  3. Middle Q-K region: The large block of interactions between the streaming and last regions.
Attention sections

Their gradient analysis reveals that the Middle Q-K region often has high attention scores but near-zero gradients with respect to the predicted token, meaning its exact values don't alter the final output.

Based on this, they develop TriangleMix:

  • Layer Selection: They run a quick, training-free gradient probe to identify a subset of layers ($L_{tri}$) where the Middle Q-K section contributes the least to decoding.
  • Static Triangle Attention: In these selected layers, they completely skip computing the Middle Q-K region, reducing the attention complexity from $O(N^2)$ to $O(N)$ via a hardware-efficient static triangle pattern.
  • Hybrid Execution: The remaining critical layers retain full dense attention (or use dynamic sparse attention). Because the triangle pattern is static, it completely avoids the runtime block-index estimation overhead that plagues dynamic methods.

Datasets

The authors evaluated TriangleMix across a diverse set of long-context benchmarks:

  • RULER: Tested at input lengths from 4K to 128K tokens to evaluate effective context window size behavior.
  • LongBench: A suite of realistic long-context tasks including question answering, summarization, and few-shot learning.
  • GSM-Infinite: A hard subset designed to challenge both long-context understanding and multi-step mathematical reasoning.
  • Wikipedia: Used to perform controlled perplexity (PPL) evaluations.

Key Insights and Ideas

  • Locality of Influence: The core reason behind decoding-time contribution sparsity is that many attention blocks only exert a temporary, local influence on nearby tokens. Once the generation position moves past a certain window ($\Delta t$), their impact on the output distribution drops to zero.
  • Scores $\neq$ Importance: High attention weights do not automatically mean a block is critical for final generation. The Middle Q-K and Last Q-K regions often have comparable attention magnitudes, yet their gradients differ drastically.
  • Layer-wise Asymmetry: This sparsity is highly layer-dependent. As shown below, in models like Llama-3.1-8B-Instruct, the gradients of the Middle Q-K region drop to near zero in the final 16 layers, making them perfect candidates for aggressive pruning.
Gradient of Middle Q-K across layers

Key Results

  • Massive Kernel Speedups: For 128K token inputs, the static Triangle attention kernel achieves a 15.3× speedup in attention computation compared to dense FlashAttention, significantly outperforming dynamic methods like MInference (3.3×) and FlexPrefill (3.4×).
  • End-to-End Acceleration: TriangleMix reduces the end-to-end Time-to-First-Token (TTFT) by 12% to 32% on Llama-3.1-8B-Instruct.
  • Perfect Synergy: TriangleMix can be seamlessly combined with dynamic sparse attention methods. Combining TriangleMix with MInference delivers an additional 6% to 19% reduction in TTFT compared to using MInference alone.
  • Near-Lossless Accuracy: Across RULER and LongBench, TriangleMix maintains accuracy within -0.4% to +0.1% of full dense attention, vastly outperforming other static baselines like pure Streaming attention.

Limitations and Future Work

  • Fixed Sparsity Ratios: The number of triangle layers ($L_{tri}$) is a fixed hyperparameter determined by the pretrained model's inherent properties.
  • Model-Dependent Sparsity: Different models show varying levels of this sparsity. While Llama models are highly sparse ($L_{tri}=16$ or $20$), Qwen2.5-7B-Instruct is less naturally sparse ($L_{tri}=8$), which constrains its maximum acceleration.
  • Future Work: The authors suggest exploring post-training optimization or fine-tuning techniques specifically designed to artificially induce or enhance decoding-time contribution sparsity in models that do not naturally exhibit it.

Summary updated

BibTeX
@inproceedings{he2026accelerating,
  author = {Zhiyuan He and Yike Zhang and Chengruidong Zhang and Huiqiang Jiang and Yuqing Yang and Lili Qiu},
  title = {{Accelerating Prefilling via Decoding-time Contribution Sparsity}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2026},
  doi = {10.18653/v1/2026.findings-acl.801},
}
Figure