LGDCSep 12, 2023

Efficient Memory Management for Large Language Model Serving with PagedAttention

Berkeley
arXiv:2309.06180v16373 citationsh-index: 67Has Code
Originality Highly original
AI Analysis

This addresses a critical bottleneck in high-throughput LLM serving for applications requiring efficient inference, with incremental improvements in memory optimization.

The paper tackles the problem of inefficient memory management for key-value cache in large language model serving, which limits batch size and throughput, and proposes PagedAttention and vLLM to achieve near-zero memory waste and 2-4x throughput improvement compared to state-of-the-art systems.

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

Code Implementations7 repos

Data from Papers with Code (CC-BY-SA-4.0)

Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes