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

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...

Ausführliche Beschreibung

Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Gao, Bin, He, Zhuomin, Sharma, Puru, Kang, Qingxuan, Jevdjic, Djordje, Deng, Junbo, Yang, Xingkun, Yu, Zhou, Zuo, Pengfei
Format: Artikel
Sprache:eng
Schlagworte:
Online-Zugang:Volltext bestellen
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
container_end_page
container_issue
container_start_page
container_title
container_volume
creator Gao, Bin
He, Zhuomin
Sharma, Puru
Kang, Qingxuan
Jevdjic, Djordje
Deng, Junbo
Yang, Xingkun
Yu, Zhou
Zuo, Pengfei
description 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%.
doi_str_mv 10.48550/arxiv.2403.19708
format Article
fullrecord <record><control><sourceid>arxiv_GOX</sourceid><recordid>TN_cdi_arxiv_primary_2403_19708</recordid><sourceformat>XML</sourceformat><sourcesystem>PC</sourcesystem><sourcerecordid>2403_19708</sourcerecordid><originalsourceid>FETCH-arxiv_primary_2403_197083</originalsourceid><addsrcrecordid>eNqFjrEOgjAYhLs4GPUBnOwLgFUg4mgajINMuhrSQAt_gq35-4P69iJxd7m7XC6Xj7HlRoRxmiRirfAFfbiNRRRu9juRTtlNOk9BZgyUoC3xs8JaD2rrTg0hd5Vu-UVjD7bmxiHPu5YgoA4tl872Gr0icNbzJ1DDpSobXR2Ihq-hnbOJUa3Xi5_P2OqYXeUpGEGKB8Jd4bv4AhUjUPR_8QGLXUGo</addsrcrecordid><sourcetype>Open Access Repository</sourcetype><iscdi>true</iscdi><recordtype>article</recordtype></control><display><type>article</type><title>Cost-Efficient Large Language Model Serving for Multi-turn Conversations with CachedAttention</title><source>arXiv.org</source><creator>Gao, Bin ; He, Zhuomin ; Sharma, Puru ; Kang, Qingxuan ; Jevdjic, Djordje ; Deng, Junbo ; Yang, Xingkun ; Yu, Zhou ; Zuo, Pengfei</creator><creatorcontrib>Gao, Bin ; He, Zhuomin ; Sharma, Puru ; Kang, Qingxuan ; Jevdjic, Djordje ; Deng, Junbo ; Yang, Xingkun ; Yu, Zhou ; Zuo, Pengfei</creatorcontrib><description>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%.</description><identifier>DOI: 10.48550/arxiv.2403.19708</identifier><language>eng</language><subject>Computer Science - Computation and Language ; Computer Science - Learning</subject><creationdate>2024-03</creationdate><rights>http://creativecommons.org/licenses/by/4.0</rights><oa>free_for_read</oa><woscitedreferencessubscribed>false</woscitedreferencessubscribed></display><links><openurl>$$Topenurl_article</openurl><openurlfulltext>$$Topenurlfull_article</openurlfulltext><thumbnail>$$Tsyndetics_thumb_exl</thumbnail><link.rule.ids>228,230,776,881</link.rule.ids><linktorsrc>$$Uhttps://arxiv.org/abs/2403.19708$$EView_record_in_Cornell_University$$FView_record_in_$$GCornell_University$$Hfree_for_read</linktorsrc><backlink>$$Uhttps://doi.org/10.48550/arXiv.2403.19708$$DView paper in arXiv$$Hfree_for_read</backlink></links><search><creatorcontrib>Gao, Bin</creatorcontrib><creatorcontrib>He, Zhuomin</creatorcontrib><creatorcontrib>Sharma, Puru</creatorcontrib><creatorcontrib>Kang, Qingxuan</creatorcontrib><creatorcontrib>Jevdjic, Djordje</creatorcontrib><creatorcontrib>Deng, Junbo</creatorcontrib><creatorcontrib>Yang, Xingkun</creatorcontrib><creatorcontrib>Yu, Zhou</creatorcontrib><creatorcontrib>Zuo, Pengfei</creatorcontrib><title>Cost-Efficient Large Language Model Serving for Multi-turn Conversations with CachedAttention</title><description>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%.</description><subject>Computer Science - Computation and Language</subject><subject>Computer Science - Learning</subject><fulltext>true</fulltext><rsrctype>article</rsrctype><creationdate>2024</creationdate><recordtype>article</recordtype><sourceid>GOX</sourceid><recordid>eNqFjrEOgjAYhLs4GPUBnOwLgFUg4mgajINMuhrSQAt_gq35-4P69iJxd7m7XC6Xj7HlRoRxmiRirfAFfbiNRRRu9juRTtlNOk9BZgyUoC3xs8JaD2rrTg0hd5Vu-UVjD7bmxiHPu5YgoA4tl872Gr0icNbzJ1DDpSobXR2Ihq-hnbOJUa3Xi5_P2OqYXeUpGEGKB8Jd4bv4AhUjUPR_8QGLXUGo</recordid><startdate>20240323</startdate><enddate>20240323</enddate><creator>Gao, Bin</creator><creator>He, Zhuomin</creator><creator>Sharma, Puru</creator><creator>Kang, Qingxuan</creator><creator>Jevdjic, Djordje</creator><creator>Deng, Junbo</creator><creator>Yang, Xingkun</creator><creator>Yu, Zhou</creator><creator>Zuo, Pengfei</creator><scope>AKY</scope><scope>GOX</scope></search><sort><creationdate>20240323</creationdate><title>Cost-Efficient Large Language Model Serving for Multi-turn Conversations with CachedAttention</title><author>Gao, Bin ; He, Zhuomin ; Sharma, Puru ; Kang, Qingxuan ; Jevdjic, Djordje ; Deng, Junbo ; Yang, Xingkun ; Yu, Zhou ; Zuo, Pengfei</author></sort><facets><frbrtype>5</frbrtype><frbrgroupid>cdi_FETCH-arxiv_primary_2403_197083</frbrgroupid><rsrctype>articles</rsrctype><prefilter>articles</prefilter><language>eng</language><creationdate>2024</creationdate><topic>Computer Science - Computation and Language</topic><topic>Computer Science - Learning</topic><toplevel>online_resources</toplevel><creatorcontrib>Gao, Bin</creatorcontrib><creatorcontrib>He, Zhuomin</creatorcontrib><creatorcontrib>Sharma, Puru</creatorcontrib><creatorcontrib>Kang, Qingxuan</creatorcontrib><creatorcontrib>Jevdjic, Djordje</creatorcontrib><creatorcontrib>Deng, Junbo</creatorcontrib><creatorcontrib>Yang, Xingkun</creatorcontrib><creatorcontrib>Yu, Zhou</creatorcontrib><creatorcontrib>Zuo, Pengfei</creatorcontrib><collection>arXiv Computer Science</collection><collection>arXiv.org</collection></facets><delivery><delcategory>Remote Search Resource</delcategory><fulltext>fulltext_linktorsrc</fulltext></delivery><addata><au>Gao, Bin</au><au>He, Zhuomin</au><au>Sharma, Puru</au><au>Kang, Qingxuan</au><au>Jevdjic, Djordje</au><au>Deng, Junbo</au><au>Yang, Xingkun</au><au>Yu, Zhou</au><au>Zuo, Pengfei</au><format>journal</format><genre>article</genre><ristype>JOUR</ristype><atitle>Cost-Efficient Large Language Model Serving for Multi-turn Conversations with CachedAttention</atitle><date>2024-03-23</date><risdate>2024</risdate><abstract>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%.</abstract><doi>10.48550/arxiv.2403.19708</doi><oa>free_for_read</oa></addata></record>
fulltext fulltext_linktorsrc
identifier DOI: 10.48550/arxiv.2403.19708
ispartof
issn
language eng
recordid cdi_arxiv_primary_2403_19708
source arXiv.org
subjects Computer Science - Computation and Language
Computer Science - Learning
title Cost-Efficient Large Language Model Serving for Multi-turn Conversations with CachedAttention
url https://sfx.bib-bvb.de/sfx_tum?ctx_ver=Z39.88-2004&ctx_enc=info:ofi/enc:UTF-8&ctx_tim=2025-01-28T23%3A48%3A09IST&url_ver=Z39.88-2004&url_ctx_fmt=infofi/fmt:kev:mtx:ctx&rfr_id=info:sid/primo.exlibrisgroup.com:primo3-Article-arxiv_GOX&rft_val_fmt=info:ofi/fmt:kev:mtx:journal&rft.genre=article&rft.atitle=Cost-Efficient%20Large%20Language%20Model%20Serving%20for%20Multi-turn%20Conversations%20with%20CachedAttention&rft.au=Gao,%20Bin&rft.date=2024-03-23&rft_id=info:doi/10.48550/arxiv.2403.19708&rft_dat=%3Carxiv_GOX%3E2403_19708%3C/arxiv_GOX%3E%3Curl%3E%3C/url%3E&disable_directlink=true&sfx.directlink=off&sfx.report_link=0&rft_id=info:oai/&rft_id=info:pmid/&rfr_iscdi=true