优化大模型推理中缓存竞争,显著降低用户等待时间。
Mitigating KV Cache Competition to Enhance User Experience in LLM Inference
- 根据请求到达率动态估算输出长度,精准分配缓存资源。
- 提前预分配缓存并复用他请求缓存,减少等待与抢占。
- 智能选择抢占目标和恢复策略,提升高并发下的响应效率。
在大语言模型服务中,键值缓存(KV-cache)瓶颈导致尾部延迟的首字耗时(TTFT)和字间耗时(TBT)过高,严重影响用户体验,尤其在对时间敏感的应用中。现有方法难以同时满足TTFT和TBT的服务水平目标(SLO)。为此,本文提出CacheOPT系统,基于测量洞察设计新机制:首先,估算请求输出长度,并以高概率控制偏差,根据请求到达率动态调整;其次,为请求分配估算的KV缓存需求,复用其他请求已分配缓存以避免抢占并降低等待时间;第三,提前预分配缓存,全局预留缓存以防止抢占;第四,选择具有长TBT SLO、剩余时间长且抢占时间短的请求进行抢占;第五,抢占时在交换与重计算间选择最短延迟策略。实验表明,CacheOPT将尾部TBT和尾部TTFT分别降低3.29倍和2.83倍,TTFT与TBT SLO达成率提升47%和53%,支持的请求到达率比当前最优方法高1.58倍。
原文摘要 · Abstract (English)
In Large Language Model (LLM) serving, the KV-cache (KVC) bottleneck causes high tail Time-to-First-Token (TTFT) and Time-Between-Tokens (TBT), impairing user experience, particularly in time-sensitive applications. However, satisfying both TTFT and TBT service-level objectives (SLOs) is challenging. To address this, we propose a system, named CacheOPT for mitigating KV Cache competition, based on key insights from our measurements, incorporating novel components. First, it estimates a request's output length, bounding the deviation with a high specified probability, adjusted based on the request arrival rate. Second, it allocates the estimated KVC demand to a request, and reuses other requests' allocated KVC to avoid preemptions while reducing waiting time. Third, it proactively allocates KVC before instead of at the time a request exhausts its allocation and reserves KVC globally to prevent preemptions. Fourth, it chooses a request that has long TBT SLO, long job remaining time and short preemption time to preempt. Fifth, it selects the shortest-latency strategy between swapping and recomputation for preemptions. Experiments show that CacheOPT achieves up to 3.29$\times$ and 2.83$\times$ lower tail TBT and tail TTFT, 47\% and 53\% higher TTFT and TBT SLO attainments, and supports up to 1.58$\times$ higher request arrival rate than the state-of-the-art methods.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。