arXiv:2607.21535cs.LGcs.CL2026-07

让长文本生成更快:用滑动窗口降低推理开销

Windowed-MTP: Removing the Full-Context Draft-KV Tax at Million-Token Context

论文配图:Windowed-MTP: Removing the Full-Context Draft-KV Tax at Million-Token Context
图 1 · 摘自论文原文
  • 仅对草稿阶段引入滑动窗口与注意力池,不改变验证过程
  • 百万级上下文下节省99%的键值缓存读取,提速28%至44%
  • 无需训练、可直接部署,适合长文本生成场景

推测解码通过廉价草稿生成候选词并由目标模型并行验证来加速自回归生成。当前主流模型内置多标记预测(MTP)草稿头,假设其开销可忽略。但在百万级上下文时,该机制需在每步草稿中对完整键值缓存执行全注意力计算,导致读取成本随上下文线性增长,反而成为瓶颈——这正是推测解码最需要优化的场景。该问题在长草稿或混合/线性注意力目标下尤为严重。本文提出Windowed-MTP:仅对草稿注意力使用流式LLM风格的滑动窗口和注意力池,保留完整注意力验证。该方法无需训练、可直接替换,且保证输出不变。它将草稿的键值缓存工作集限制为常数,在100万上下文时减少约99%的缓存条目。在Qwen GDN-MoE 35B/122B及Mamba2-hybrid NoPE 120B三种架构上,单卡环境下每解码步成本下降28%至44%,该收益随上下文增长而提升。由于每标记延迟为成本除以接受长度,相同接受率下端到端延迟改善相当;当窗口提升接受率时收益更显著,且保持目标模型的输出分布。未读取的草稿键值缓存(100万上下文时占总缓存7.7%-11%)可通过紧凑环形缓冲区回收,无接受率或质量损失。

原文摘要 · Abstract (English)

Speculative decoding accelerates autoregressive generation by having a cheap draft propose tokens that a target verifies in parallel. Frontier models increasingly ship a built-in Multi-Token-Prediction (MTP/NEXTN) draft head under the assumption that the draft is negligibly cheap. At million-token context this breaks: an MTP draft head typically runs full attention over the entire KV cache at every draft step, so its read grows linearly with context and comes to dominate the draft cost -- precisely where speculation is most valuable. The effect compounds with draft length (a deep native draft can turn net-negative, slower than no speculation) and sharpens under hybrid/linear-attention targets, where cheaper verification leaves the draft's full-attention read exposed. We apply a StreamingLLM-style sliding window plus attention sink to the draft's attention only (Windowed-MTP), leaving full-attention verification intact. It is training-free, drop-in, and lossless by construction: the full-attention target still decides every accepted token, so windowing changes only which tokens are proposed, never which are accepted. It bounds the draft's KV working set to a constant, dropping ~99% of KV entries at 1M. Across three architecture families (Qwen GDN-MoE 35B/122B and a Mamba2-hybrid NoPE 120B) at 1M context on a single GPU in SGLang, windowing cuts the per-decode-step cost over the shipping native MTP draft by +28% to +44%, an input-invariant margin that widens with context. Since per-token latency is this cost divided by acceptance length, at matched acceptance end-to-end decode latency improves by the same amount, and more where windowing also lifts acceptance, while preserving the target's verified output distribution. Finally, the unread draft KV -- 7.7-11% of total KV at 1M -- is reclaimed via a compact ring buffer at no acceptance or quality cost.

推理优化长文本生成注意力机制滑动窗口

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