From Autoregressive to Diffusion: Parallel Denoising for Faster LLM Generation

    This article examines how to reduce the serial forward passes that dominate large language model generation latency, comparing two routes: keeping autoregressive decoding while adding speculative decoding and multi-token prediction as draft-verify accelerators, versus replacing the generation paradigm with block-level parallel denoising from diffusion language models. It explains the autoregressive decoding bottleneck, walks through speculative decoding, multi-token prediction, and discrete diffusion "canvas" generation with code and scheduling examples, offers a head-to-head comparison, covers quantization-aware training as a complementary technique, and closes with engineering practices, a deployment path on Baidu AI Cloud, and common misconceptions.

    1. Why “One Token at a Time” Became the Generation Latency Bottleneck

    Recently, a notable trend has emerged: a new class of diffusion-based language models no longer generates text token by token. Built on a base architecture but using discrete diffusion generation instead, they denoise and refine an entire “canvas” of 256 tokens in parallel at once. How these models relate to autoregressive ones, and how they differ from existing techniques such as multi-token prediction and quantization-aware training, are questions developers need to clarify when choosing a model.

    To understand this shift, start with the inherent constraints of autoregressive decoding. Autoregressive language models factorize the joint probability of a text as:

    1. p(x1, x2, ..., xN) = Π p(xt | x1, ..., x_{t-1})

    This means generating N tokens requires at least N model forward passes. Step t must wait for the result of step t−1, so there is almost no parallelism along the sequence dimension.

    Typical single-model, single-GPU deployment scenarios (estimated at that scale) exhibit two characteristics:

    Observation Typical behavior
    Per-step generation cost Each step must read all weights, typically on the order of milliseconds to tens of milliseconds
    Arithmetic intensity Below the hardware’s “compute ÷ bandwidth” balance point; compute is hard to saturate, and time is dominated by memory bandwidth and fixed overhead
    Request concurrency Under concurrent requests, one forward pass serves the whole batch; throughput rises with batch size, while single-request latency barely changes

    Therefore, a reply of a hundred characters often goes through hundreds of serial forward passes, and interactive latency comes mostly from here. The industry commonly measures this with time to first token (TTFT), time per output token (TPOT), and end-to-end latency. Theoretical speedup can be estimated as:

    1. SpecDec ≈ E[γ · α + 1] / (γ · c + 1)
    2. BlockDiff ≈ steps / tokens filled in parallel per step = average solvable mask ratio

    Here, γ is the draft length per round, α is the draft token acceptance rate, and c is the relative cost of drafting versus verification. Diffusion generation is instead “forward steps ÷ average tokens decoded per step.”

    To address this bottleneck, the industry has mainly two routes:

    1. Keep autoregressive: predict subsequent tokens ahead of time and accelerate with “draft-verify,” represented by speculative decoding and multi-token prediction.
    2. Replace the generation method: let multiple positions be determined in the same round, represented by block-level parallel denoising via discrete diffusion.

    There are also compression techniques independent of the generation paradigm, such as knowledge distillation and quantization-aware training.

    2. Route 1: Keep the Writing Style, Just Add a “Draft Accelerator”

    2.1 Speculative Decoding: Guess K Tokens at Once, Verify in Parallel

    Speculative decoding alternates between drafting and verification:

    • Draft: a lightweight prediction source produces K candidate tokens at once.
    • Verify: append the candidates to the prefix, have the main model compute those K positions in parallel, then accept or reject them position by position.
    1. def speculative_generate(main, draft, prefix, K=4, eos_id=0, T=1.0):
    2. output = list(prefix)
    3. while len(output) < MAX_LEN:
    4. guess = draft.sample(output, n=K) # draft K tokens at once
    5. logps = main.logps(output + guess[:-1]) # one verification computes K positions
    6. keep = 0
    7. for x, lp in zip(guess, logps):
    8. # rejected tokens need resampling; when rejected at the end, resample from the last logits
    9. if lp.shape[-1] <= x: # placeholder: vocabulary must include EOS
    10. break
    11. r = uniform()
    12. if r < min(1.0, exp(lp[x] - lp_draft[x])): # position-wise acceptance test
    13. keep += 1
    14. else:
    15. # sample from the residual distribution normalized by (p(x)-q(x))_+
    16. output.append(resample_residual(lp - lp_draft))
    17. return output
    18. output.extend(guess[:keep]) # accept the first keep tokens
    19. output.append(sample(logps[keep])) # one extra token for "free"
    20. return output

    Draft sources typically come in three types:

    • Independent small model: small in scale, same architecture family, with a low cost coefficient c.
    • Self-drafting: the main model attaches a few multi-token prediction heads and outputs candidates for multiple positions in parallel on its own backbone.
    • Model-free priors: drafting by probability based on retrieval results or n-gram statistics.

    Whatever the source, the main model ultimately confirms position by position. The algorithm can provably sample from the same distribution as the original target (provided temperature and sampling strategy stay consistent)—this is the so-called “lossless acceleration.”

    Implementation notes:

    • Position-wise acceptance: the probability of accepting the i-th token is min(1, p(x_i)/q(x_i)), where p and q are the main model’s and the draft’s probabilities at that position. The first rejected position must be resampled from a normalized residual distribution to keep the output distribution unchanged.
    • Dynamic draft length: a fixed K is often not worthwhile; adjust it dynamically based on context entropy. Highly predictable scenarios like code completion can use a larger K, while open-ended generation should use a smaller K.
    • Hardware conditions: verifying K positions in parallel raises the compute demand of a single forward pass to roughly several times that of drafting; but decoding is memory-bound anyway, so as long as batch size isn’t too large, this compute is often used for free.

    2.2 Multi-Token Prediction: Teaching the Model to “Look Ahead” at the Training Objective Level

    Multi-token prediction adjusts the objective at the training stage:

    1. L = -Σ_t Σ_{k=1..K} log p(x_{t+k} | x_{≤t})

    It brings two benefits:

    • Representation quality: the model must anticipate multiple subsequent tokens at each position, forcing it to encode longer-range planning information.
    • Inference acceleration: these prediction heads are naturally suited as a draft source, usable with the verification flow above.

    In practice it takes the form of either “a main output head + K prediction heads” or “main prediction + cascaded prediction.” Since each position predicts multiple tokens, both training loss and training time increase, so the coefficients need to be balanced.

    2.3 Why It’s the “Most Compatible” Accelerator

    Speculative decoding and multi-token prediction don’t change the generation order; it’s still “writing left to right,” just letting the model write a few sentences ahead and then double-check. This brings three engineering advantages:

    • Zero intrusion: the inference service interface, sampling parameters, and context management all stay the same. After switching the main model to a quantized version, you just need to ensure the draft model is quantized under the same conditions.
    • Controllable quality: with strict acceptance criteria the output distribution is unchanged; when loosening criteria for higher acceptance rates, a quality evaluation set can quantify the cost.
    • Mature ecosystem: mainstream inference frameworks generally support it, with a short engineering landing cycle.

    The shortcomings are equally clear:

    • The speedup is governed by the draft acceptance rate and follows E[γ·α+1]/(γ·c+1). When each round accepts 2–3 tokens on average with low draft overhead, common speedups are on the order of 2–3×; in strongly constrained scenarios (such as JSON structures) it can be even higher.
    • But in uncertain scenarios like open-ended generation and high-temperature sampling, the acceptance rate drops noticeably; if the draft and main model have inconsistent quantization precision, distribution shift further depresses the acceptance rate.
    • Most critically, it does not break through the underlying “one token at a time” paradigm, so the speedup ceiling is ultimately bound by the acceptance rate.

    3. Route 2: Turn “Writing Sentences” into “Parallel Denoising on a Canvas”

    3.1 Canvas and Denoising

    Discrete diffusion language models learn a reverse process during training:

    1. The forward process gradually replaces tokens in a real sequence with a special [MASK] token according to a noise schedule.
    2. The model learns to predict the original token distribution for each masked position given the mask rate and context.

    At inference, the model starts from a “fully masked block,” and across multiple forward passes it fills in predictions for multiple positions at once each time; if needed, it also re-masks already-filled positions and revises them, until the whole canvas is filled.

    A typical example of such a model has the following structural features (values are illustrative):

    Item Example configuration
    Total params / active per token ~25B scale (MoE) / ~4B
    Layers / context ~30 layers / hundreds of thousands of tokens
    Canvas length 256 tokens
    Experts 128 total, 8 active + 1 shared expert

    A few parameters need to be understood separately:

    • Total vs. active parameters: sparsely activated MoE puts weights in storage while limiting computation to the selected experts, balancing capacity with per-token compute.
    • Canvas length: the basic granularity of diffusion scheduling. A longer canvas means more positions can be filled in parallel within a block; but long-range dependencies and “cross-position coordination” also become harder.
    • Long context vs. canvas length: these are two dimensions. The former determines how much history can be “referenced,” the latter determines the span “drafted” at once.

    3.2 Intuitive Illustration of the Denoising Schedule

    Let the canvas length be L=256 with T steps total; the schedule pre-assigns each position’s “unlock time” to the steps.

    1. def block_diffusion_generate(model, prompt, L=256, T=32):
    2. canvas = [MASK] * L # fully masked canvas
    3. for t in range(T):
    4. logits = model.forward(prompt + canvas) # one forward covers the whole canvas
    5. if t == T - 1:
    6. for i in range(L): # fill everything at once on the last step
    7. canvas[i] = sample(logits[i])
    8. break
    9. # keep only high-confidence positions; re-mask the rest for later rounds
    10. kept = keep_by_confidence(logits, canvas, ratio=scheduled(t, T))
    11. canvas = [token if i in kept else MASK for i, token in enumerate(canvas)]
    12. return canvas # decode after concatenation

    Note: the above is illustrative pseudocode. Different implementations vary in their confidence measures, number of tokens decoded per step, and handling of re-masking and resampling.

    Here keep_by_confidence controls how many positions are kept at each step. A common strategy is to rank by each position’s prediction distribution entropy (or top-1 probability) and keep the highest-confidence batch.

    This is like sketching with a pencil on draft paper: first fill the whole block quickly, then deepen the lines and erase the wrong local parts round by round. Compared with token-by-token generation, two differences are worth noting:

    • Revision capability: positions already written can be re-masked and rewritten in later rounds; a local error doesn’t require redoing the whole sentence.
    • Bidirectional context: positions within the canvas are mutually visible in the same forward pass, without requiring the left to come before the right.

    The costs are also direct:

    • One denoising round requires at least one full forward pass. 32 steps means roughly 32 forward passes per 256 tokens, which amortizes to only about 1/8 of a pass per token, but each pass processes the entire canvas, so per-step time is noticeably higher.
    • If the model uses full attention with no effective caching at masked layers, at step t the attention length is roughly L × (1 − (T−t)/T), averaging about L/2, growing quadratically with length. On long sequences this term can quickly dominate cost, so canvas length is often a key hyperparameter.

    3.3 Block Autoregressive and Multi-Canvas Sampling

    Pure diffusion generation struggles to guarantee document-level long-range consistency, so a hybrid “block autoregressive” strategy is often used in practice:

    • Intra-block parallelism: each 256-token canvas is denoised in parallel as above.
    • Inter-block autoregression: only after one canvas is complete does it serve as the condition for denoising the next; alternatively, multiple canvases can be maintained simultaneously and denoised in turns, forming a pipeline.
    • Structured conditioning: constraints such as document titles and code function signatures can be injected as additional conditions, with canvas content filled within their framework.

    This way, block boundaries inherit autoregressive “left to right,” while block interiors gain the freedom of parallel denoising; the overall generation order still matches the natural text order, making streaming output and integration with existing applications easy.

    4. Head-to-Head Comparison of the Two Routes

    Dimension Autoregressive + draft-verify Block-level diffusion parallel denoising
    Generation order Left to right, token by token Intra-block parallel, inter-block autoregressive
    Output per forward pass 1–K+1 after verification A batch of positions determined by the schedule
    Quality Main model confirms position by position; distribution unchanged Depends on the coordination of training and the denoising schedule
    Inference stack Mature, natively supported by mainstream frameworks Requires support for whole-block forward and mask scheduling; ecosystem is relatively new
    Main bottleneck Draft acceptance rate, draft overhead Denoising steps, full-canvas forward and memory
    Accelerator friendliness High High (intra-block parallelism is naturally suited to batching and parallel hardware)
    Positioning “Speed up” existing models and interfaces Redefine “generation” at the training stage

    Simple conclusions:

    • To speed up existing models: prioritize speculative decoding. Small changes, controllable quality, fast results.
    • Training a new model from scratch: evaluate block-level diffusion as a generation paradigm, but accept the cost of a supporting inference stack and engineering adaptation.

    The two are not mutually exclusive:

    • Speculative decoding can apply to intra-block denoising in diffusion models (treating draft-verify as a “one-shot multi-step” candidate source).
    • Diffusion models can also be trained with multi-token-prediction-style objectives.

    Understanding this keeps “changing the paradigm” and “adding an accelerator” from being conflated.

    5. A Side-by-Side: Quantization-Aware Training Solves “Another Kind of Waste”

    Independent of the generation method is quantization. When deploying at FP8, INT8, or lower bit widths, ordinary post-training quantization may show noticeable accuracy loss on models with abnormal activation distributions and many long-tail weights. Quantization-aware training (QAT) introduces fake quantization during training (or fine-tuning):

    • The forward pass uses “quantize-dequantize” to simulate inference error.
    • The backward pass uses a Straight-Through Estimator (STE) to bypass the non-differentiable rounding operator.
    • The model thereby learns to maintain output quality under quantization noise.
    1. # illustrative pseudocode: inject fake quantization during training
    2. w = weight()
    3. w_q = fake_quant(w, bits=8, scale=s) # quantize-dequantize; still a high-precision tensor numerically
    4. out = layer_forward(input(), w_q) # forward with quantization error
    5. grad = backward(out, target()) # backward goes through STE straight to w

    When combined with speculative decoding, note that if the draft model’s quantization precision is higher than the main model’s, their distributions diverge and the acceptance rate drops. In practice, the draft and main model usually adopt the same quantization scheme.

    6. Engineering Practice Notes

    1. Establish Quantifiable Evaluation Criteria

    Looking only at “how many times faster” is meaningless. Fix four metrics:

    • Latency: time to first token, TPOT, end-to-end latency.
    • Throughput: total output tokens per unit time.
    • Quality: automatic evaluation plus manual spot-checks, covering typical tasks like long-form writing, code, and structured output.
    • Stability: latency percentiles under different concurrency levels (e.g., P95, P99).

    2. Weigh “Hit Rate × Overhead” When Choosing a Draft Source

    A rough estimate:

    1. # illustrative calculation: comparing the ceilings of different draft sources
    2. K, alpha_small, c_small = 5, 0.8, 0.05 # independent small-model draft
    3. K, alpha_self, c_self = 3, 0.6, 0.15 # self-drafting
    4. print("small-model draft ceiling:", (1 + K * alpha_small) / (1 + K * c_small))
    5. print("self-drafting ceiling:", (1 + K * alpha_self) / (1 + K * c_self))
    6. # small-model draft ceiling: 4.0 ; self-drafting ceiling: 2.0

    For example, under the same main model, a small-model draft may have a higher hit rate and more rounds, but if its per-round draft overhead is lower, its ceiling is actually higher. This also explains why engineering often favors a “small and accurate” draft model. Dynamic length scheduling is equally important: use a large K for high-confidence segments and a small K for low-confidence ones.

    3. Focus on the “Steps–Quality” Curve When Scheduling Diffusion Models

    • Calibrate denoising steps: canvas length, denoising steps, and re-masking strategy need to match the training setup.
    • Quality has diminishing marginal returns as steps increase: blindly adding steps may only increase latency, not quality.
    • Provide multiple preset configurations: let business teams choose a “fast / balanced / high-precision” tier as needed.

    4. General Advice for Inference Deployment

    Whichever paradigm, production deployment usually can’t avoid three things:

    • Batching and scheduling: continuous batching lets new requests join the batch at any time and leave as soon as they finish, avoiding long requests holding up the whole batch.
    • Cache reuse: prefix caching can reduce repeated prefill overhead, which is especially noticeable for long system prompts or multi-turn conversations.
    • Memory planning: the KV cache, draft model weights, and diffusion intermediate states all consume memory. A draft model takes an extra copy of weights, and dynamic K changes the memory peak, so capacity planning needs headroom.

    In addition, constrained generation like function calling and JSON output can be combined with grammar-constrained decoding (e.g., finite-state machine / pushdown automaton validation); speculative decoding also tends to have higher acceptance rates in strongly constrained scenarios.

    5. A Landing Path on Baidu AI Cloud

    The ultimate value of model capabilities depends on service quality. On Baidu AI Cloud, you can build a complete iteration loop from its general capabilities:

    • Experimentation and hosting: model development platforms and large-model services such as Qianfan support training, fine-tuning, and hosting.
    • Inference hosting: the Baige platform’s inference services and elastic scaling handle traffic peaks.
    • Data and event streams: object storage holds evaluation sets, and message queue services decouple training and evaluation event streams.
    • Observability: logging and monitoring-alert services continuously track latency percentiles, throughput, and quality metrics.

    A complete “train-evaluate-deploy-observe” loop lets every paradigm upgrade be backed by data.

    7. Clearing Up Common Misconceptions

    Claim Reality
    “Speculative decoding is lossless acceleration, use it freely” Only strict position-wise acceptance (and residual resampling) preserves the distribution; engineering simplifications (e.g., accepting only the most probable token) change the sampling result
    “Diffusion models are always faster than autoregressive” Intra-block parallelism does offer an advantage, but steps, full-canvas forward overhead, and context length can all offset the gains; measure per task
    “A longer canvas is always better” Longer canvases raise the bar for long-range dependencies and cross-position consistency, while steps and memory overhead rise accordingly
    “QAT is only used during training” Inference needs matching quantization kernels, dequantization parameters, and calibration; otherwise the training gains can’t be realized
    “After switching to the diffusion paradigm, the existing inference stack works as-is” Mask scheduling, re-masking strategy, and inter-block caching all require native support in the inference framework

    8. Conclusion

    From “autoregressive + draft accelerator” to “block-level diffusion parallel denoising,” this is essentially two answers to the same question: how to reduce the number of serial model forward passes.

    • Speculative decoding and multi-token prediction: don’t change the generation method, only change “how much is computed at once,” winning on compatibility, stability, and a mature ecosystem.
    • Block-level diffusion generation: changes the generation method itself, trading canvas for parallelism, winning on large intra-block parallel potential at the cost of dual adaptation of both training and the inference stack.
    • Quantization-aware training: runs through both, addressing “precision efficiency per unit of compute and storage,” and serves as a general foundation on the deployment side.

    When choosing, return to business metrics: latency percentiles, throughput, quality, and engineering cost. There is no “better” paradigm, only a “better-matched” solution.