How Speculative Decoding Speeds Up Local LLM Inference Without a New GPU
This article explains how speculative decoding accelerates local LLM inference without changing GPUs. It covers the memory-bandwidth bottleneck in autoregressive decoding, how a draft model proposes tokens and a target model verifies them in parallel, why average acceptance length determines the speedup, and key engineering considerations such as draft-model selection, sampling consistency, KV cache rollback, and batching. It also includes pseudocode and a risk and tuning checklist.
1. The Bottleneck Is Not Compute, but Data Movement
Local LLM inference usually has two phases: prefill and decoding. After a user enters a prompt, the model processes the entire context in the prefill phase, computes attention, and builds the KV cache. This phase has high parallelism and is mainly limited by compute capability. Once the model starts generating a response, it switches to autoregressive decoding: for every token generated, it must read the model weights and the existing KV cache, perform a forward pass, and write the new key-value data back to the cache. Then, to generate the next token, the same read-compute-write cycle runs again.
When model weights reach tens of gigabytes or more, generating each token means moving a large amount of data. At this point, the key limit is often not the number of compute units, but memory bandwidth and data-movement efficiency. In other words, the hardware is not failing to compute fast enough; it is repeatedly moving weights and cache data. This is also why simply adding compute resources may deliver limited benefits for token-by-token generation.
Speculative decoding changes the token generation method. It does not replace the GPU or further compress the target model. Instead, it assigns part of the easy-to-predict work to a smaller, faster draft model, and then lets the target model verify the candidates together. The target model still owns final output quality, while the draft model only proposes candidate tokens.
2. The Draft Model Proposes Candidates, and the Target Model Verifies Them at Once
A simple example can illustrate the idea. Given the input “The cat,” the draft model might propose “sat on my lap” as consecutive candidates. The target model then checks these candidate tokens in a single forward pass. If the first two tokens match the target model’s probability distribution, they are accepted. If the third token is rejected, the remaining candidates are discarded, and the target model generates a correction token. Work that previously required multiple target-model runs can now sometimes be compressed into one verification round.
The key here is parallel verification. A single target-model forward pass can compute probabilities for multiple candidate positions at the same time, instead of advancing serially one token at a time. Because the draft model is small, generating multiple candidates usually costs much less than having the target model read the full weights multiple times. The system therefore combines multiple low-cost draft steps with one target-model verification step, advancing several positions at lower cost.
It is important to note that speculative decoding does not let the draft model replace the target model. Whether a final token is accepted is governed by the target model’s probability distribution. With a correct implementation, the sampling result should remain consistent with sampling from the target model itself; the draft model affects speed, not output quality directly. If the draft model guesses wrong frequently, the target model will keep rejecting and correcting, and the extra computation may actually slow generation.
3. The Core Metric: Average Acceptance Length
Speculative decoding may look like a free lunch, but the metric that really determines acceleration is average acceptance length: the average number of draft tokens accepted by the target model per round. If the draft model proposes 4 tokens at a time and 3 are accepted, one target-model verification advances multiple positions. If only 1 is accepted, or even the first token is rejected, the draft cost becomes additional overhead.
A simplified model can estimate the benefit. Let the draft length be γ, the relative cost of the draft model generating each token be c, and the average number of tokens ultimately advanced per round be L. The approximate speedup relative to token-by-token generation by the target model is:
L / (1 + γ·c)
Here L includes accepted draft tokens and one correction token. When c is small and L is large, the speedup is clear. When a low acceptance rate makes L close to 1 and γ·c is non-negligible, the speedup ratio may be less than 1. This formula is only a simplified estimate; actual performance is also affected by batching, verification computation, KV cache rollback, and memory access patterns. It is still enough to show the tuning direction: improve acceptance rate, control draft length, and reduce draft cost.
A larger draft length is not always better. If γ is too small, there are too few candidates and verification overhead accounts for a high share. If γ is too large, draft generation cost rises, and once an early rejection occurs, all later candidates are wasted. In engineering practice, γ should be an adjustable parameter and tuned dynamically based on the actual acceptance rate. For example, when the acceptance rate remains high, candidate length can be increased moderately; when the acceptance rate drops, candidate length should be shortened to avoid invalid drafts increasing latency.
4. Key Engineering Considerations
1. Draft Model Selection
The draft model does not need to have the same scale as the target model, but it should ideally meet three conditions: tokenizer or vocabulary compatibility, an output distribution close to the target model, and a small parameter count that can run on the same hardware environment. If tokenizers differ, candidate tokens and target-model verification positions are difficult to align. If distributions differ too much, the acceptance rate will drop. If the draft model is too large, its memory footprint and generation cost will erode the benefit. In practice, it is also necessary to balance memory savings from draft-model quantization against acceptance-rate loss.
2. Sampling Consistency
Under greedy decoding, verification is relatively straightforward: a candidate token can be accepted if it matches the target model’s greedy result. Sampling decoding requires accept-reject correction to ensure that the final distribution is still determined by the target model. Sampling parameters such as temperature and top-p should remain consistent between drafting and verification; otherwise, distribution consistency is broken. In implementation, random-number state should be preserved to prevent requests within a batch from interfering with each other.
3. KV Cache Rollback
After the draft model proposes multiple candidates, target-model verification produces cache entries for the corresponding positions. If some candidates are rejected, the KV cache for rejected positions and their subsequent candidates must be discarded, keeping only the cache for accepted positions and the correction token. In batched scenarios, different requests have different acceptance lengths, and cache rollback and variable-length handling within a batch are major sources of complexity. Incorrect implementation can cause cache misalignment or output drift.
4. Batching and Scheduling
As concurrent requests increase, speculative decoding can still improve throughput, but scheduling strategy is critical. Different requests have different acceptance lengths. If long candidate sequences are simply packed into the same batch, verification computation may be wasted. Dynamic batching can be used to prioritize requests with similar candidate lengths; requests with low acceptance rates can use shorter γ; and the draft model and target model can be placed on the same device or split by resource to reduce communication overhead. If running on Baidu AI Cloud container platform or a self-managed cluster, acceptance rate, draft latency, verification latency, per-token latency, and P99 latency can be included in monitoring and alerting to form an observable tuning loop.
5. Pseudocode Example
The pseudocode below shows the core loop, omitting specific framework interfaces:
function speculative_generate(prompt, target, draft, gamma, max_tokens):prefix = promptwhile len(prefix) < max_tokens:candidates = draft.propose(prefix, gamma)target_probs = target.verify(prefix, candidates)accepted = []for i, token in enumerate(candidates):if accept_by_target_distribution(target_probs[i], token):accepted.append(token)else:accepted.append(target.sample_correction(target_probs[i]))breakprefix = prefix + acceptedrollback_kv_cache(prefix)return prefix
The focus of this pseudocode is not the interface but the flow: the draft model proposes candidates, the target model verifies them at once, tokens are accepted or rejected one by one, a correction token is generated after rejection, and the cache is rolled back. A real system also needs to handle variable lengths within a batch, sampling randomness, cache management, and timeout control.
6. Risks and Tuning Checklist
The main risks of speculative decoding include: a distribution gap between the draft model and target model leading to a low acceptance rate; excessive draft length causing wasted computation; incorrect sampling correction causing output distribution shift; incomplete KV cache rollback causing context misalignment; reduced verification efficiency under concurrency; and extra memory usage by the draft model. During tuning, focus on average acceptance length, acceptance rate, draft-model latency share, target-model verification latency, per-token latency, throughput, and rejection rate. If the acceptance rate remains low for a long time, first check tokenizer compatibility and sampling parameter consistency, then consider changing the draft model or shortening γ.
In summary, the value of speculative decoding is that it transforms “serial full-weight reads for each token” into “a small draft model proposing multiple candidates and the target model verifying them together.” It does not promise unconditional multiple-fold acceleration. However, when the draft model is well matched, the acceptance rate is high, and cache and batching are implemented correctly, it can significantly improve the local LLM inference experience without changing the GPU. In deployment, use observable metrics as the basis, tune parameters in small steps, verify output consistency, and then gradually increase concurrency and deployment scale.
