arXiv:2502.14866cs.CLcs.AI2025-02中稿 · MLSys 2025被引 48

通过统一稀疏注意力提升长序列大模型推理效率

LServe: Efficient Long-sequence LLM Serving with Unified Sparse Attention

  • 采用混合稀疏注意力机制,跳过低重要性词元的计算块
  • 预填充加速2.9倍,解码加速1.3-2.1倍,保持长上下文准确率
  • 适合需要高效长文本处理的部署场景

大型语言模型(LLMs)在处理长序列和复杂推理任务上展现出巨大潜力,但其服务效率受限于预填充阶段注意力的二次计算复杂度以及解码阶段键值缓存(KV cache)的巨大内存开销。为此,我们提出LServe,一种基于统一稀疏注意力的高效系统。该方法将预填充与解码阶段的不同硬件友好、结构化稀疏模式统一到单一框架中,以块为单位跳过不重要词元的计算。LServe实现了静态与动态稀疏性的兼容,通过组合优化实现乘法级加速:在预填充与解码阶段均将一半注意力头转换为近乎免费的流式头;同时发现,无论上下文长度如何,仅需常数数量的KV页面即可维持长上下文与推理能力。我们设计了一种层次化KV页面选择策略,基于查询中心相似性动态修剪页面。实验表明,相比vLLM,LServe平均使预填充速度提升2.9倍,解码速度提升1.3-2.1倍,且保持长上下文准确性。代码已开源:https://github.com/mit-han-lab/omniserve。

原文摘要 · Abstract (English)

Large language models (LLMs) have shown remarkable potential in processing long sequences and complex reasoning tasks, yet efficiently serving these models remains challenging due to the quadratic computational complexity of attention in the prefilling stage and the large memory footprint of the KV cache in the decoding stage. To address these issues, we introduce LServe, an efficient system that accelerates long-sequence LLM serving via hybrid sparse attention. This method unifies different hardware-friendly, structured sparsity patterns for both prefilling and decoding attention into a single framework, where computations on less important tokens are skipped block-wise. LServe demonstrates the compatibility of static and dynamic sparsity in long-context LLM attention. This design enables multiplicative speedups by combining these optimizations. Specifically, we convert half of the attention heads to nearly free streaming heads in both the prefilling and decoding stages. Additionally, we find that only a constant number of KV pages is required to preserve long-context and reasoning capabilities, irrespective of context length. We then design a hierarchical KV page selection policy that dynamically prunes KV pages based on query-centric similarity. On average, LServe accelerates LLM prefilling by up to 2.9x and decoding by 1.3-2.1x over vLLM, maintaining long-context accuracy. Code is released at https://github.com/mit-han-lab/omniserve.

长序列处理稀疏注意力LLM推理

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。