atlas

Research map / Architectures and efficiency / Attention and transformers

FlexPrefill: A Context-Aware Sparse Attention Mechanism for Efficient Long-Sequence Inference

ICLR 2025 · Architectures and efficiency › Attention and transformers · approach: Sparse attention for long-context LLMs · 0 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proposes FlexPrefill, a training-free sparse prefilling attention that per-head, per-input chooses between query-aware and vertical-slash patterns via Jensen-Shannon divergence and sets per-head budgets via cumulative attention thresholds.

Problem

Quadratic cost of attention during long-sequence LLM prefilling; existing sparse methods use fixed patterns or offline-searched patterns and ratios that do not adapt to each input and attention head.

Approach

Per attention head, estimate block-pooled attention from the last query block and compare it to the true distribution with square-root JS divergence; if the estimate is accurate use query-aware block selection, otherwise fall back to a vertical-slash pattern. Then select the smallest set of blocks/lines whose cumulative normalized attention exceeds a threshold gamma, giving each head and input its

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Use dynamic rather than fixed computational budgets across attention heads (ablation)FlexPrefill · RULERscore and inference speedHelped
Enable Query-Aware attention with an appropriate threshold (tau=0.1 rather than tau=0) (ablation)FlexPrefill on Qwen · RULER Avgscore: 69.47 -> 70.75Helped
Raise the Query-Aware threshold to tau=0.3 from tau=0.1 (ablation)FlexPrefill on LLaMA · RULER Avgscore: 89.18 -> 88.38Hurt
Change Triton block size from 128 to 64 (ablation)FlexPrefill on GLM · RULER Avgscore: 89.34 -> 89.34No clear effect
Use middle rather than last representative queries for sparse pattern determination (ablation)FlexPrefill on LLaMA-3.1 · RULER Avgscore: 89.18 -> 89.02No clear effect
Use middle rather than last representative queries for vertical-slash index selection (ablation)FlexPrefill on LLaMA-3.1 · RULER Avgscore: 89.18 -> 38.18Hurt
Use query-wise index selection instead of flattening the estimated attention map (ablation)FlexPrefill on LLaMA · RULER Avgscore: 89.18 -> 89.3No clear effect
Add a minimum computational budget of 1024 tokens rather than no minimum at gamma=0.9 (ablation)FlexPrefill on LLaMA · RULER Avgscore: 84.78 -> 88.38Helped
Increase the minimum budget from 1024 to 2048 tokens at gamma=0.9 (ablation)FlexPrefill on LLaMA · RULER Avgscore: 88.38 -> 88.82No clear effect
Cap maximum computational budget at 8k rather than leave it uncapped (ablation)FlexPrefill on LLaMA · RULER Avgscore: 89.18 -> 86.98Hurt
Cap maximum computational budget at 32k rather than leave it uncapped (ablation)FlexPrefill on GLM · RULER Avgscore: 89.34 -> 89.54Helped
Lower cumulative-attention threshold gamma from 0.95 to 0.85 (ablation)FlexPrefill on LLaMA-3.1 · RULER Avgscore: 89.18 -> 87.10Hurt

Surprising findings

Limitations

Experimental setup

Datasets: RULER InfiniteBench

Benchmarks: RULER InfiniteBench

Metrics: accuracy attention latency (ms) speedup

Baselines: FlashAttention StreamingLLM MInference MoA InfLLM LM-Infinite HiP

Builds on: MInference StreamingLLM FlashAttention

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy