arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2511.11907cs.DCcs.AI
收藏

KVSwap: 为长上下文本地推理的磁盘感知KV缓存卸载

KVSwap: Disk-aware KV Cache Offloading for Long-Context On-device Inference

University of Leeds(利兹大学)

Huawei Zhang, Chunwei Xia, Zheng Wang

AI总结:

KVSwap通过磁盘感知技术提升本地长上下文推理的内存效率和吞吐量,同时保持生成质量。

摘要:

语言模型(LMs)支撑着新兴的移动和嵌入式AI应用,如会议和视频摘要以及文档分析,这些应用通常需要处理多个长上下文输入。在设备上本地运行LM可以提高隐私性,实现离线使用,并降低成本,但长上下文推理很快会遇到一个内存容量墙,因为关键值(KV)缓存随着上下文长度和批量大小线性增长。现有的KV缓存卸载方案旨在将缓存数据从GPU内存转移到CPU内存;然而,它们不适用于嵌入式和移动系统,其中CPU和GPU(或NPU)通常共享统一内存,而非易失性二次存储(磁盘)提供的I/O带宽有限。我们提出了KVSwap,一个专为本地设备设计的软件框架,能够在高内存效率的同时有效利用磁盘存储。KVSwap将完整的缓存存储在磁盘上,使用高度紧凑的内存元数据来预测哪些条目需要预加载,重叠计算与硬件感知的磁盘访问,并协调读取模式以匹配存储设备特性。我们的评估显示,在代表性的LM和存储类型上,KVSwap在紧缩的内存预算下提供更高的吞吐量,同时在现有KV缓存卸载方案上保持生成质量。

英文摘要:

Language models (LMs) underpin emerging mobile and embedded AI applications like meeting and video summarization and document analysis, which often require processing multiple long-context inputs. Running an LM locally on-device improves privacy, enables offline use, and reduces cost, but long-context inference quickly hits a \emph{memory capacity wall} as the key-value (KV) cache grows linearly with context length and batch size. Existing KV-cache offloading schemes are designed to transfer cache data from GPU memory to CPU memory; however, they are not suitable for embedded and mobile systems, where the CPU and GPU (or NPU) typically share a unified memory and the non-volatile secondary storage (disk) offers limited I/O bandwidth. We present KVSwap, a software framework tailored for local devices that achieves high memory efficiency while effectively leveraging disk storage. KVSwap stores the full cache on disk, uses highly compact in-memory metadata to predict which entries to preload, overlaps computation with hardware-aware disk access, and orchestrates read patterns to match storage device characteristics. Our evaluation shows that across representative LMs and storage types, KVSwap delivers higher throughput under tight memory budgets while maintaining generation quality over existing KV cache offloading schemes.

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

↑