[论文解读] LLM as a System Service on Mobile Devices
本文提出 LLMS,一种系统服务设计,通过分块 KV 缓存压缩和换出实现对设备上 LLM 上下文的管理,以在应用之间实现低延迟、持久的 LLM 服务。它在基线之上实现了高达两个数量级的切换延迟下降,并在不损失准确性的情况下带来显著改进。
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 作为移动设备的系统服务(LLMaaS)来提升隐私、可用性和效率的动机。
- 强调持久 LLM 上下文的内存瓶颈以及传统应用级内存管理的不足。
- 将 LLMS 作为一个内存管理框架,解耦应用内存与 LLM 上下文内存。
- 开发新技术,在受限内存条件下最大化上下文切换性能。
提出的方法
- 将 KV 缓存划分为固定大小的块(如 16 个 token),实现独立压缩和换出。
- 应用容忍度感知压缩,对信息密度较低的块分配更高的压缩比。
- 引入换出-重计算流水线,在上下文加载期间将重计算与 I/O 重叠。
- 使用块生命周期管理策略,设置 LCTRU 驱逐队列并实现提前换出以隐藏回收延迟。
- 提供类似 Android-Service 的 API 设计,应用持有 LLMCtx 上下文并通过 callLLM 进行交互。
- 在搭载 Llama2-7B/OPT-7B 的 72 小时轨迹上,基于商用设备(COTS)进行经验评估,并与 LMK、磁盘换出和 vLLM 基线进行对比。

实验结果
研究问题
- RQ1在将 LLM 作为系统服务暴露时,如何在移动设备上高效管理 LLM 上下文内存?
- RQ2哪种分块、压缩和调度策略在保持准确性的同时能最小化上下文切换延迟?
- RQ3换出-重计算流水线与基于 LCTRU 的驱逐策略是否能超越传统应用级内存管理在 LLM 上下文中的表现?
- RQ4相较于基线,在真实设备轨迹及常见 LLMs 下,LLMS 的性能提升是多少?
主要发现
- 与传统应用级内存管理和磁盘换出基线相比,LLMS 将 LLM 上下文切换延迟降低最多 100 倍(两数量级)。
- 与静态 8 位量化的最先进 vLLM 相比,LLMS 实现最多 20 倍的切换延迟降低,平均约 9.7 倍。
- 使用 LLMS 的分块式容忍感知压缩时,在 6 个数据集上未观察到任何准确性损失。
- LLMS 在 Jetson Orin NX、Jetson TX2 和 MI14 智能手机上实现了在 Llama2-7B 和 OPT-7B 的设备端 LLMaaS 的可行性。
- 该方法利用 KV 缓存的独特属性(分块结构、可压缩性和可重计算性)来优化上下文管理。

更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。