arXiv:2609.02029cs.AI2026-09

通过分头缓存调度,让长文本模型在不损失质量的前提下减少显存占用。

HeadWiseKV: Budgeted Per-Head Cache Residency for Hybrid Long-Context Language Models

  • 按注意力头分配动态缓存窗口,提前预判显存需求。
  • 在112K上下文长度下降低峰值显存8.59%,最长支持161K上下文。
  • 无需训练,适配多种混合型长文本模型,适合部署优化场景。

长上下文推理需持续保留键值(KV)缓存,占用大量GPU显存并降低生成吞吐量。这一瓶颈在混合语言模型中依然存在,因其残差全局注意力层会主导上下文相关的缓存需求。本文研究在总KV驻留预算下的缓存分配策略,提出HeadWiseKV——一种无需训练的框架,可压缩混合模型的残差全局KV缓存,同时保留其原有的局部、循环和线性路径。该方法为每个物理KV头分配静态多级历史窗口,使缓存需求在服务前即可预测。将此分配建模为受限的操作率-失真问题,并提出核心算法SeqCalib:按执行顺序处理层,每层决策依赖于下层部署时的实际策略,从而考虑深度间的交互。分组缓存运行时将选定策略实现为实际的每头缓存驻留,而非对完整缓存的掩码。在四个混合长上下文模型上评估下游质量,并在Qwen3.6-27B上分析物理驻留与服务行为。HeadWiseKV在所有模型上保持接近全缓存的RULER和LoCoMo质量。在固定模型系统研究中,112K上下文长度下采样峰值设备内存减少8.59%,最大成功验证上下文从114K扩展至161K。

原文摘要 · Abstract (English)

Long-context inference retains a growing key--value (KV) cache during decoding, which consumes substantial GPU memory and can reduce generation throughput. This bottleneck remains in hybrid language models because their residual global-attention layers can dominate context-dependent cache demand. We study how to allocate this state under an aggregate KV-residency budget. We introduce HeadWiseKV, a training-free framework that compresses the residual global KV caches of hybrid language models while preserving their native local, recurrent, and linear paths. It assigns each physical KV head a static, multilevel history window, making cache demand predictable before serving. We formulate this allocation as a restricted operational rate--distortion problem and propose SeqCalib as the core policy-generation algorithm in HeadWiseKV. SeqCalib processes layers in execution order and conditions each decision on the lower-layer policy used at deployment, thereby accounting for interactions across depth. A grouped-cache runtime materializes the selected policy as actual per-head KV residency rather than a mask over a full cache. We evaluate downstream quality across four hybrid long-context models and study physical residency and serving behavior on Qwen3.6-27B. HeadWiseKV retains near-Full-KV RULER and LoCoMo quality across the evaluated models. In the fixed-model systems study, it reduces sampled peak device memory by 8.59\% at a 112K context length and extends the largest verified successful context from 114K to 161K.

缓存优化长文本生成显存压缩混合模型

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