arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2410.00428cs.DCcs.AIcs.LG
收藏

LayerKV:通过分层KV缓存管理优化大语言模型服务

LayerKV: Optimizing Large Language Model Serving with Layer-wise KV Cache Management

Ant Group(蚂蚁集团)

Yi Xiong, Hao Wu, Changxu Shao, Ziqing Wang, Rui Zhang, Yuhong Guo, Junping Zhao, Ke Zhang, Zhenxuan Pan

AI总结:

针对大语言模型上下文扩展导致首令牌生成时间(TTFT)飙升的问题,提出分层KV缓存管理方法LayerKV,通过细粒度内存控制与SLO感知调度,在不增硬件、不降性能的前提下大幅降低TTFT与SLO违反率。

摘要:

大语言模型(LLM)不断扩展的上下文窗口极大提升了其在各类应用中的能力,但也给维持低延迟带来了严峻挑战,尤其是首令牌生成时间(Time to First Token, TTFT)。本文发现,随着上下文长度增加,TTFT的急剧上升主要由排队延迟导致,而排队延迟的根源是GPU键值(Key-Value, KV)缓存分配需求增长与KV缓存块有限供应之间的冲突。为解决这一问题,我们提出LayerKV——一种简单有效的插件式方法,无需额外硬件、不损失输出性能,且能与现有并行策略和调度技术无缝集成,可有效降低TTFT。具体而言,LayerKV引入分层KV块分配、管理与卸载机制,实现对系统内存的细粒度控制,同时搭配服务等级目标(Service Level Objectives, SLOs)感知调度器以优化整体SLO。在7B到70B参数规模的代表性模型上、多种GPU配置下开展的综合评估表明,LayerKV将TTFT延迟最高降低69倍,SLO违反率降低28.7%,显著提升了用户体验。

英文摘要:

The expanding context windows in large language models (LLMs) have greatly enhanced their capabilities in various applications, but they also introduce significant challenges in maintaining low latency, particularly in Time to First Token (TTFT). This paper identifies that the sharp rise in TTFT as context length increases is predominantly driven by queuing delays, which are caused by the growing demands for GPU Key-Value (KV) cache allocation clashing with the limited availability of KV cache blocks. To address this issue, we propose LayerKV, a simple yet effective plug-in method that effectively reduces TTFT without requiring additional hardware or compromising output performance, while seamlessly integrating with existing parallelism strategies and scheduling techniques. Specifically, LayerKV introduces layer-wise KV block allocation, management, and offloading for fine-grained control over system memory, coupled with an SLO-aware scheduler to optimize overall Service Level Objectives (SLOs). Comprehensive evaluations on representative models, ranging from 7B to 70B parameters, across various GPU configurations, demonstrate that LayerKV improves TTFT latency up to 69x and reduces SLO violation rates by 28.7%, significantly enhancing the user experience.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑