ChatPaper.aiChatPaper

Gestione Efficiente della Memoria per il Servizio di Modelli Linguistici di Grandi Dimensioni con PagedAttention

Efficient Memory Management for Large Language Model Serving with PagedAttention

September 12, 2023
Autori: Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph E. Gonzalez, Hao Zhang, Ion Stoica
cs.AI

Abstract

Il servizio ad alta produttività di modelli linguistici di grandi dimensioni (LLM) richiede l'elaborazione in batch di un numero sufficiente di richieste contemporaneamente. Tuttavia, i sistemi esistenti incontrano difficoltà perché la memoria della cache chiave-valore (KV cache) per ogni richiesta è enorme e cresce e si riduce dinamicamente. Se gestita in modo inefficiente, questa memoria può essere significativamente sprecata a causa della frammentazione e della duplicazione ridondante, limitando le dimensioni del batch. Per affrontare questo problema, proponiamo PagedAttention, un algoritmo di attenzione ispirato alle classiche tecniche di memoria virtuale e paginazione dei sistemi operativi. Su di esso, costruiamo vLLM, un sistema di servizio LLM che raggiunge (1) uno spreco quasi nullo nella memoria della KV cache e (2) una condivisione flessibile della KV cache all'interno e tra le richieste per ridurre ulteriormente l'uso della memoria. Le nostre valutazioni mostrano che vLLM migliora la produttività di LLM popolari di 2-4 volte con lo stesso livello di latenza rispetto ai sistemi all'avanguardia, come FasterTransformer e Orca. Il miglioramento è più evidente con sequenze più lunghe, modelli più grandi e algoritmi di decodifica più complessi. Il codice sorgente di vLLM è disponibile pubblicamente all'indirizzo 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
PDF251December 15, 2024