大規模言語モデルサービングのための効率的なメモリ管理:PagedAttentionを用いたアプローチ
Efficient Memory Management for Large Language Model Serving with PagedAttention
September 12, 2023
著者: Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph E. Gonzalez, Hao Zhang, Ion Stoica
cs.AI
要旨
大規模言語モデル(LLM)の高スループットな提供には、十分な数のリクエストを一度にバッチ処理する必要があります。しかし、既存のシステムでは、各リクエストのキー・バリューキャッシュ(KVキャッシュ)メモリが巨大で、動的に増減するため、困難が生じています。このメモリが非効率的に管理されると、フラグメンテーションや冗長な重複によって大幅に無駄が生じ、バッチサイズが制限されます。この問題を解決するため、我々はオペレーティングシステムにおける古典的な仮想メモリとページング技術に着想を得たアテンションアルゴリズム「PagedAttention」を提案します。その上に、vLLMというLLM提供システムを構築し、(1) KVキャッシュメモリの無駄をほぼゼロにし、(2) リクエスト内およびリクエスト間でのKVキャッシュの柔軟な共有を実現して、メモリ使用量をさらに削減します。評価結果によると、vLLMは、FasterTransformerやOrcaなどの最先端システムと比較して、同じレベルのレイテンシで、人気のあるLLMのスループットを2~4倍向上させます。この改善は、より長いシーケンス、より大きなモデル、より複雑なデコードアルゴリズムにおいてより顕著です。vLLMのソースコードは、https://github.com/vllm-project/vllm で公開されています。
English
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-4times 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