Speculative Decoding in vLLM on AMD GPUs
144 points
• 7 days ago
• Article
Link
推测式解码是对大型语言模型的一种强力优化,用以克服标准自回归解码的效率瓶颈。基线方法在循环中每次只生成并确认一个 token,而推测式解码将流程拆成两个阶段:先由一个轻量级草稿模块提出一串候选 token,随后目标模型在一次前向中验证这些候选项。如果目标模型接受草稿的 token,系统即可一次性提交多个输出,从而显著提升吞吐量。
文章介绍了 vLLM 当前支持的五种具体草稿方法:native Multi-Token Prediction (MTP) 、 Gemma 4 MTP 、 EAGLE-3 、 DFlash 和 DSpark 。这些方法主要在于如何利用目标模型的信息以及如何生成候选 token 存在差异。例如,native MTP 使用模型本身的辅助路径,而 DFlash 和 DSpark 则采用专门的、以目标为条件的网络并行预测整块未来 token 。相比之下,EAGLE-3 依赖一种自回归机制,结合了目标 Transformer 不同阶段的隐层状态。
在 AMD Instinct™ MI300X 和 MI355X GPU 上的实验表明,推测式解码的效果高度依赖具体的模型家族、草稿检查点和目标工作负载。某些配置的吞吐量提升超过 2 倍,但并非所有数据集和模型都能获得一致的性能提高。推测 token 的数量(即 proposal length)是关键调参项:随着草稿 token 数量增加,吞吐量通常会上升,但到达某一点后会趋于平缓甚至下降,因为额外的草稿开销开始抵消验证成功带来的收益。
在实际落地时,推测式解码需要细致的观测和调优。文章建议监控吞吐量、平均被接受长度和各位置的接受率等指标,以确定最优配置。由于不同负载的 token 可预测性差异显著,通常没有一刀切的设置。推荐的流程是从已知配置出发,针对不同的 proposal length 进行扫描,找到最适合当前任务的平衡点。
最后,为新的目标模型训练定制的 speculator 是进一步提升性能的可行途径。该过程包括收集目标模型的代表性隐层状态来训练草稿组件,确保投机器与目标的内部表征对齐。通过让草稿模型的架构和训练数据与目标领域(例如数学或代码生成)相匹配,用户可以获得更高的接受率,从而在生产环境中实现更高的服务吞吐量。
Speculative decoding serves as a powerful optimization for large language models, addressing the efficiency limitations of standard autoregressive decoding. While the baseline approach generates and commits one token at a time in a repetitive loop, speculative decoding separates the process into two distinct phases. A lightweight draft component first proposes a sequence of candidate tokens, and the original target model then verifies these candidates in a single pass. If the target model accepts the draft tokens, the system commits multiple outputs simultaneously, significantly increasing throughput.
The article details five specific drafting methods currently supported in vLLM: native Multi-Token Prediction (MTP), Gemma 4 MTP, EAGLE-3, DFlash, and DSpark. These approaches differ primarily in how they leverage information from the target model and how they generate candidate tokens. For instance, native MTP uses a model-native auxiliary path, while DFlash and DSpark utilize dedicated, target-conditioned networks to predict entire blocks of future tokens in parallel. EAGLE-3, by contrast, relies on an autoregressive mechanism that incorporates hidden states from various stages of the target Transformer.
Experimental results on AMD Instinct™ MI300X and MI355X GPUs demonstrate that the impact of speculative decoding is highly dependent on the specific model family, draft checkpoint, and target workload. While some configurations showed throughput gains exceeding 2x, performance improvements were not uniform across all datasets and models. The number of speculative tokens, or the proposal length, proved to be a critical tuning variable. Throughput generally improved as more tokens were drafted, up to a point, after which it hit a plateau or declined because the overhead of additional drafting work began to outweigh the benefits of successful verification.
Practical implementation of speculative decoding requires careful observability and tuning. The article suggests that users monitor signals such as throughput, mean accepted length, and per-position acceptance rates to identify the optimal configuration. Because different workloads exhibit different token predictability, a one-size-fits-all setting is rarely sufficient. A recommended workflow involves starting from a known configuration and performing a sweep of different proposal lengths to find the balance that best suits the specific task at hand.
Finally, training a custom speculator for a new target model is a viable path for further performance gains. This process involves collecting representative hidden states from the target model to train the draft component, ensuring that the speculator is well-aligned with the target's internal representations. By matching the draft model's architecture and training data to the target's expected domain, such as mathematics or code generation, users can achieve better acceptance rates and, consequently, higher serving throughput in their production environments.
54 comments • Comments Link
- 工作站级的 AMD R9700 在官方支持上严重不足,因此不得不依赖 Radiance 等社区维护的分支才能获得有竞争力的推理速度。
- 长期的软件支持缺失和驱动不稳定让很多人在执行计算任务时对 AMD 硬件望而却步,哪怕 NVIDIA 的设备更贵,用户仍更倾向于选择 NVIDIA 。
- 有用户反馈称,借助社区开发的内核和 MXFP4 quantization 等技术,在 AMD 硬件上成功运行 Qwen 3.8-27B 等模型是可行的。
- 像 R4D kernel 这样的社区项目实现了高级的 tensor splitting 和其他性能优化,这在过去被认为在这些硬件上难以做到。
- 业界普遍认为 AMD 在面向 prosumer 和以 AI 为核心的用户群体方面缺乏明确的沟通和战略投入;当昂贵的硬件无法被官方软件充分利用时,用户自然会感到挫败。
- speculative decoding 的原理是使用较小的 draft model 并行预测 token 序列,然后由 target model 在一次 forward pass 中验证这些预测,从而有效摊薄内存受限带来的开销。
- 对 speculative tokens 的验证依赖比较 draft model 与 target model 的 probability distributions,这一比较可以高效并行完成,无需遵循传统的 autoregressive decoding 流程。
- 在 AMD 与 NVIDIA 硬件优劣的讨论中,观点依然分化:NVIDIA 提供开箱即用的成熟软件栈,而 AMD 往往需要依靠社区的深入调优才能达到相似的性能。
- 不同观察者眼中,LLM 的研究与部署既可能是极具变革性的技术突破,也可能被视为实用性有限的过度炒作。
总体来看,这场讨论揭示了 AMD 硬件潜力与缺乏可靠官方软件支持之间的巨大鸿沟——这种支持不足长期上定义了 AMD 与 AI 开发者社区的关系。尽管通过社区主导的分支和激进的 quantization 可以取得显著性能,但许多用户仍对 AMD 在这些工作负载上的长期投入持怀疑态度,因此即便成本更高,他们往往还是选择 NVIDIA 。与硬件争论并行的还有技术层面的探讨:speculative decoding 的机制表明,通过并行验证 token 序列可以缓解 LLM 推理中的 memory-bound 问题。归根结底,这次讨论强调了一个更普遍的观点:在决定 AI 计算领域市场主导地位时,易用且高质量的软件栈与原始硬件规格同样重要。 • The workstation-grade AMD R9700 is significantly under-supported by official channels, leading to a reliance on community-driven forks like Radiance to achieve competitive inference speeds.
• Many users have been deterred from AMD hardware for compute tasks due to a long-standing history of inadequate software support and driver instability, causing them to favor NVIDIA despite higher price premiums.
• Some users report success running models like Qwen 3.8-27B on AMD hardware, provided they utilize community-developed kernels and techniques like MXFP4 quantization.
• Community projects, such as the R4D kernel, allow for advanced tensor splitting and performance improvements that were previously thought impossible on this hardware.
• There is a perceived lack of clear communication and strategic interest from AMD regarding the needs of prosumer and AI-focused users, leading to frustrations when expensive hardware remains underutilized by official software.
• Speculative decoding functions by using a smaller draft model to predict a sequence of tokens in parallel, which the target model then verifies in a single forward pass, effectively amortizing memory-bound costs.
• The process of verifying speculative tokens relies on comparing probability distributions between the draft and target models, which can be done efficiently in parallel without needing to follow standard autoregressive decoding.
• Comparing AMD and NVIDIA hardware remains polarized, as NVIDIA offers mature software stacks that work out of the box, whereas AMD requires specialized community tuning to reach comparable performance.
• LLM research and deployment are viewed both as highly transformative technological breakthroughs and, conversely, as over-hyped tools with limited practical utility depending on the perspective of the observer.
The discussion highlights a divide between the raw capability of AMD hardware and the lack of robust, official software support that has historically defined the company's relationship with the AI developer community. While high-performance results are achievable through community-led forks and aggressive quantization, many users remain skeptical of AMD's long-term commitment to these workloads, frequently opting for NVIDIA despite the higher costs. Parallel to these hardware concerns, the technical conversation clarifies the mechanics of speculative decoding, emphasizing how parallel verification of token sequences mitigates the memory-bound nature of LLM inference. Ultimately, the thread underscores a broader sentiment that high-quality, accessible software is as critical as raw hardware specifications in determining market dominance within the AI compute space.