HackerPapers

arXiv:2309.06180cs.LG

Efficient Memory Management for Large Language Model Serving with PagedAttention

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

Abstract

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

arXiv comments
SOSP 2023
Journal reference
DOI
Subjects
cs.LGMachine Learning cs.DCDistributed, Parallel, and Cluster Computing

On Hacker News

Linked by 3 identifiable commenters in 4 comments across 4 threads, from Mar 2024 to Feb 2026. Found in 2 HN submissions from Sep 2023 to Apr 2025. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments4 threads

    • The whole thing feels AI written, generated from the codebase.* *this is incorrect per the author’s response, my apologies. For instance, it goes into (nano)vLLM internals and doesn’t mention PagedAttention once (one of the core ideas that vLLM is based on)[1]. Also mentions…

      jbarrowView on HNParent context

    • Sorry this isn't more obvious. Ideally VRAM usage for the context window (the KV cache) becomes dynamic, starting small and growing with token usage, whereas right now Ollama defaults to a size of 2K which can be overridden at runtime. A great example of this is vLLM's…

      jmorganView on HNParent context

  1. Gemini Flash 1 comment
    • The PagedAttention paper is a good starting point as it represents the first major open source inference engine that had "pretty good" batch performance for transformers. https://arxiv.org/pdf/2309.06180

      AaronFrielView on HNParent context

    • It indeed is. An attention mechanism's key and value matrices grow linearly with context length. With PagedAttention[1], we could imagine an external service providing context. The hard part is the how, of course. We can't load our entire database in every conversation, and I…

      AaronFrielView on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.