arXiv:2511.11907cs.DCcs.AI2025-11被引 4

让手机端长文本生成更流畅,靠硬盘存缓存、智能预加载。

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

  • 缓存全存硬盘,内存只留压缩元数据,大幅节省显存
  • 预加载预测+计算重叠,实测在低内存下吞吐提升30%以上
  • 专为手机/嵌入式设备设计,适合离线长文本处理场景

语言模型支撑着会议摘要、视频分析和文档处理等移动与嵌入式AI应用,常需处理多个长上下文输入。本地运行模型可提升隐私性、支持离线使用并降低成本,但长上下文推理会迅速遭遇内存瓶颈——键值(KV)缓存随上下文长度和批大小线性增长。现有缓存卸载方案将数据从GPU内存移至CPU内存,但在嵌入式系统中不适用,因CPU与GPU(或NPU)共享统一内存,且非易失性二级存储(硬盘)的I/O带宽有限。我们提出KVSwap,一种专为本地设备设计的软件框架,在有效利用硬盘存储的同时实现高内存效率。该框架将完整缓存存于硬盘,用高度紧凑的内存元数据预测需预加载的条目,通过计算与硬件感知的磁盘访问重叠,并协调读取模式以匹配存储设备特性。评估显示,在典型语言模型和多种存储类型下,相比现有方案,KVSwap在严格内存限制下实现了更高吞吐量,同时保持生成质量。

原文摘要 · Abstract (English)

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.

长文本生成设备端推理缓存优化硬盘卸载

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。