Efficient Speculative Decoding for Llama at Scale: Challenges and Solutions

Bangsheng Tang, Carl Chengyan Fu, Fei Kou, Grigory Sizov, Haoci Zhang, Jason Park, Jiawen Liu, Jie You, Qirui Yang, Sachin Mehta, Shengyong Cai, Xiaodong Wang, Xingyu Liu, Yunlu Li, Yanjun Zhou, Wei Wei, Zhiwei Zhao, Zixi Qi, Adolfo Victoria, Aya Ibrahim, Bram Wasti, Changkyu Kim, Daniel Haziza, Fei Sun, Giancarlo Delfin, Emily Guo, Jialin Ouyang, Jaewon Lee, Jianyu Huang, Jeremy Reizenstein, Lu Fang, Quinn Zhu, Ria Verma, Vlad Mihailescu, Xingwen Guo, Yan Cui, Ye Hu, Yejin LeearXiv 2025 · DOI

Introduction

Large Language Models (LLMs) have transformed natural language processing, yet their deployment in production remains constrained by the latency of auto-regressive generation. Speculative decoding has emerged as a promising solution, utilizing a lightweight "draft" model to predict multiple future tokens that are subsequently verified by a larger "base" model in a single parallel step. However, transitioning speculative decoding from research environments to high-traffic production systems introduces an "engineering wall." At scale, increasing batch sizes and communication overhead between hardware components often negate the theoretical speedups.

Meta’s GenAI and Infra teams have addressed these challenges by optimizing EAGLE-based speculative decoding for Llama 3 and Llama 4 models. By integrating architectural refinements with aggressive systems engineering, they achieved a 1.4× to 2.0× speedup at scale, setting a new latency record for Llama 4 Maverick at approximately 4 ms per token.

Architectural and Training Optimizations

The effectiveness of speculative decoding depends heavily on the draft model's accuracy and speed. The team implemented several training-side optimizations to maximize the "Tokens Per Call" (TPC) metric.

Online Distillation and Weight Tying

Rather than training a standalone draft model, the authors utilized online distillation. The draft model is trained to predict both the base model’s hidden states and its logits simultaneously. To further improve efficiency and reduce the parameter footprint, weight tying was implemented between the embedding and LM head layers of the base and draft models.

Architecture of the speculative decoding training pipeline, featuring online distillation and weight tying between the base and draft models.

The Dense Draft Advantage

While many modern LLMs, including Llama 4 Maverick, utilize Mixture-of-Experts (MoE) architectures, the researchers discovered a "sweet spot" for draft models: a 3-layer dense Feed-Forward Network (FFN). Despite the base model's complexity, a dense draft model proved more efficient, utilizing 10× fewer parameters while maintaining high prediction accuracy. Furthermore, moving the draft model's FFN to INT4 quantization provided an optimal trade-off between execution speed and guess quality compared to higher-precision formats like FP8 or BF16.

Systems Engineering for Inference

To translate training gains into production performance, the team overhauled the inference stack to eliminate hardware bottlenecks.

  • Optimized Tree Attention: Managing non-sequential tokens in a "draft tree" often incurs overhead. The team split attention into a mask-free "prefix" (the prompt) and a masked "suffix" (speculated tokens), allowing for more effective use of hardware-specific kernels like Flash Attention v3.
  • Latency Hiding: A major bottleneck identified was unnecessary synchronization between the CPU and GPU. By restructuring the decoding cycle to overlap CPU bookkeeping and result transmission with GPU kernel execution, the team achieved a GPU utilization rate of 94%.
  • Dynamic Tree Dispatching: Because different tree shapes (e.g., wide trees vs. deep chains) perform differently depending on traffic, a dynamic dispatcher was implemented to select the optimal tree structure based on current batch sizes.
  • Disaggregated Inference: The system separates the "prefill" phase (initial prompt processing) from the "decode" phase (token generation) onto different hardware hosts, maximizing overall throughput.

Experimental Results

The optimized system was evaluated against both public benchmarks (MT-Bench) and internal Meta datasets designed to simulate real-world production stress.

Performance benchmarks showing (a) TTIT improvements across Llama models, (b) scaling with batch size, and (c) stability over request time.

As shown in the performance data, the optimized EAGLE implementation consistently outperforms standard engines. For Llama 4 Maverick, the system achieved a decoding speed of ~4 ms per token on 8 NVIDIA H100 GPUs, representing a 10% improvement over previous state-of-the-art methods. Notably, while speculative decoding speedups typically degrade as batch sizes increase, the use of the Tree Dispatcher allowed the system to maintain a 1.4× to 2.0× speedup even under heavy production loads. Compared to the widely used vLLM library, this implementation is 10–30% faster at a batch size of one.

Conclusion

By bridging the gap between theoretical speculative decoding and production-scale requirements, Meta has demonstrated that LLM latency can be significantly reduced without sacrificing model quality. The combination of dense draft models, online distillation, and meticulous CPU-GPU synchronization hiding provides a blueprint for deploying next-generation Llama models in high-demand environments. Future work will focus on integrating these optimizations into open-source frameworks to benefit the broader AI research community.

Summary updated

BibTeX
@misc{tang2025efficient,
  author = {Bangsheng Tang and Carl Chengyan Fu and Fei Kou and Grigory Sizov and Haoci Zhang and Jason Park and Jiawen Liu and Jie You and Qirui Yang and Sachin Mehta and Shengyong Cai and Xiaodong Wang and Xingyu Liu and Yunlu Li and Yanjun Zhou and Wei Wei and Zhiwei Zhao and Zixi Qi and Adolfo Victoria and Aya Ibrahim and Bram Wasti and Changkyu Kim and Daniel Haziza and Fei Sun and Giancarlo Delfin and Emily Guo and Jialin Ouyang and Jaewon Lee and Jianyu Huang and Jeremy Reizenstein and Lu Fang and Quinn Zhu and Ria Verma and Vlad Mihailescu and Xingwen Guo and Yan Cui and Ye Hu and Yejin Lee},
  title = {{Efficient Speculative Decoding for Llama at Scale: Challenges and Solutions}},
  year = {2025},
  eprint = {2508.08192},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.08192},
}
Figure