Stateful Large Language Model Serving with Pensieve
Lingfan Yu, Jinkun Lin, Jinyang Li
TL;DR
<3-5 sentence high-level summary> Pensieve tackles the inefficiency of stateless LLM serving in multi-turn conversations by introducing a stateful two-tier GPU-CPU KV cache that preserves and reuses processed context across requests. It couples this caching strategy with a novel multi-token attention kernel that can operate over non-contiguous KV memory, and a unified batch scheduler that processes prefill and generation phases together. The approach includes chunk-based eviction with ahead-of-time swapping and pipelined recovery, plus mechanisms to handle dropped tokens via recomputation. Empirical results show substantial throughput gains (up to 3.0x) over strong stateless baselines on large models, with notable latency reductions and improved scalability on multi-GPU deployments.
Abstract
Large Language Models (LLMs) are wildly popular today and it is important to serve them efficiently. Existing LLM serving systems are stateless across requests. Consequently, when LLMs are used in the common setting of multi-turn conversations, a growing log of the conversation history must be processed alongside any request by the serving system at each turn, resulting in repeated processing. In this paper, we design $Pensieve$, a system optimized for multi-turn conversation LLM serving. $Pensieve$ maintains the conversation state across requests by caching previously processed history to avoid duplicate processing. $Pensieve$'s multi-tier caching strategy can utilize both GPU and CPU memory to efficiently store and retrieve cached data. $Pensieve$ also generalizes the recent PagedAttention kernel to support attention between multiple input tokens with a GPU cache spread over non-contiguous memory. Our evaluation shows that $Pensieve$ can achieve $1.14$-$3.0\times$ the throughput of vLLM and TensorRT-LLM and significantly reduce latency.
