Speed Up Local LLM Inference Without a New GPU: How Speculative Decoding Works

    Large language model decoding is bottlenecked by memory bandwidth rather than compute, which is why local inference often feels slow even on a capable GPU. This article explains speculative decoding, a technique that pairs a small, fast draft model with a larger target model to produce several tokens per target-model pass. It covers why the decode phase is memory-bandwidth bound, how the draft-and-verify loop works, why rejection sampling with residual correction keeps the output distribution identical to standard sampling, and how average acceptance length and the number of speculative tokens determine real-world speedup. It closes with practical guidance on draft-model selection, concurrency and batching, KV cache management, and deployment for local LLM inference.

    1. Why LLMs “Load Themselves” One Token at a Time

    To understand how the speedup works, it helps to see what actually happens inside a single large-model inference pass. Mainstream autoregressive LLM inference is typically split into two phases with very different characteristics.

    Prefill phase: After a user submits a prompt, the model processes the entire context in parallel in one shot, computing attention across all layers and building the KV cache (key-value cache). This phase ingests a large number of tokens at once. The computation is matrix-heavy and throughput-bound, so more compute on the GPU directly translates into an advantage.

    Decode phase: Once the model starts generating its answer, it switches to producing one token per step. Each forward pass yields only a single token. Here the GPU cannot simply “run a quiet computation”—it first has to move the entire set of model weights and the accumulated KV cache from VRAM into the compute units. After computing, it writes the newly generated key-value pairs back into the cache. On the next step, all of this repeats from scratch.

    Here is the crux of the problem: a model that spans tens or even hundreds of gigabytes must have the vast majority of its weights read once for every single token it generates. As a result, generation speed is often determined not by how many compute units the GPU has, but by VRAM bandwidth and data-movement speed. Compute sits largely idle while bandwidth is saturated—the inefficiency of “loading itself” one token at a time. The decode phase is often described as a “memory-bandwidth-bound” process.

    Speculative decoding starts from the idea of breaking this serial “one token, one data transfer” structure.

    2. The Core Idea: Hand Predictable Work to a “Helper”

    Speculative decoding uses two cooperating models: a larger, higher-quality target model (the verifier), and a much smaller, faster draft model (the sprinter).

    The draft model’s job is to cheaply “guess” the next several tokens as candidates. For example, if the prompt is “The cat,” the draft model might predict candidates like “sat on my lap” in one go. The target model then does not evaluate these one by one. Instead, it checks the entire sequence of candidates in a single forward pass, verifying whether each position matches its own probability distribution:

    • Tokens that match (align with the target model’s distribution) are accepted directly;
    • As soon as one token is rejected, it and every candidate after it are discarded, and the target model samples a correct token at that position.

    Previously, the target model might have needed three or four passes to reach the same point. Now it has a chance to advance several positions in a single verification pass. Because the draft model is tiny, generating candidates costs far less than the target model reading its full weights multiple times, so the overall time is significantly reduced.

    The following illustrative pseudocode shows this cooperation loop (for meaning only, not a specific framework’s API):

    1. def speculative_generate(target, draft, prompt, gamma=4, max_new=256):
    2. out = []
    3. t_state = target.prefill(prompt) # Target model prefills and builds the KV cache
    4. d_state = draft.copy_state(t_state) # Draft model reuses the same initial state
    5. while len(out) < max_new:
    6. # 1) Draft model "guesses" gamma candidate tokens in a row
    7. guesses = [draft.sample_next(d_state) for _ in range(gamma)]
    8. # 2) Target model runs one forward pass, obtaining the probability of each candidate at its position
    9. probs = target.forward_parallel(t_state, guesses)
    10. # 3) Verify position by position: accept if it matches the distribution
    11. accepted = 0
    12. for i, tok in enumerate(guesses):
    13. if random() < min(1.0, probs[i][tok] / draft_prob[i][tok]):
    14. out.append(tok); accepted += 1
    15. else:
    16. # Rejected: resample one token from the corrected residual distribution
    17. out.append(resample_from_residual(probs[i], draft_prob[i]))
    18. break
    19. # 4) If all hit, "earn" one extra token for free
    20. if accepted == gamma:
    21. out.append(target.sample_bonus())
    22. sync_states(t_state, d_state, out) # Sync both states using the finally confirmed tokens
    23. return out

    3. The Math: Why It Speeds Up Without Hurting Quality

    Many people worry that “letting the large model accept guesses from someone else will degrade output quality.” The answer is no. The key is that verification uses rejection sampling with residual correction, rather than a simple “accept if right, discard if wrong.”

    For each draft token, the target model accepts it with probability min(1, p/q), where p is the target model’s probability and q is the draft model’s probability. Once a token is rejected, a new token is sampled from the normalized residual distribution max(0, p − q). In theory, this mechanism guarantees that the probability distribution the final output follows is exactly the same as when the target model samples token by token on its own.

    Put differently, the draft model only “proposes,” and the final decision always rests with the target model. The speedup comes from reducing repeated transfers of the target model’s weights, not from sacrificing generation quality. This is precisely what sets speculative decoding apart from various “approximate compression” methods.

    4. Average Acceptance Length: The Metric That Makes or Breaks It

    Speculative decoding may look like a free lunch, but the core metric that truly measures the speedup is average acceptance length—the average number of draft tokens the target model accepts per round.

    • If the draft model guesses 4 tokens and 3 are accepted, that is equivalent to advancing 3 positions with a single large-model computation—a solid payoff;
    • If the draft model guesses wrong often, the target model has to keep rejecting and correcting, and the wasted draft computation becomes pure overhead.

    Therefore, more draft tokens do not necessarily mean faster. This raises the tuning question of the number of speculative tokens (often denoted γ): set γ too small and the savings in transfers are limited; set it too large and rejected candidates waste the draft model’s compute. A reasonable γ is strongly tied to the task type and to how well the draft model and target model are “in sync,” and in practice you need to scan a small range for the specific scenario.

    5. The Theoretical Speedup Ceiling

    Assume the per-forward cost of the draft model is very small relative to the target model, and let the average acceptance length be τ. Then the overall speedup increases as τ grows, up to a theoretical ceiling determined by τ: as the draft cost approaches zero, the speedup approaches the average number of tokens produced per round. This explains why highly predictable text (formatted output, code completion, templated responses) often sees more noticeable speedup, while highly divergent, randomness-heavy creative content sees comparatively limited gains.

    6. Engineering Practice

    Draft model selection: The ideal draft model comes from the same family as the target model or aligns well with its tokenizer, and is typically a fraction of the target model’s size. It is better to lean slightly smaller while ensuring it “guesses accurately and fast.”

    Concurrency and batching: In single-request scenarios, speculative decoding can significantly reduce latency. But under high concurrency, where batching has already saturated the compute, the extra draft computation may compete with the main model for resources, narrowing or even reversing the gains. You therefore need to weigh it against the service load: the benefit is greatest when latency matters under low concurrency, and it should be evaluated carefully in high-throughput scenarios.

    State and cache management: The draft and target models each need to maintain and synchronize their own KV caches. A poor implementation introduces extra overhead, and this is an engineering detail that decides whether the actual gains materialize.

    Deployment: Locally, you can enable speculative decoding directly with mainstream open-source inference frameworks. In the cloud, users can quickly spin up two models and tune parameters through the general capabilities that cloud providers offer, such as container platforms, GPU compute instances, and inference services; the general compute and inference products of platforms like Baidu AI Cloud are also commonly used to host this kind of dual-model cooperation. Whether deployed locally or in the cloud, the methodology for selection, tuning, and load testing is the same.

    7. Summary

    At its core, speculative decoding uses a “small, fast draft model that sprints ahead + a large target model that verifies in one pass” to work around the inherent bottleneck of the decode phase being constrained by VRAM bandwidth. It does not rely on swapping out the GPU, nor on compressing the model further; instead, it restructures the token-generation path, and when implemented correctly it does not sacrifice output quality. Understanding average acceptance length, setting the number of speculative tokens sensibly, and making trade-offs based on concurrency load are the keys to putting this technique to good use in local LLM inference.