浅层预填,深层解码:通过层不对称的KV可见性实现高效的长上下文推理
Shallow Prefill, Deep Decoding: Efficient Long-Context Inference via Layer-Asymmetric KV Visibility
AI总结:
本文提出SPEED方法,通过不对称的KV可见性策略,仅在低层保留非锚定提示词的KV状态,从而在保持解码阶段全深度的同时降低长上下文推理成本,提升效率。
摘要:
在仅含解码器的语言模型中,长上下文推理成本高,因为长提示在预填阶段被处理、在每层缓存,并在自回归解码阶段被重复关注。我们引入浅层预填,深层解码(SPEED),一种相位不对称的KV可见性策略,该策略仅在低层保留非锚定提示词的KV状态,同时保持解码阶段的完整深度。与之前使上层提示KV状态存储或构造更便宜的方法不同,SPEED彻底移除预填token从上层解码阶段的可见性集。通过最小的BoS锚点,这一简单改变在保持广泛基准质量的同时降低了长上下文成本。在受控的Llama-3.1-8B指令微调研究中,SPEED仅使用75%的层处理预填token,在OLMES风格基准上达到51.2的平均得分,与全深度基线的51.4相比,同时提升了TTFT 33%,TPOT 22%,并减少了25.0%的活跃KV内存,在128K上下文中。逐层诊断表明,这种截断保留了全深度模型的主要提示选择和表示稳定化区域。这些结果表明,长上下文提示token并不总是需要保持为全深度KV缓存对象,只要解码阶段token保持全深度。
英文摘要:
Long-context inference in decoder-only language models is costly because long prompts are processed during Prefill, cached at every layer, and repeatedly attended to during autoregressive Decode. We introduce \emph{Shallow Prefill, dEEp Decode} (SPEED), a phase-asymmetric KV-visibility policy that materializes non-anchor prompt-token KV states only in lower layers while keeping Decode-phase tokens full-depth. Unlike previous approaches that make upper-layer prompt KV states cheaper to store or construct, SPEED removes prefill tokens from the upper-layer Decode visibility set altogether. With a minimal BoS anchor, this simple change preserves broad benchmark quality while reducing long-context cost. In a controlled Llama-3.1-8B instruction-tuning study, SPEED using only 75\% of layers for prefill tokens reaches 51.2 average score on OLMES-style benchmarks, compared with 51.4 for the full-depth baseline, while improving TTFT by 33\%, TPOT by 22\%, and reducing active KV memory by 25.0\% at 128K context. Layer-wise diagnostics suggest that this cutoff retains the main prompt-selection and representation-stabilization regions of the full-depth model. These results show that long-context prompt tokens need not always persist as full-depth KV-cache objects when Decode-phase tokens remain full-depth.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。