arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2309.06180cs.LGcs.DC
收藏

使用PagedAttention的大型语言模型服务的高效内存管理

Efficient Memory Management for Large Language Model Serving with PagedAttention

UC Berkeley(加州大学伯克利分校);Stanford University(斯坦福大学);UC San Diego(加州大学圣地亚哥分校)

Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph E. Gonzalez, Hao Zhang, Ion Stoica

AI总结:

针对LLM服务中KV cache内存浪费限制批处理大小的问题,提出受操作系统分页技术启发的PagedAttention算法并构建vLLM系统,实现近乎零内存浪费与灵活共享,在同等延迟下将吞吐量提升2-4倍。

摘要:

大型语言模型(LLM)的高吞吐量服务需要一次批量处理足够多的请求。然而,现有系统面临困难,因为每个请求的键值缓存(KV cache)内存巨大且动态增减。若管理低效,该内存会因碎片化和冗余重复而被显著浪费,从而限制批处理大小。为解决此问题,我们提出PagedAttention,一种受操作系统中经典虚拟内存和分页技术启发的注意力算法。在此基础上,我们构建了vLLM,一个LLM服务系统,它实现了(1)KV cache内存近乎零浪费,以及(2)在请求内部和跨请求间灵活共享KV cache以进一步降低内存使用。我们的评估表明,与FasterTransformer和Orca等最先进系统相比,vLLM在相同延迟水平下将流行LLM的吞吐量提高了2-4倍。在序列更长、模型更大和解码算法更复杂时,改进更为显著。vLLM的源代码已在https://github.com/vllm-project/vllm公开。

英文摘要:

High throughput serving of large language models (LLMs) requires batching sufficiently many requests at a time. However, existing systems struggle because the key-value cache (KV cache) memory for each request is huge and grows and shrinks dynamically. When managed inefficiently, this memory can be significantly wasted by fragmentation and redundant duplication, limiting the batch size. To address this problem, we propose PagedAttention, an attention algorithm inspired by the classical virtual memory and paging techniques in operating systems. On top of it, we build vLLM, an LLM serving system that achieves (1) near-zero waste in KV cache memory and (2) flexible sharing of KV cache within and across requests to further reduce memory usage. Our evaluations show that vLLM improves the throughput of popular LLMs by 2-4$\times$ with the same level of latency compared to the state-of-the-art systems, such as FasterTransformer and Orca. The improvement is more pronounced with longer sequences, larger models, and more complex decoding algorithms. vLLM's source code is publicly available at https://github.com/vllm-project/vllm

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

↑