arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2502.14866cs.CLcs.AIcs.DCcs.LGcs.PF
收藏

LServe:基于统一稀疏注意力实现高效长序列LLM服务

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

MIT(麻省理工学院)

Shang Yang, Junxian Guo, Haotian Tang, Qinghao Hu, Guangxuan Xiao, Jiaming Tang, Yujun Lin, Zhijian Liu, Yao Lu, Song Han

AI总结:

LServe通过统一混合稀疏注意力,将一半注意力头转为流式头并分层剪枝KV页面,实现长序列LLM服务预填充2.9倍、解码1.3-2.1倍加速,保持长上下文准确性。

摘要:

大型语言模型(LLM)在处理长序列和复杂推理任务方面展现出显著潜力,然而,由于预填充阶段注意力的二次方计算复杂度和解码阶段KV缓存的大内存占用,高效服务这些模型仍然具有挑战性。为解决这些问题,我们引入了LServe,一个通过混合稀疏注意力加速长序列LLM服务的高效系统。该方法将预填充和解码注意力中不同的硬件友好、结构化稀疏模式统一到一个框架中,其中对较不重要token的计算被按块跳过。LServe展示了静态和动态稀疏性在长上下文LLM注意力中的兼容性。该设计通过结合这些优化实现了乘法级加速。具体来说,我们将一半的注意力头在预填充和解码阶段转换为近乎免费的流式头。此外,我们发现无论上下文长度如何,仅需恒定数量的KV页面即可保持长上下文和推理能力。然后,我们设计了一种基于查询中心相似性的分层KV页面选择策略,动态剪枝KV页面。平均而言,与vLLM相比,LServe将LLM预填充加速高达2.9倍,解码加速1.3-2.1倍,同时保持长上下文准确性。代码已发布在https://github.com/mit-han-lab/omniserve。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑