ByteDance Seed
首页模型博客&论文Seed Edge加入我们
首页模型博客&论文Seed Edge加入我们
体验豆包AI 体验中心

2025-02-28

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

Download PDF
上一篇下一篇

摘要

Large language models (LLMs) encounter computational challenges during long-sequence inference, especially in the attention pre-filling phase, where the complexity grows quadratically with the prompt length. Previous efforts to mitigate these challenges have relied on fixed sparse attention patterns or identifying sparse attention patterns based on limited cases. However, these methods lacked the flexibility to efficiently adapt to varying input demands. In this paper, we introduce FlexPrefill, a Flexible sparse Pre-filling mechanism that dynamically adjusts sparse attention patterns and computational budget in real-time to meet the specific requirements of each input and attention head. The flexibility of our method is demonstrated through two key innovations: 1) Query-Aware Sparse Pattern Determination: By measuring Jensen-Shannon divergence, this component adaptively switches between query-specific diverse attention patterns and predefined attention patterns. 2) Cumulative-Attention Based Index Selection: This component dynamically selects query-key indexes to be computed based on different attention patterns, ensuring the sum of attention scores meets a predefined threshold. FlexPrefill adaptively optimizes the sparse pattern and sparse ratio of each attention head based on the prompt, enhancing efficiency in long-sequence inference tasks. Experimental results show significant improvements in both speed and accuracy over prior methods, providing a more flexible and efficient solution for LLM inference.

作者

Xunhao Lai, Jianqiao Lu, Yao Luo, Yiyuan Ma, Xun Zhou

期刊/会议

ICLR 2025 Oral

追求智能上限,创造社会价值
欢迎加入字节跳动 Seed
模型成果
Seed2.1
Seedance 2.5
Seedream 5.0 Pro
SeedRealtime
Seed Audio 1.0
Seed GR-RL
了解更多
论文
Seed Edge
Seed STEM 科学家计划
校园招聘
Copyright© 2026 Bytedance Seed
网站声明联系我们 : seed.feedback@bytedance.com
Seed2.1Seedance 2.5Seedream 5.0 ProSeedRealtimeSeed Audio 1.0Seed GR-RL
论文Seed EdgeSeed STEM 科学家计划校园招聘
追求智能上限,创造社会价值
欢迎加入字节跳动 Seed
Copyright© 2026 Bytedance Seed
网站声明
联系我们 : seed.feedback@bytedance.com
追求智能上限,创造社会价值
联系我们 : seed.feedback@bytedance.com
Copyright© 2026 Bytedance Seed网站声明