Abstract
This technical report describes the design and training of novel speculative decoding draft models for accelerating the inference speeds of large language models in a production environment. By conditioning draft predictions on both context vectors and sampled tokens, we can train our speculators to efficiently predict high-quality n-grams, which the base model then accepts or rejects. This allows us to effectively predict multiple tokens per inference forward pass, accelerating wall-clock inference speeds of highly optimized base model implementations by a factor of 2-3x. We explore these initial results and describe next steps for further improvements.
Introduction
Large Language Models (LLMs) are notoriously slow at inference because they are auto-regressive, generating text one token at a time. For a model like Llama2-13B, the GPU must load 24GB of weights just to produce a single token, creating a massive bottleneck in production environments. Speculative decoding attempts to fix this by using a smaller, faster "draft" model to guess the next few tokens, which the large "base" model then verifies in a single parallel pass. However, existing draft models often predict multiple future tokens independently from the same hidden state, leading to poor n-gram quality—for example, guessing "Step Step Step" instead of a coherent sequence like "Step 1, Step 2."
Methods
We introduce a novel multi-stage MLP speculator architecture and a specialized two-stage training pipeline. Instead of predicting all draft tokens in parallel from one vector, this model uses a chain of MLP heads. Each head takes two inputs: the base model’s context vector (representing the past) and the embedding of the token sampled by the previous head. This "loops" the sampled tokens back into the prediction for the next token, ensuring the draft sequence is coherent.
The training process involves two phases:
- Alignment to Ground Truth: The speculator is first trained on standard text datasets to predict next tokens.
- Alignment to Base Model: The speculator is fine-tuned on data generated by the base model itself to mimic its specific distribution and "quirks."
At inference time, the speculator generates a "tree" of possible candidates. The base model uses "Tree Attention" to verify multiple potential paths simultaneously, maximizing the chance that at least one long sequence of tokens is accepted.
Key Results
The proposed speculators achieved significant wall-clock speedups across various production-grade models. Llama2-7B and 13B models reached a 2x speedup, while Codellama-13B achieved over 3x speedup, reaching a throughput of 181.5 tokens per second at fp16 precision. The speculators are roughly 1/10th the size of the base model but execute in under 1/30th of the time due to their shallow, non-transformer architecture.
Evaluation on heterogeneous workloads showed that conditioning is critical; feeding the sampled token embedding back into the next MLP head produces much more realistic sequences, significantly increasing the acceptance rate by the base model. However, performance gains are sensitive to system load. As batch sizes increase and the GPU reaches maximum utility, the overhead of checking multiple candidates can eventually make speculative decoding slower than standard decoding.
Conclusion
Combined token/embedding speculators offer a powerful method for accelerating LLM inference without altering base model weights. Code-specific models benefit particularly well from deeper speculators due to the structured nature of programming languages. Future work will investigate weight tying between MLP heads to reduce memory footprint and dynamic toggling of speculative decoding based on real-time production load to optimize throughput-latency trade-offs.
Summary updated