LLM as a System Service on Mobile Devices

Wangsong Yin, Mengwei Xu, Yuanchun Li, Xuanzhe Liu
{"title":"LLM as a System Service on Mobile Devices","authors":"Wangsong Yin, Mengwei Xu, Yuanchun Li, Xuanzhe Liu","doi":"arxiv-2403.11805","DOIUrl":null,"url":null,"abstract":"Being more powerful and intrusive into user-device interactions, LLMs are\neager for on-device execution to better preserve user privacy. In this work, we\npropose a new paradigm of mobile AI: LLM as a system service on mobile devices\n(LLMaaS). Unlike traditional DNNs that execute in a stateless manner, such a\nsystem service is stateful: LLMs execution often needs to maintain persistent\nstates (mainly KV cache) across multiple invocations. To minimize the LLM\ncontext switching overhead under tight device memory budget, this work presents\nLLMS, which decouples the memory management of app and LLM contexts with a key\nidea of fine-grained, chunk-wise, globally-optimized KV cache compression and\nswapping. By fully leveraging KV cache's unique characteristics, it proposes\nthree novel techniques: (1) Tolerance-Aware Compression: it compresses chunks\nbased on their measured accuracy tolerance to compression. (2) IO-Recompute\nPipelined Loading: it introduces recompute to swapping-in for acceleration. (3)\nChunk Lifecycle Management: it optimizes the memory activities of chunks with\nan ahead-of-time swapping-out and an LCTRU (Least Compression-Tolerable and\nRecently-Used) queue based eviction. In evaluations conducted on\nwell-established traces and various edge devices, \\sys reduces context\nswitching latency by up to 2 orders of magnitude when compared to competitive\nbaseline solutions.","PeriodicalId":501333,"journal":{"name":"arXiv - CS - Operating Systems","volume":"147 1","pages":""},"PeriodicalIF":0.0000,"publicationDate":"2024-03-18","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"arXiv - CS - Operating Systems","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/arxiv-2403.11805","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0

Abstract

Being more powerful and intrusive into user-device interactions, LLMs are eager for on-device execution to better preserve user privacy. In this work, we propose a new paradigm of mobile AI: LLM as a system service on mobile devices (LLMaaS). Unlike traditional DNNs that execute in a stateless manner, such a system service is stateful: LLMs execution often needs to maintain persistent states (mainly KV cache) across multiple invocations. To minimize the LLM context switching overhead under tight device memory budget, this work presents LLMS, which decouples the memory management of app and LLM contexts with a key idea of fine-grained, chunk-wise, globally-optimized KV cache compression and swapping. By fully leveraging KV cache's unique characteristics, it proposes three novel techniques: (1) Tolerance-Aware Compression: it compresses chunks based on their measured accuracy tolerance to compression. (2) IO-Recompute Pipelined Loading: it introduces recompute to swapping-in for acceleration. (3) Chunk Lifecycle Management: it optimizes the memory activities of chunks with an ahead-of-time swapping-out and an LCTRU (Least Compression-Tolerable and Recently-Used) queue based eviction. In evaluations conducted on well-established traces and various edge devices, \sys reduces context switching latency by up to 2 orders of magnitude when compared to competitive baseline solutions.
作为移动设备系统服务的 LLM
由于 LLM 功能更强大,对用户与设备的交互更具侵入性,因此 LLM 渴望在设备上执行,以更好地保护用户隐私。在这项工作中,我们提出了一种新的移动人工智能范式:LLM 作为移动设备上的系统服务(LLMaaS)。与以无状态方式执行的传统 DNN 不同,这种系统服务是有状态的:LLM 的执行通常需要在多次调用中保持持久状态(主要是 KV 缓存)。为了在设备内存预算紧张的情况下最大限度地减少 LLM 上下文切换的开销,这项工作提出了LLMS,通过细粒度、分块、全局优化的 KV 缓存压缩和交换这一关键理念,将应用程序和 LLM 上下文的内存管理分离开来。通过充分利用 KV 缓存的独特特性,它提出了三项新技术:(1)容忍度感知压缩:它根据测量到的压缩精度容忍度来压缩数据块。(2) IO-重新计算管道式加载:将重新计算引入交换加速。(3) 块生命周期管理:通过提前换出和基于队列的 LCTRU(最小压缩容忍度和最近使用量)驱逐,优化块的内存活动。在对完善的跟踪和各种边缘设备进行的评估中,与竞争性的基准解决方案相比,\sys最多可将上下文切换延迟降低两个数量级。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术官方微信