通过共享跨请求的键值缓存,显著降低长文本大模型推理延迟。
KVShare: An LLM Service System with Efficient and Effective Multi-Tenant KV Cache Reuse
- 设计双阶段高偏差算法,按需重计算部分缓存。
- 实测推理首字延迟降低9.39倍,吞吐提升1.2倍。
- 适合多租户场景下追求低延迟与高吞吐的LLM服务部署。
长文本理解的进步使大语言模型(LLMs)的上下文长度达到百万级标记,虽提升了准确率和推理能力,但带来高昂计算成本和不佳的首次生成时间(TTFT)。KV缓存复用通过重用前缀或模板的完整缓存,或共享相似缓存并选择性重计算,为解决该问题提供可能。然而,现有研究忽视了跨请求缓存复用及解码阶段新标记引入的注意力偏差。本文提出一种多租户场景下的KV缓存管理模块——KVShare,实现不牺牲精度的高效推理。系统包含:1)双阶段高偏差算法(DHD),在预填充和解码阶段条件性地重计算少量缓存;2)基于缓存命中率的调度器,优先处理高命中请求并支持连续批处理,以提升系统效率和加速TTFT。在Qwen2.5-7B、Llama3.1-8B和Yi1.5-9B等模型上的多任务实验表明,相比完全重计算,KVShare将TTFT降低最高达9.39倍,吞吐提升1.2倍,且相比当前最优方法,准确率提高20.38%。
原文摘要 · Abstract (English)
Recent advances in long-text understanding have pushed the context length of large language models (LLMs) up to one million tokens. It boosts LLMs's accuracy and reasoning capacity but causes exorbitant computational costs and unsatisfactory Time to First Token (TTFT). KV cache reuse, which reuses the exact same KV cache of prefixes and templates or shares similar ones but with extra selective recomputation, offers a promising way to tackle this issue. However, prior studies overlook the cross-request KV reuse and the attention deviations introduced by new tokens during the decoding stage. In this paper, we present a KV cache management module that shares the KV cache across requests under multi-tenant scenarios without sacrificing model accuracy. Our system, KVShare, enables accurate and efficient LLM serving by 1) a Dual-Stage High Deviation algorithm (DHD) that conditionally selects a small portion of KV cache to be recomputed during both prefill and decode phases, and 2) a cache-aware scheduler that prioritizes requests based on their KV cache hit rates and orchestrates continuous batching to achieve enhanced system efficiency and faster TTFT. Multi-task experiments conducted on models such as Qwen2.5-7B,Llama3.1-8B and Yi1.5-9B demonstrate that KVShare reduces TTFT by up to 9.39x and increases 1.2x of the throughput compared to the full KV recompute. Moreover, KVShare achieves 20.38% boost in terms of accuracy compared to SOTA methods.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。