概述
Exact speculative sampling can preserve the target distribution, but speedup depends on draft cost, acceptance rate, batching and hardware.
深入探討
Normally an LLM generates text one token at a time: each token requires a full forward pass through the giant model, and you can't start the next until the current one finishes. For large models at low batch sizes, decoding can be memory-bandwidth bound: each token step reads many weights, so moving data may dominate arithmetic. Other batch sizes and workloads can have different bottlenecks. Speculative decoding breaks the bottleneck. A small, cheap draft model proposes a chunk of, say, five candidate tokens. The large 'target' model then processes all five in a single parallel forward pass and checks them. In greedy decoding, the target accepts the matching prefix and uses its own token at the first mismatch, discarding the remaining draft. Exact sampling uses a rejection-sampling correction to preserve the target distribution; acceptance is not always simple token equality. The target can verify a drafted block in a parallel pass, but verification still costs computation. Net speedup depends on draft-model cost, how many tokens are accepted, and the hardware and workload.
現實世界的實施
7B 草案模型提出 70B 聊天模型的代幣,以減少生產助理中的回應延遲
Medusa 頭固定在 LLM 上,因此無需單獨的草稿模型即可同時預測多個未來代幣
vLLM 支援推測性解碼,以提高服務叢集上的每秒令牌吞吐量
在模型的隱藏特徵空間中進行 EAGLE 繪圖,以提高接受率和整體速度
推測解碼的未來
Serving frameworks offer speculative decoding and self-drafting variants, but the best method depends on the target model, workload and hardware. Systems should measure latency, throughput, acceptance rate, memory use and output-distribution requirements rather than assume a fixed speedup. Some methods use a separate drafter; others add heads or use feature-space proposals. Continued research is likely to improve these tradeoffs, but deployment gains must be measured on the actual service.
付諸實踐
為什麼這很重要
- 成本與預算. 多年來,架構決策決定著效能和營運成本。
- 更明確的決策. 技術教育幫助團隊選擇正確的堆疊,而不僅僅是最新的堆疊。
- 品質管控. 更好的工程選擇可以減少生產中的可靠性事故。
留意
- 優化一項基準測試可以隱藏更廣泛的系統弱點。
- 基礎設施和維護成本常常被低估。
- 隨著系統變得更加複雜,安全性和可觀察性差距可能會擴大。
後續步驟
- 在實施之前定義延遲、品質和成本目標。
- 在實際負載和資料條件下進行基準測試。
- 儀器監控錯誤、漂移和使用者影響。
- 在擴展之前準備回滾和事件回應路徑。
不斷探索
常見問題
什麼是推測解碼?
Speculative decoding can speed up large-model generation by letting a faster drafter propose tokens for a target model to verify in batches. Exact speculative sampling can preserve the target distribution, but speedup depends on draft cost, acceptance rate, batching and hardware.
推測性解碼如何加速大型模型的產生?
快速草稿模型提出多個令牌,大型目標模型在一次並行傳遞中檢查所有令牌。
For a large model at low batch size, why can one-token autoregressive decoding be slow?
For large models at low batch sizes, repeatedly reading weights can dominate arithmetic, though the bottleneck depends on workload.
In greedy speculative decoding, what happens at the first token where draft and target predictions disagree?
In greedy verification, the target corrects the first mismatch and the remaining drafted suffix is discarded; exact sampling uses a rejection-sampling correction instead.
Under exact speculative sampling, how does the output distribution compare with sampling from the target model alone?
The exact rejection-sampling correction preserves the target model’s distribution; this is distinct from relaxed variants.
最直接決定推測解碼加速的因素是什麼?
目標模型每個驗證步驟接受的起草令牌越多,加速越大。