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

随机KV路由:实现自适应深度-wise缓存共享

Stochastic KV Routing: Enabling Adaptive Depth-Wise Cache Sharing

Apple(苹果公司)

Anastasiia Filippova, David Grangier, Marco Cuturi, João Monteiro

AI总结:

本文提出通过随机跨层注意力机制实现高效的深度-wise缓存共享,减少内存占用并提升推理效率。

摘要:

为提高Transformer语言模型的吞吐量,需要缓存键值(KVs)以避免自回归生成中的冗余计算。KV缓存的内存开销显著且严重影响服务成本。本文提出减少这些内存需求的方法。尽管近期工作主要通过时间轴上的压缩和驱逐来减少KV缓存,我们认为深度维度提供了另一种正交且稳健的优化途径。虽然先前研究认为每层都拥有完整的缓存是冗余的,但实现跨层缓存共享仍是一个实际挑战;现有方法通常导致吞吐量降低或首次令牌生成时间增加。本文证明,丢弃一层的缓存可在不损失信息的情况下实现高效优化。我们提出了一种简单的训练方法:随机跨层注意力。在训练过程中,各层随机选择关注自身或前一层的KV状态。这种随机过程使模型对各种深度-wise缓存共享策略具有鲁棒性,确保部署时的灵活性。我们的评估表明,应用此方案在预训练或微调期间可为各种模型家族实现深度-wise缓存共享。此外,对于数据受限情况下较大的模型,这种方法具有类似于正则化的效果,经常保持或提高性能,同时显著减少缓存的内存开销。

英文摘要:

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 \emph{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.

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

↑