arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2403.19708cs.CLcs.LG
收藏

基于CachedAttention的多轮对话低成本大语言模型服务

Cost-Efficient Large Language Model Serving for Multi-turn Conversations with CachedAttention

National University of Singapore(新加坡国立大学);Shanghai Jiaotong University(上海交通大学);Huawei Cloud(华为云)

Bin Gao, Zhuomin He, Puru Sharma, Qingxuan Kang, Djordje Jevdjic, Junbo Deng, Xingkun Yang, Zhou Yu, Pengfei Zuo

AI总结:

本文提出CachedAttention注意力机制,通过分层KV缓存、预加载与异步保存、调度器感知的获取淘汰及位置编码解耦,显著降低多轮对话大语言模型服务的推理成本与延迟。

摘要:

通过多轮对话与人类交互是大语言模型(LLMs)的一项基本能力。然而,现有的大语言模型服务引擎在执行多轮对话时效率低下,因为需要反复计算历史token的键值(KV)缓存,导致高昂的服务成本。为解决这一问题,本文提出了CachedAttention,一种新的注意力机制,能够在多轮对话中复用KV缓存,显著减少重复计算开销。CachedAttention维护了一个分层KV缓存系统,利用成本效益高的内存/存储介质来保存所有请求的KV缓存。为降低慢速介质带来的KV缓存访问开销,CachedAttention采用逐层预加载和异步保存方案,使KV缓存访问与GPU计算重叠执行。为确保待访问的KV缓存位于最快层级,CachedAttention采用调度器感知的获取与淘汰策略,根据推理作业调度器的提示有意识地将KV缓存放置在不同层级中。为避免上下文窗口溢出导致已保存KV缓存失效,CachedAttention通过解耦位置编码并有效截断KV缓存,使已保存的KV缓存保持有效。大量实验结果表明,CachedAttention将首token时间(TTFT)最多降低87%,将多轮对话的提示预填充吞吐量最多提升7.8倍,并将端到端推理成本最多降低70%。

英文摘要:

Interacting with humans through multi-turn conversations is a fundamental feature of large language models (LLMs). However, existing LLM serving engines executing multi-turn conversations are inefficient due to the need to repeatedly compute the key-value (KV) caches of historical tokens, incurring high serving costs. To address the problem, this paper proposes CachedAttention, a new attention mechanism that enables reuse of KV caches across multi-turn conversations, significantly reducing the repetitive computation overheads. CachedAttention maintains a hierarchical KV caching system that leverages cost-effective memory/storage mediums to save KV caches for all requests. To reduce KV cache access overheads from slow mediums, CachedAttention employs layer-wise pre-loading and asynchronous saving schemes to overlap the KV cache access with the GPU computation. To ensure that the KV caches to be accessed are placed in the fastest hierarchy, CachedAttention employs scheduler-aware fetching and eviction schemes to consciously place the KV caches in different layers based on the hints from the inference job scheduler. To avoid the invalidation of the saved KV caches incurred by context window overflow, CachedAttention enables the saved KV caches to remain valid via decoupling the positional encoding and effectively truncating the KV caches. Extensive experimental results demonstrate that CachedAttention significantly decreases the time to the first token (TTFT) by up to 87%, improves the prompt prefilling throughput by up to 7.8$\times$ for multi-turn conversations, and reduces the end-to-end inference cost by up to 70%.

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

↑