arXiv:2605.19049cs.LGcs.AI2026-05被引 1

通过缓存键值优化线性注意力推理,显著降低延迟与内存开销。

KVBuffer: IO-aware Serving for Linear Attention

  • 缓存近期键值,支持分块计算和并行验证
  • 推理延迟最高降低45.17%,推测解码并发数提升5倍
  • 适合长文本生成、高并发推理场景

线性注意力因解码代价与上下文长度无关,近年来在长上下文推理中备受关注。然而,现有服务系统通常在每步解码中反复计算并更新一个庞大的线性注意力状态,由于该状态远大于单个标记的键值,导致大量内存访问,效率低下。本文提出KVBuffer,一种面向输入输出(IO)的线性注意力服务机制。通过缓存近期键值,KVBuffer使系统能更灵活、高效地计算线性注意力输出:解码时支持分块计算,推迟状态更新并批量处理,降低平均内存访问和解码延迟;推测解码时可并行验证候选词,避免临时状态存储;短上下文场景下可直接从缓冲键值计算注意力输出,无需创建或更新状态。我们在SGLang中实现KVBuffer以支持Qwen3-Next。评估表明,相比基线,KVBuffer可将线性注意力解码延迟最多降低45.17%,在验证四个草案词时,推测解码最大请求数提升5倍。

原文摘要 · Abstract (English)

Linear attention has recently gained significant attention for long-context inference due to its constant decoding cost with respect to context length. However, existing serving systems typically serve linear attention by recurrently computing and updating a large linear attention state in every decoding step. Since the state is much larger than the per-token key and value, recurrent decoding incurs substantial memory access and becomes inefficient for serving linear attention. In this paper, we propose KVBuffer, an IO-aware serving mechanism for linear attention. By buffering recent keys and values, KVBuffer enables serving systems to compute linear attention outputs in more flexible and memory-efficient ways. For decoding, KVBuffer enables chunkwise computation, which reduces average memory access and decoding latency by deferring state updates and applying them in batch. For speculative decoding, KVBuffer verifies draft tokens in parallel and avoids storing temporary states. For short contexts, KVBuffer computes attention outputs directly from buffered keys and values, without creating or updating the linear attention state. We implement KVBuffer in SGLang for Qwen3-Next. Our evaluations show that KVBuffer can reduce linear attention decoding latency by up to 45.17% and increase the maximum number of serving requests by 5x for speculative decoding when verifying four draft tokens.

线性注意力推理优化缓存机制高并发

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