面向大语言模型服务的高效内存管理:PagedAttention

Efficient Memory Management for Large Language Model Serving with PagedAttention

郑怜悯 Lianmin Zheng · UC Berkeley · 2023-09-12 · arXiv:2309.06180 ↗ · 被引 6859

打开互动全文版(逐段中英对照 + 图/公式 + 论文问答)→

摘要 · Abstract

大语言模型的高吞吐服务需要同时批处理大量请求。然而,现有系统面临挑战:每个请求的键值缓存(KV 缓存)内存巨大且动态增长和收缩。管理不当会导致内存因碎片化和冗余复制而严重浪费,限制批处理大小。为解决此问题,我们提出 PagedAttention,一种受操作系统经典虚拟内存和分页技术启发的注意力算法。在此基础上,我们构建了 vLLM,一个 LLM 服务系统,实现了(1)KV 缓存内存近乎零浪费和(2)请求内及请求间 KV 缓存的灵活共享,以进一步减少内存使用。评估表明,与 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

核心贡献 · Key contributions

局限 · Limitations

论文章节 · Sections(共 32)

阅读逐段中英对照全文 →