2025-02-21 · 专家 · 自然语言处理 · 机器学习

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

LServe通过统一稀疏注意力机制,有效加速了长序列LLM的服务,同时保持了长上下文准确性。

更新于 2026-11-29。作者:Shang Yang、Junxian Guo、Haotian Tang、Qinghao Hu、Guangxuan Xiao、Jiaming Tang、Yujun Lin、Zhijian Liu、Yao Lu、Song Han。

中文摘要

大型语言模型(LLMs)在处理长序列方面展现出惊人的潜力,然而,由于预填充阶段注意力的二次计算复杂性和解码阶段KV缓存的巨大内存占用,高效地服务于这些长上下文模型仍然具有挑战性。为了解决这些问题,我们引入了LServe,这是一个高效的系统,通过混合稀疏注意力加速长序列LLMs的服务。这种方法将预填充和解码注意力中的不同硬件友好型、结构化稀疏模式统一到一个框架中,通过块级跳过对不太重要的标记的计算。LServe展示了静态和动态稀疏在长上下文LLM注意力中的兼容性。这种设计通过结合这些优化实现了乘法加速。具体来说,我们在预填充和解码阶段将一半的注意力头转换为近乎免费的流式头部。此外,我们发现无论上下文长度如何,只需要常数个KV页面即可保留长上下文能力。然后,我们设计了一个分层KV页面选择策略,根据查询中心相似性动态修剪KV页面。平均而言,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, yet efficiently serving these long-context 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 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.

解读

一句话总结

LServe通过统一稀疏注意力机制,有效加速了长序列LLM的服务,同时保持了长上下文准确性。

问题1:这篇论文想要解决什么具体问题?

问题2:论文的核心创新点是什么?

问题3:实验结果如何验证了方法的有效性?

问题4:这个研究的实际应用价值是什么?

来源