FlashPrefill V2: Block-Sparse Prefill Attention for Long-Context LLM Serving
作者: Qihang Fan, Huaibo Huang, Zhiying Wu, Bingning Wang, Ran He
分类: cs.CL
发布日期: 2026-08-20
备注: FlashPrefill V2
💡 一句话要点
提出FlashPrefill V2以解决长上下文LLM服务中的注意力计算瓶颈
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 长上下文建模 稀疏注意力 大型语言模型 计算效率 推理优化
📋 核心要点
- 现有方法在长上下文建模中面临注意力计算的平方复杂度问题,导致性能瓶颈。
- FlashPrefill V2通过均值修正、稀疏注意力算子重设计及支持分页KV缓存等方式,提升了长上下文服务的效率。
- 在NVIDIA H20 GPU上,FlashPrefill V2在FP8和BF16精度下分别实现了最高47.26倍和27.19倍的速度提升。
📝 摘要(中文)
长上下文建模是大型语言模型的重要能力,但注意力机制的平方复杂度在计算密集的预填充阶段仍然是一个关键瓶颈。本文提出FlashPrefill V2,通过引入均值修正项、重新设计稀疏注意力算子以及支持分页KV缓存和连续批处理,推动FlashPrefill从原型向实际应用的转变。实验结果表明,FlashPrefill V2在NVIDIA H20 GPU上相较于FlashAttention-2在128K上下文长度下实现了最高47.26倍的速度提升,展示了其在实际量化需求下的优越性能。
🔬 方法详解
问题定义:本文旨在解决大型语言模型在长上下文处理中的注意力计算复杂度问题。现有方法如FlashPrefill虽然有所改进,但仍然在生产部署中存在不足,特别是在预填充阶段的计算效率低下。
核心思路:FlashPrefill V2的核心思路是通过引入均值修正项来抑制近似误差,并重新设计稀疏注意力算子,以适应最新的FlashAttention实现,确保在极端稀疏情况下仍能保持性能。
技术框架:整体架构包括均值修正、PackGQA内存访问、warp专门化和pingpong流水线等模块,支持FP8推理并与现代推理框架如SGLang集成。
关键创新:最重要的创新在于均值修正项的引入和稀疏注意力算子的重设计,使得在高稀疏度下仍能有效控制性能下降,与现有方法相比具有显著优势。
关键设计:关键设计包括对稀疏注意力算子的优化,采用PackGQA内存访问方式,确保高效的数据处理,并支持分页KV缓存和连续批处理,以满足实际应用需求。
🖼️ 关键图片
📊 实验亮点
实验结果显示,FlashPrefill V2在NVIDIA H20 GPU上相较于FlashAttention-2在128K上下文长度下实现了最高47.26倍的速度提升,在FP8精度下,相较于FA3/4对齐的稠密基线仍实现了30.49倍的速度提升,展现了其卓越的性能。
🎯 应用场景
FlashPrefill V2的研究成果在长上下文处理的实际应用中具有重要价值,尤其是在需要高效推理的自然语言处理任务中。其优化的注意力机制和高效的计算框架可以广泛应用于对话系统、文本生成和信息检索等领域,推动大型语言模型的实际部署和应用。
📄 摘要(原文)
Long-context modeling is a pivotal capability for Large Language Models, yet the quadratic complexity of attention remains a critical bottleneck, particularly during the compute-intensive prefilling phase. Our previous work, FlashPrefill, mitigates this cost through instantaneous pattern discovery and max-based dynamic thresholding; however, it remains an algorithmic prototype that is still distant from production deployment. In this paper, we present FlashPrefill V2, which evolves FlashPrefill from a prototype toward practical long-context serving along three dimensions. First, we introduce a mean correction term that effectively suppresses the approximation error, keeping performance degradation manageable even at extreme sparsity levels. Second, we redesign the sparse attention operator with PackGQA memory access, warp specialization, and pingpong pipelining, fully aligning with the latest FlashAttention-3/4 implementations and supporting FP8 inference to meet practical quantization requirements. Third, FlashPrefill V2 natively supports paged KV cache and continuous batching, allowing integration as an attention backend in modern inference frameworks such as SGLang. Extensive evaluations on NVIDIA H20 GPUs---among the most widely deployed inference accelerators---demonstrate that FlashPrefill V2 delivers up to 47.26x and 27.19x speedups over FlashAttention-2 at 128K context length under FP8 and BF16 precision, respectively, and, in FP8, still achieves a 30.49x speedup against an FA3/4-aligned dense baseline.