Speculative Decoding in Practice: Up to 4x Faster Local LLM Inference Without Hardware Changes
This article explains how speculative decoding accelerates local LLM inference by pairing a small draft model with a target model for parallel verification. It covers the memory-bandwidth bottleneck in decoding, the accept/reject workflow, the role of average acceptance length, concurrency benefits, and practical engineering choices in frameworks such as llama.cpp, Transformers, and vLLM.
Speculative Decoding in Practice: Up to 4x Faster Local LLM Inference Without Hardware Changes
When you run a local large language model, have you noticed that the same question can sometimes produce a complete answer almost instantly on the same hardware, while other responses appear token by token like an old typewriter? The core difference is not necessarily the model itself, but the token generation strategy. A technique called speculative decoding introduces a lightweight draft model behind the scenes to multiply local inference efficiency, increasing single-request generation speed to nearly 4x in some cases without changing any hardware. This article breaks down the underlying logic and engineering practices behind this technique.
1. The Memory Wall in LLM Inference: Why Generation Speed Is Limited by Bandwidth
LLM inference typically has two stages: prefill and decode. In prefill, the model processes the entire user input at once, computes attention in parallel, and builds the KV cache. This stage depends heavily on GPU compute capacity (FLOPs). Once the model starts generating a response, however, it enters the decode stage, where tokens are generated one at a time. At this point, the performance bottleneck shifts fundamentally.
Serial dependency in decoding: To generate the next token, the GPU must perform a sequence of operations: read all model weights (for example, about 14 GB of VRAM for a 7B-parameter model) and the KV cache for already generated tokens from memory into compute cores; calculate the probability distribution for the current token; and write the new token’s key-value data into the cache. This process must run completely for every token generated. Because the amount of data movement is large, GPU memory bandwidth becomes the main constraint on generation speed, while compute units often sit largely idle.
An intuitive view of the bandwidth bottleneck: Consider a consumer GPU with about 1 TB/s of bandwidth running a model with 14 GB of weights. In a theoretical calculation, it can perform at most about 70 full weight reads per second, which implies a hard upper limit of roughly 70 tokens/s for generation. In practice, the number may be slightly higher depending on cache hits, model architecture, and other factors. No matter how strong the GPU compute cores are, decoding speed remains locked if bandwidth cannot be improved. This explains why local LLM inference often struggles to match cloud GPU clusters.
2. Speculative Decoding: Trading Draft-Model Compute for Target-Model Time
The core idea of speculative decoding is to decouple generation from verification. It introduces a draft model that is much smaller than the target model, often one-tenth the size or less, and very fast. The draft model first quickly generates a sequence of candidate tokens. The target model, also called the main model or verification model, then needs only one forward pass to verify in parallel whether those candidate tokens fall within an acceptable range of its own probability distribution.
The workflow is as follows:
- Draft prediction: Based on the current context, the draft model predicts the next K tokens consecutively, using greedy or sampling methods, for example K=4 or K=8, and produces a candidate sequence.
- Single-pass verification: The candidate token sequence is appended to the original context and fed into the target model in one pass. In a single forward computation, the target model calculates the probability distribution for each position in parallel.
- Token-by-token acceptance and rejection: The target model checks candidate tokens in order. As long as a candidate token is acceptable under the target model’s predicted probability, usually defined as the highest-probability token or meeting a specific sampling threshold, it is accepted. When the first unacceptable token is encountered, denoted as token i, acceptance stops. From that position onward, the target model uses its own predicted token as the corrected output.
- Benefit calculation: Suppose the draft model generates K tokens and the first i are accepted. A single forward pass of the target model then advances decoding by i+1 tokens: the i accepted tokens plus one correction token, while the computational cost is only one forward pass.
The essence of the performance gain: Work that would originally require K+1 serial forward passes by the target model is compressed into one pass. This avoids repeated bandwidth waste from reading full weights and the KV cache, freeing the target model from performing a complete I/O read and write for nearly every token.
3. The Key Metric for Speedup: Average Acceptance Length
Speculative decoding does not guarantee speedup simply because the draft model writes more tokens. The core metric that determines the actual speedup is average acceptance length, meaning the average number of draft tokens accepted by the target model per verification round.
- Ideal case: If the draft model generates 4 tokens per round and the target model accepts all of them, the theoretical speedup approaches 4x, assuming draft-model generation time is negligible.
- Real-world case: If the draft model frequently predicts incorrectly, the target model may accept only 1 to 2 tokens, or even reject all of them. In that case, the draft model’s generation overhead becomes an extra burden and can cause negative optimization.
- Factors affecting acceptance rate: The capability gap between the draft model and the target model matters. The simpler and more specialized the task, the closer a small model may perform to a large model, and the higher the acceptance rate. When a task requires complex reasoning, world knowledge, or precise instruction following, the small model’s probability of incorrect guesses rises significantly.
For this reason, engineering practice often uses dynamic adjustment: observe the average acceptance rate over recent rounds and adjust the draft sequence length (K) dynamically. When the acceptance rate drops, shorten the draft length. When the acceptance rate remains high, extend the draft length appropriately to maximize speedup. At the same time, the draft model needs a sampling temperature that makes it slightly more diverse than the target model, avoiding overly confident but incorrect candidate sequences.
4. Additional Benefits Under Concurrency: Beyond Single-Request Speedup
The value of speculative decoding is further amplified in concurrent scenarios. Standard inference services, such as those using batched inference frameworks, process multiple requests in parallel with varying input and output lengths, and GPU utilization during serial decoding is often not high. With a draft model:
- More efficient batched verification: A single forward pass of the target model can verify candidate tokens for multiple requests at the same time, achieving parallelism along the batch dimension. Even if some requests have draft tokens rejected, generation of correction tokens can still make full use of that forward pass.
- Significantly higher throughput: Measured data shows that as the number of concurrent requests continues to increase, a system with a dynamic draft strategy can consistently achieve about 2x throughput improvement in tokens/s. This means that under the same hardware conditions, it can serve more users or complete more batch tasks, which is important for reducing the unit cost of local inference services.
- Lower time to first token (TTFT): Although speculative decoding mainly optimizes the decode stage, quickly generating candidates with the draft model and combining them with KV cache precomputation during prefill can effectively reduce the perceived wait for the first token.
5. Engineering Practices and Algorithm Optimization Directions
Major inference frameworks such as llama.cpp, the Transformers library, and vLLM have already added speculative decoding as a standard feature. In real deployments, developers should pay attention to the following points:
1. Draft model selection
- Same-source small model: Use a smaller version of the target model with the same tokenizer, for example a 1B model for a 7B model. This ensures an identical vocabulary and avoids extra token-mapping overhead.
- Independent small model: Any language model can be used, but vocabulary mapping and embedding alignment must be handled on the target-model side, increasing deployment complexity.
- N-gram cache: A lightweight alternative that requires no additional trained model. It builds a temporary N-gram model from historical generation data as the draft. This is especially effective for highly repetitive instruction scenarios such as code generation and log processing.
2. Sampling distribution alignment: When verifying draft tokens, the target model should use the same sampling strategy as the draft model, such as Top-p, Top-k, and temperature, to ensure accurate acceptance rates. If greedy decoding is used, comparing the Top-1 probability is sufficient.
3. System-level optimization: Allocate a separate compute stream for the draft model and pipeline it with the target model’s verification stream. While the draft model generates the next batch of candidates, the target model verifies the previous batch, hiding draft-model generation latency.
4. Advanced algorithm variants: The industry has already seen improvements such as parallel drafting, which generates multiple candidate draft windows and selects the best one; search-tree drafting, which branches verification across multiple possible paths; and retrieval-enhanced drafting, which retrieves possible continuations from a knowledge base as candidates. These approaches further push past the acceptance-rate ceiling of a single draft model.
6. Conclusion: A New Key to Unlocking Local Compute
Speculative decoding is not a complex new architecture. It is a clever reorganization of the existing inference flow. It accurately identifies memory bandwidth as the core bottleneck and uses redundant compute to reduce the number of I/O operations. For developers deploying LLMs locally, this represents a substantial free lunch: 2x to 4x performance improvement without replacing the GPU, quantizing the model, or sacrificing generation quality. The next time your local model outputs token by token, check your inference framework configuration and try giving it a draft assistant. You may find that your hardware has far more potential than you expected.
