Skip to main content
QUICK REVIEW

[论文解读] Accelerating LLM Inference with Staged Speculative Decoding

Benjamin Spector, Chris Ré|arXiv (Cornell University)|Aug 8, 2023
Topic ModelingComputer Science被引用 9
一句话总结

论文提出分阶段猜测解码,结合树形结构的猜测批次与二阶段草案模型,以在保持输出质量的同时加速小批量设备端大模型推断,在 GPT-2-L 上实现最高 3.16x 的加速。

ABSTRACT

Recent advances with large language models (LLM) illustrate their diverse capabilities. We propose a novel algorithm, staged speculative decoding, to accelerate LLM inference in small-batch, on-device scenarios. We address the low arithmetic intensity of small-batch inference by improving upon previous work in speculative decoding. First, we restructure the speculative batch as a tree, which reduces generation costs and increases the expected tokens per batch. Second, we add a second stage of speculative decoding. Taken together, we reduce single-batch decoding latency by 3.16x with a 762M parameter GPT-2-L model while perfectly preserving output quality.

研究动机与目标

  • 解决设备上小批量大模型推理的低算术强度问题。
  • 在不牺牲模型分布忠实度的前提下,扩展猜测解码以提高吞吐量。
  • 提升对延迟敏感且注重隐私的实际设备端大模型性能。

提出的方法

  • 将猜测批次重新表述为树形结构,以增加每批的期望 token 数并实现并行性。
  • 通过增加草案 2 模型引入猜测解码的第二阶段以加速解码。
  • 在树形结构批次下,在 oracle、草案和草案-2 模型之间进行采样与解码,以最大化叶节点数量并复用 KV 缓存。
Figure 1: A roofline plot for single-query GPT-2-L inference on an RTX 4090. At small batch sizes, inference is completely memory bandwidth bound. Thus this plot shows that the only way to significantly increase performance is to increase the arithmetic intensity of inference.
Figure 1: A roofline plot for single-query GPT-2-L inference on an RTX 4090. At small batch sizes, inference is completely memory bandwidth bound. Thus this plot shows that the only way to significantly increase performance is to increase the arithmetic intensity of inference.

实验结果

研究问题

  • RQ1树形结构的猜测批次是否能增加每批 token 数并降低小批量大模型推理的带宽需求?
  • RQ2加入第二阶段草案模型是否会在不改变输出分布的情况下进一步加速解码?
  • RQ3相较于基线和标准猜测解码,在设备端硬件上分阶段猜测解码的观察到的加速和带宽降低是多少?

主要发现

  • 分阶段猜测解码在确定性解码(GPT-2-L 7.62B 参数)在 RTX 4090 上对基线单批推理实现了平均 3.16x 的加速。
  • 分阶段猜测解码相对于基线和标准猜测解码在内存带宽方面的降低(确定性:0.23x 对比 1.00 基线;0.31x 对比 0.23x 分阶段,基线与 0.23x 分阶段;Topk:0.35x 分阶段对比 0.48x 猜测解码)。
  • 在 Top-k 采样(k=50,T=1)下,分阶段猜测解码相对于基线平均提升 1.98x,相对于标准猜测解码提升 1.36x。
  • 该方法在对 HumanEval 提示的不同难度内容下表现出更高的吞吐量,强调收益随内容熵变化而变化。
Figure 2: Relative performance distribution over different problems in the HumanEval dataset. (A) shows greedy decoding, whereas (B) shows Topk decoding. Problem indices are sorted by staged speculative performance for clarity.
Figure 2: Relative performance distribution over different problems in the HumanEval dataset. (A) shows greedy decoding, whereas (B) shows Topk decoding. Problem indices are sorted by staged speculative performance for clarity.

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。