将大模型推理的键值缓存移出显存,实现跨查询和引擎复用,显著提升企业级推理效率。
LMCache: An Efficient KV Cache Layer for Enterprise-Scale LLM Inference
- 把键值缓存从GPU显存移到外部存储,支持跨查询、跨引擎共享
- 结合vLLM使用可提升15倍吞吐量,尤其在多轮问答等场景
- 提供灵活控制接口,适配大规模部署与动态调度需求
键值(KV)缓存传统上存于GPU内存以加速大语言模型(LLM)推理的解码阶段。但随着用户累积的缓存数据快速增长,远超显存容量,将其移出设备成为必要趋势。现有方案缺乏高效离线与传输能力。本文提出LMCache,首个且目前最高效的开源KV缓存解决方案,能从现代LLM引擎(如vLLM和SGLang)中提取并存储外部缓存,实现跨引擎与跨查询复用。支持缓存卸载(前缀复用)和预填充-解码分离(跨引擎/GPU缓存迁移)。其高性能源于三点:批量数据移动操作、计算与I/O流水线优化;模块化缓存连接组件,解耦引擎快速迭代;以及跨GPU、CPU、存储与网络层的专用控制接口。评估显示,结合vLLM使用,多种工作负载下吞吐量最高提升15倍。大规模部署揭示:远程存储加载可缓解预填充延迟,而工业中广泛应用的上下文截断会令前缀缓存命中率下降一半。代码已开源:https://github.com/LMCache/LMCache。
原文摘要 · Abstract (English)
KV cache has traditionally been stored in GPU memory to accelerate the decoding phase of large language model (LLM) inference. However, it is increasingly necessary to move KV caches outside GPU devices, to enable cache reuse across different queries and inference engines. Our real-world usage statistics confirm this trend: over time, the total KV cache stored by users has grown rapidly, far exceeding the capacity of GPU memory. Despite this need, there lacks an efficient solution for offloading and transferring KV caches. We present LMCACHE, the first and so far the most efficient open-source KV caching solution, which extracts and stores KV caches generated by modern LLM engines (vLLM and SGLang) out of the GPU memory and shares them across engines and queries. LMCACHE supports both cache offloading (prefix reuse across queries) and prefill-decode (PD) disaggregation (cross-engine/GPU cache transfer). LMCACHE's high performance and wide adoption stem from the following contributions: (1) highly optimized KV cache data movement powered by batched data movement operations, compute and I/O pipelining; (2) a modular KV cache connector component, decoupling LMCACHE from the rapid evolution of inference engines; (3) a first-class control API for flexible cache orchestration across GPU, CPU, storage, and network layers. Our evaluation shows that combining LMCACHE with vLLM achieves up to 15x improvement in throughput across workloads such as multi-round question answering and document analysis. Large-scale adoption of LMCACHE in enterprise settings provides us valuable insights, for example, fetching KV cache from remote storage has unsurprisingly benefits to prefill delay, and that context truncation, which is a widely applied technique in industry, can greatly reduce prefix cache hit ratio by half. The source code of LMCACHE is at: https://github.com/LMCache/LMCache.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。