跳到正文
北京时间
原文
Apple Machine Learning Research(RSS)·· 2026-05-05精选AI 评分59

Stochastic KV Routing: 实现自适应深度方向的缓存共享

Stochastic KV Routing: Enabling Adaptive Depth-Wise Cache Sharing

AI 导读

为降低大语言模型推理时KV缓存的高昂内存开销,研究提出了一种沿模型深度维度优化的新方法。该方法通过随机KV路由,在Transformer模型的各层之间动态共享KV缓存,而非每层保留完整独立缓存。实验表明,在保持模型质量基本不变的前提下,该方法能将KV缓存的内存占用减少高达50%,为降低大模型服务成本提供了与现有时间轴压缩、淘汰技术正交的新优化路径。

推荐理由

苹果这篇不走寻常路,从深度维度压缩KV缓存,是推理服务端降本的新思路,做LLM部署的值得一读。

正文

Serving transformer language models with high throughput requires caching Key-Values (KVs) to avoid redundant computation during autoregressive generation. The memory footprint of KV caching is significant and heavily impacts serving costs. This work proposes to lessen these memory requirements. While recent work has largely addressed KV cache reduction via compression and eviction along the temporal axis, we argue that the depth dimension offers an orthogonal and robust avenue for optimization. Although prior research suggests that a full cache for every layer is redundant, implementing cross-layer cache sharing remains a practical challenge; existing methods typically suffer from reduced throughput or increased time-to-first-token. In this paper, we demonstrate that dropping a layer’s cache offers efficient optimization without information loss. We propose a simple training approach: random cross-layer attention. During training, layers randomly choose to attend either to their own KV states or those of a preceding layer. This stochastic process adapts the model to be robust to various depth-wise cache sharing strategies, ensuring flexibility for unknown hardware constraints at deployment time. Our evaluations show that applying this scheme during pre-training or fine-tuning enables depth-wise cache sharing for various model families. Furthermore, for larger models in data-constrained settings, this approach is suggestive of a regularization-like effect, frequently preserving or improving performance while significantly reducing the cache’s memory footprint.

来源:Apple Machine Learning Research(RSS) · machinelearning.apple.com