arXiv:2512.16822cs.LG2025-12被引 7

通过页对齐与位置无关缓存,显著降低大模型服务中的显存占用。

MEPIC: Memory Efficient Position Independent Caching for LLM Serving

  • 将缓存块对齐到页存储,支持跨请求、跨位置的缓存复用。
  • 减少重复缓存数据,长提示场景下显存节省最高达5倍。
  • 无需修改模型即可实现,适合高并发大模型推理服务。

现代大模型应用如深度研究助手、代码代理和检索增强生成(RAG)系统,反复处理包含共享文档或代码片段的长提示历史,对键值(KV)缓存造成巨大压力,需在有限内存下维持高吞吐和低延迟。前缀缓存虽可部分缓解成本,但受限于严格的前缀匹配。位置无关缓存(PIC)允许在任意位置进行块级复用,但需选择性重计算和位置编码(PE)调整,导致相同块在不同请求中缓存内容差异,且无页对齐时内存布局不一致,无法共享页。这使得即使大量请求复用相同内容,显存节省仍有限。本文提出MEPIC,一种高效的PIC系统,通过将块缓存对齐至分页存储,将重计算从令牌级降至块级(仅首个块请求相关),在注意力核中融合旋转位置编码(RoPE),使其余块完全可共享。这些技术消除了大部分重复块的缓存,相比现有最优PIC,显存使用减少最多2倍,长提示下最高达5倍,且保持相近延迟与精度,无需模型改动。

原文摘要 · Abstract (English)

Modern LLM applications such as deep-research assistants, coding agents, and Retrieval-Augmented Generation (RAG) systems, repeatedly process long prompt histories containing shared document or code chunks, creating significant pressure on the Key Value (KV) cache, which must operate within limited memory while sustaining high throughput and low latency. Prefix caching partially alleviates some of these costs by reusing KV cache for previously processed tokens, but limited by strict prefix matching. Position-independent caching (PIC) enables chunk-level reuse at arbitrary positions, but requires selective recomputation and positional-encoding (PE) adjustments. However, because these operations vary across queries, KV for the same chunk diverges across requests. Moreover, without page alignment, chunk KV layouts diverge in memory, preventing page sharing. These issues result in only modest HBM savings even when many requests reuse the same content. We present MEPIC, a memory-efficient PIC system that enables chunk KV reuse across positions, requests, and batches. MEPIC aligns chunk KV to paged storage, shifts recomputation from token- to block-level so only the first block is request-specific, removes positional encodings via Rotary Position Embedding (RoPE) fusion in the attention kernel, and makes remaining blocks fully shareable. These techniques eliminate most duplicate chunk KV in HBM, reducing usage by up to 2x over state-of-the-art PIC at comparable latency and accuracy, and up to 5x for long prompts, without any model changes.

大模型推理显存优化缓存机制

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