LLM Decoding Acceleration: Speculative Decoding vs. Diffusion Generation

    This article compares two routes for accelerating large language model decoding: multi-token prediction / speculative decoding and diffusion generation. It first explains why autoregressive decoding is inherently serial and memory-bound, then shows how speculative decoding drafts K tokens and verifies them in one parallel pass with a distribution-preserving acceptance scheme, and how diffusion generation denoises whole blocks in parallel under a hybrid "serial across blocks, parallel within blocks" structure. It covers speedup estimation, quality risks, engineering trade-offs, the interaction with quantization (QAT and PTQ), and practical guidance for choosing and deploying each route, along with key engineering practices such as acceptance-rate monitoring, block-level caching, and fallback strategies.

    Introduction: The Bottleneck in Generative Inference Is Decoding

    Large model inference typically has two stages:

    • Prefill: The model processes the entire input prompt in parallel. It is compute-intensive and determines time to first token (TTFT).
    • Decode: The model outputs new content token by token. Each token requires a forward pass conditioned on all preceding tokens.

    The decode stage has extremely low parallelism, and its arithmetic intensity is often only a few FLOP/Byte. Mainstream GPUs have surplus compute but constrained memory bandwidth: generating each token means moving the entire model weights from memory again. Decode is therefore a memory-bound process that determines time per output token (TPOT).

    In recent years, the community has produced two classes of “non-traditional decoding” approaches. One is multi-token prediction (MTP) / speculative decoding; the other is diffusion generation, represented by diffusion language models. The former keeps the “one token at a time, left to right” writing style but guesses several tokens ahead and verifies them in a single pass. The latter no longer writes word by word; instead, it lays down a draft region and then denoises and corrects the whole block in parallel. The following analysis covers the principles, costs, and applicable boundaries of both routes.

    1. The Baseline: Why Autoregressive Generation Is Inherently Serial

    Autoregressive generation formally factorizes the joint probability step by step:

    1. p(x1, x2, ..., xT) = ∏ p(xi | x1, ..., xi-1)

    Each token is conditioned on “all tokens determined so far.” This has two consequences:

    1. Strong serial dependency: Token i cannot be generated until tokens 1 through i-1 are fixed. Decoding cannot process an entire sequence at once the way prefill can.
    2. Per-token memory overhead: Context windows are often 32K or longer (some models reach hundreds of thousands of tokens), yet each step adds only one token’s attention query of effective computation. The cost of moving weights stays nearly fixed.

    The longer the context, the more pronounced the bottleneck. Decode acceleration has therefore become a core topic in inference optimization. Common industry approaches include:

    • Quantization and weight compression: Reduces the weight traffic per token.
    • Paged KV cache: Alleviates memory fragmentation for long contexts.
    • Speculative decoding / MTP: Changes how much is produced per forward pass.
    • Diffusion generation: Changes how tokens are produced itself.

    The first two do not change decoding order; the latter two intervene in the generation process at different levels.

    2. Route One: Multi-Token Prediction and Speculative Decoding

    2.1 Core idea: Keep the writing style, just add a draft accelerator

    An analogy helps here. An autoregressive model is like an author who writes left to right, word by word, and can only conceive the next word after finishing the current one. Multi-token prediction does not change this style; it simply gives the author an assistant who writes out several candidate words at once. The author then quickly checks them, keeping the correct parts, discarding the wrong ones, and continuing from the point of disagreement.

    The process has two steps, draft and verify:

    • Draft: A lightweight mechanism produces K candidate tokens in sequence. Sources can be an independent small model, extra prediction heads built into the main model, or retrieval or n-gram-based matching.
    • Verify: The main model concatenates the “confirmed prefix + K draft tokens” and runs one forward pass in parallel, obtaining the output distribution at each position under the true model, then accepts or rejects each position accordingly.

    There are two main acceptance schemes:

    • Greedy decoding: A draft token is accepted only if it matches the main model’s greedy result at that position.
    • Sampling decoding: Accept with probability min(1, p/q) (p is the main model distribution, q is the draft distribution); on rejection, resample from the corrected distribution.

    Both methods share the same core goal: bring correctly guessed tokens into the output in batches with as little verification cost as possible.

    2.2 Why quality is essentially lossless

    Under standard sampling decoding, the distribution of the output sequence is identical to what you would get by sampling token by token directly from the main model. In other words, acceleration introduces no additional bias, and final output quality depends only on the main model. This is the direct benefit of the main model always holding final confirmation authority.

    Illustrative pseudocode:

    1. prefix = tokenizer.encode(prompt)
    2. while not finished(prefix):
    3. # Draft stage: propose K candidate tokens at once (K can be adjusted dynamically)
    4. draft_tokens, draft_dist = propose_draft(prefix, K)
    5. # Verify stage: target model runs one forward pass, producing the target distribution at each position in parallel
    6. target_dist = target_model.forward(prefix + draft_tokens)
    7. accepted = 0
    8. for i in range(K):
    9. if accept(target_dist[i], draft_tokens[i], draft_dist[i]):
    10. accepted += 1
    11. else:
    12. break # Stop immediately on the first rejection; all subsequent drafts are discarded
    13. # Keep accepted tokens; on rejection, sample 1 token from the corrected distribution
    14. prefix.extend(draft_tokens[:accepted])
    15. if accepted < K:
    16. prefix.append(sample_from(target_dist, accepted))
    17. adjust_draft_length() # Adjust next round's K based on recent acceptance rate

    2.3 How to estimate the speedup

    Let α be the probability that a single draft token is accepted (the acceptance rate) and K the draft length. The closer the draft model’s distribution is to the main model’s, the higher α.

    In the ideal case, where positions are independent and the compute cost of the draft model and the main model is negligible, the average number of tokens produced per verification round is:

    1. E[token] = (1 - α^(K+1)) / (1 - α)
    • α = 0.8, K = 4: about 2.95 tokens per round;
    • α = 0.6, K = 4: about 2.18 tokens per round;
    • As K → ∞, the theoretical ceiling is 1/(1-α), i.e., about 5x at α = 0.8.

    The actual speedup must be multiplied by a verification cost discount factor, roughly influenced by:

    • The main model verifies K+1 positions in one pass, at roughly K+1 times the compute;
    • The forward-pass overhead of the draft model itself;
    • In conventional memory-bound decoding, this extra compute is often usable, but under high-concurrency batching the GPU is usually already compute-saturated, so the discount is more pronounced.

    For this reason, the “average length of consecutively accepted tokens” is more informative than the theoretical speedup multiplier.

    2.4 Advantages and limitations

    Advantages:

    • Can be layered onto an existing autoregressive model with good inference-engine compatibility;
    • Distribution-preserving in theory, with low quality risk and easy gray-release validation;
    • Relatively mature engineering, easy to roll back.

    Limitations:

    • Still constrained by the “left to right, confirm one at a time” ordering;
    • Once a position is rejected, all subsequent drafts are discarded;
    • The speedup ceiling is mainly determined by the acceptance rate, so the benefit is limited when α is low.

    In essence, MTP / speculative decoding adds a draft accelerator to a conventional autoregressive model without changing its writing style. It noticeably improves perceived speed but cannot break the inherent ceiling imposed by decoding order.

    3. Route Two: Diffusion Generation

    3.1 Core idea: Lay down a draft first, then revise the whole section

    Diffusion generation draws on the idea of image diffusion models: starting from pure noise and gradually denoising over multiple timesteps to arrive at a clear image. Transferring this idea to discrete text tokens yields discrete diffusion.

    Text diffusion decoding no longer fixes one token at a time. Instead:

    1. Take a region of length L (a canvas), where most positions are initialized as masks, placeholders, or noise;
    2. At each denoising step, the model predicts all positions in the block in parallel;
    3. Based on prediction confidence, fix some of the positions;
    4. Repeat until the whole block is filled, then move to the next block.

    It is more like a painter who lays down an underpainting, then repeatedly reviews and revises local areas until it gradually takes shape.

    One clarification: the “diffusion” here does not mean continuously mixing tokens with Gaussian noise and denoising numerically. Rather, it applies structured noising such as mask replacement to discrete tokens and learns the inverse process. “Parallel denoising” also does not mean outputting all tokens at once; it compresses many serial steps into a few steps, each processing the whole block in parallel.

    Illustrative pseudocode:

    1. prefix = tokenizer.encode(prompt)
    2. while not finished(prefix):
    3. # A canvas: length L, all [MASK] except the known prefix
    4. canvas = [MASK] * L
    5. for step in range(num_denoise_steps):
    6. # One forward pass predicts all undetermined positions in the canvas in parallel
    7. dist = diffusion_model.forward(prefix + canvas)
    8. # Select positions to fix this round by confidence (decreasing each round)
    9. positions = select_by_confidence(dist, step)
    10. for pos in positions:
    11. canvas[pos] = sample_from(dist[pos])
    12. prefix.extend(resolve(canvas)) # Append to the prefix once the whole block is complete

    3.2 Block-level autoregression and multi-canvas sampling

    Early text diffusion denoised in parallel over the entire sequence and had limited long-text modeling ability. Practice gradually shifted to block-level autoregression: autoregressive dependency is kept between blocks (the next block starts only after the previous one completes), while within a block, denoising is parallel. This hybrid structure of serial across blocks and parallel within blocks balances long-text coherence with intra-block throughput.

    Multi-canvas sampling organizes this idea further:

    • Assign each block a fixed-length canvas, and prepare several additional canvases beyond the main canvas;
    • At each denoising step, sample candidate content in parallel first, then select the current best content through information exchange between canvases, iterating until convergence.

    Block length (e.g., 256 tokens) directly determines parallelism granularity and quality-control frequency, and is a core tunable hyperparameter:

    • Longer blocks mean fewer serial steps per block and greater potential speedup;
    • Longer blocks also mean a larger range of error propagation within a single block.

    3.3 Key parameters that determine effectiveness

    • Number of denoising steps: More steps mean more stable quality, but each step requires a full forward pass, lowering speed. The ratio of steps to block length determines the average number of tokens fixed per step.
    • Mask scheduling strategy: How many positions to keep at each denoising step, and which ones (filling from high to low confidence, or keeping randomly), directly affects the dependency strength between tokens within a block.
    • Parallelism and sampling strategy: Whether positions are written simultaneously or written in order, and whether greedy or randomized sampling is used, affects the coherence and diversity of the output.

    3.4 Advantages and costs

    Advantages:

    • Parallel within blocks, producing multiple tokens per step, theoretically compressing serial steps substantially;
    • The generation process has randomness, so output diversity is good;
    • The iterative write-and-revise approach is a natural fit for scenarios needing local correction, such as code completion and structured output.

    Costs:

    • Joint modeling is approximate: When positions are decided in parallel, later tokens cannot see the final results of earlier tokens in the same block, so some conditional dependencies can only be compensated over multiple iterations. This is a quality risk diffusion generation usually faces.
    • KV cache and scheduling need redesign: Most inference frameworks are optimized around one token per step sequential decoding, so prefix caching, continuous batching, and paged attention must be reworked around block-level parallelism.
    • MoE structures amplify engineering complexity: A sparse architecture with large total parameters that activates only a few parameters and experts per token has low per-token compute, but is sensitive to cross-device routing communication and requires careful load balancing and communication strategies for parallel decoding.

    3.5 Quality must be validated by measurement

    The quality of diffusion generation cannot be judged by perplexity alone. A more reliable approach is to use a fixed evaluation set and compare the two decoding methods on business metrics, format validity rate, and human ratings; also check the determinism of the output, since randomized decoding usually requires additional random seed management to guarantee reproducibility.

    4. Core Comparison of the Two Routes

    Dimension Multi-token prediction / speculative decoding Diffusion generation
    Generation order Still one token at a time, left to right Autoregressive across blocks, parallel within blocks
    Output per forward pass K drafts + 1 confirmation position Multiple positions fixed per step
    Correction method Roll back and re-guess on the first disagreement Iteratively refine over multiple denoising steps
    Output distribution Theoretically identical to the main model Affected by parallel approximation; needs empirical validation
    Speedup ceiling Constrained by acceptance rate Constrained by denoising steps and parallelism
    Quality risk Low Requires focused validation
    Inference framework rework cost Lower, can be integrated incrementally Higher, needs block-level parallelism support
    Extra memory overhead Draft model / prediction heads / draft token cache Canvas state and multi-step intermediate results

    5. Relationship with Quantization-Aware Training (QAT)

    Quantization-aware training (QAT) simulates quantization error during training or fine-tuning, typically trading a small accuracy loss for lower-bit inference; post-training quantization (PTQ) requires only a small amount of calibration data but carries greater accuracy risk at low bit widths.

    These methods also affect decode acceleration:

    1. Speculative decoding: The quantization bit width and calibration method on the draft side and main-model side need to match. If the draft uses low bits and the main model uses higher bits, the shift in their output distributions lowers the acceptance rate, so the draft model usually comes from the same training and quantization pipeline as the main model.
    2. Diffusion generation: Quantization error affects the confidence ranking at each denoising step and thus the position selection strategy, so quality regression must be done with a fixed seed for reproducibility.

    It is worth emphasizing that the two optimize different stages: QAT optimizes how much weight is moved per token, while the two decoding routes optimize how many tokens are produced per forward pass. They can be combined, but need to be evaluated jointly.

    6. How to Choose and Deploy

    6.1 Selection guidance

    • Existing autoregressive model with high output-quality requirements: Prioritize evaluating speculative decoding or MTP, a low-risk incremental change.
    • Long outputs, high throughput, scenarios that accept extra quality validation: Consider piloting diffusion generation, focusing on validating long-text coherence.
    • High proportion of structured output: Compare the two routes on format validity rate before deciding the main approach.
    • Latency-sensitive with low concurrency: Both routes can reduce single-user response time, so start with speculative decoding for quick wins.

    6.2 Deployment steps

    1. Establish a baseline: Record TTFT, TPOT, throughput (tokens/s), memory usage, and business metrics.
    2. Confirm the bottleneck: Long-context, low-concurrency scenarios are more sensitive to decode acceleration.
    3. Offline evaluation: Use a fixed evaluation set and random seed to measure quality change and speedup separately.
    4. Small-traffic gray release: Route traffic by proportion through a gateway, and use logging services and monitoring alerts to observe latency, error rate, and user feedback in real time.
    5. Dynamic tuning: Dynamically adjust draft length based on online acceptance rate, and switch block length and denoising steps by task type.

    6.3 Engineering essentials

    • Acceptance rate monitoring: A sharp drop in acceptance rate often means the draft and main model are out of sync or the quantization configuration is inconsistent.
    • Block-level caching: Under the diffusion route, reuse prefix caching across different blocks as much as possible to avoid redundant computation.
    • Batching scheduling: Speculative decoding produces outputs of varying lengths, so the scheduler must support continuous batching and paged caching.
    • Fallback strategy: Fall back to standard autoregressive decoding in anomaly or low-confidence scenarios to ensure availability.

    Conclusion

    The two routes represent two philosophies:

    • Multi-token prediction / speculative decoding: Keeps the writing style unchanged, accelerating with drafts and covering with verification.
    • Diffusion generation: Changes the writing style, laying down a draft first and denoising blocks in parallel, breaking the serial limit of word-by-word generation.

    There is no absolute winner in engineering practice; the key is weighing latency, throughput, quality, and rework investment against business needs. Inference services involve general-purpose capabilities such as model hosting, elastic compute, object storage, container platforms, logging services, and monitoring alerts, and cloud platforms can generally compose these components on demand to support deployment, elastic scaling, and stable operation of inference services. Understanding the essence of the decoding mechanism is what lets you make better selection decisions.