kb://library/diffusion-language-models2026-06-16

Diffusion Language Models

diffusionlanguage-modelsparallel-decodingmasked-diffusioninferencegenerative-modelstransformers

Diffusion Language Models

One-line intuition: Instead of writing a sentence one token at a time, left to right, a diffusion language model starts from a sentence that is all blanks and fills the blanks in in parallel, refining its guess over a handful of denoising passes — trading the rigid left-to-right factorization of [[attention-and-transformers]]-based LLMs for a different bet: speed and bidirectionality, at the cost of a hard statistical-independence problem.

What it is (intuition)

Almost every LLM you have used — GPT, Llama, Claude, [[deepseek-architecture|DeepSeek]] — is autoregressive (AR): it factorizes the probability of a text as a product of next-token distributions,

p(x₁…x_L) = ∏ᵢ p(xᵢ | x₁…xᵢ₋₁)

and generates strictly one token per forward pass, in order. That is why generation latency scales with output length: 500 tokens means 500 sequential network calls. (See [[llm-inference-internals]] and [[speculative-decoding]] for the tricks AR models use to claw some of that back.)

A diffusion language model (DLM) throws out the left-to-right ordering. Borrowing the idea from image diffusion ([[diffusion-models]]), it defines a forward corruption process that gradually destroys a clean text into pure noise, and trains a network to reverse that corruption. For text the dominant flavor is masked / absorbing-state discrete diffusion: "noise" means replacing tokens with a special [MASK] token. The forward process masks more and more of the sentence until it is all [MASK]; the model learns, at any masking level, to predict the original tokens. To generate, you start from a fully-masked canvas and un-mask tokens over a few iterative steps, predicting all remaining masked positions at once each step.

Two intuitions that make this click:

  • It is a "coarse-to-fine" or "rough draft → polish" generator. The first denoising step paints a blurry, low-confidence guess of the whole answer; later steps lock in the confident tokens and re-decide the shaky ones. Image diffusion does the same to pixels; DLMs do it to tokens.
  • It is a *parallel* generator. Because the whole sequence is predicted jointly, you can fill in 256 tokens in (say) 12 network passes instead of 256. That is where the headline "~4× faster" numbers come from in 2026.

The catch — stated up front because this article is honest — is that predicting many tokens simultaneously forces a conditional-independence assumption that natural language violates. Managing that tension is the entire engineering story of modern DLMs.

Why it matters

  1. Latency, not just throughput. AR decoding is fundamentally sequential — O(L) forward passes. DLMs decouple the number of network passes from the number of tokens, so a long completion can land in a fixed, small number of denoising steps. In 2026 this has gone from a research curiosity to shipping products: - Mercury (Inception Labs) reports 1109 tokens/sec (Mercury Coder Mini) and 737 tokens/sec (Mercury Coder Small) on NVIDIA H100s — roughly 8–10× faster than speed-optimized AR frontier models — while scoring 88–90% on HumanEval and ~76% MBPP. - DiffusionGemma (Google DeepMind, released 2026-06-10) is a 26B-parameter [[mixture-of-experts|MoE]] (≈3.8–4B active) diffusion model on the Gemma 4 backbone, advertised at up to ~4× faster generation than the equivalent AR Gemma 4, with quantized weights fitting in 18 GB VRAM — i.e., a high-end consumer GPU. - LLaDA (Feb 2025) was the proof that you can scale masked diffusion to 8B params trained from scratch and stay competitive with Llama 3 8B.
  1. Bidirectionality fixes some AR pathologies. Because a DLM attends to context on both sides of a masked position (no causal mask), it natively does infilling / fill-in-the-middle and is less prone to the reversal curse ("A is B" ⇏ "B is A"). LLaDA beats GPT-4o and Qwen2.5 on a reversal-poem task precisely because its token dependencies are not hard-wired left-to-right.
  1. A genuinely different lever on the cost curve. AR speedups ([[speculative-decoding]], [[quantization]], better KV caching) all keep the sequential backbone. DLMs attack the backbone itself. Whether that lever ultimately wins is still open (see caveats), but it is one of the few non-incremental directions in inference efficiency.

How it works (real mechanics)

The lineage (so the formulas aren't magic)

  • D3PM (Austin et al., NeurIPS 2021) generalized diffusion to discrete state spaces via a corruption transition matrix Qₜ. One choice — an absorbing state where every token can decay into a special [MASK] symbol but never leave it — is the ancestor of everything here. D3PM noted this connects diffusion to autoregressive and mask-based models.
  • MDLM (Sahoo et al., NeurIPS 2024) showed the absorbing-state objective simplifies dramatically. Its SUBS parameterization enforces two facts that match intuition: (1) the model never predicts [MASK] as an output (zero-masking-probability), and (2) once a token is un-masked it is frozen ("carry-over un-masking") — it cannot revert. With SUBS, the diffusion ELBO collapses into a weighted mixture of ordinary masked-LM cross-entropy losses — i.e., training a DLM is almost BERT-style masked-token prediction, but with a principled per-step weighting that makes it a proper likelihood model.
  • LLaDA (Nie et al., 2025) scaled this to 8B and is the cleanest reference for the mechanics below.

Forward process (corruption)

Pick a continuous "time" t ∈ [0,1]. Each token is independently masked with probability t:

q_{t|0}(xₜⁱ | x₀ⁱ) =  { 1 − t ,  if xₜⁱ = x₀ⁱ   (token survives)
                      {   t   ,  if xₜⁱ = [MASK] (token absorbed)

At t = 0 the text is clean; at t = 1 it is entirely [MASK]. There is no Gaussian noise schedule as in continuous [[diffusion-models]] — "noise level" is literally "fraction masked."

Training objective (the load-bearing formula)

A bidirectional Transformer mask predictor p_θ(· | xₜ) is trained to recover the original tokens at masked positions. LLaDA's loss (its Eq. 3):

L(θ) = − E_{t, x₀, xₜ} [ (1/t) · Σᵢ 𝟙[xₜⁱ = MASK] · log p_θ(x₀ⁱ | xₜ) ]

Read it piece by piece:

  • 𝟙[xₜⁱ = MASK] — only masked positions contribute (it is masked cross-entropy).
  • t ~ U[0,1] — every training example is corrupted at a random masking ratio, so the model must handle "10% masked" and "95% masked" alike.
  • `1/t` weighting — the crucial term. It up-weights heavily-masked (hard, low-t) examples so the loss is a valid variational upper bound on the negative log-likelihood:
  − E_{p_data}[ log p_θ(x₀) ]  ≤  L(θ)

This is what separates a principled DLM from a plain MaskGIT/BERT-style masked-LM (which omits 1/t and is therefore not a likelihood model). It is why DLMs can report perplexity and be compared head-to-head with AR models.

Architecturally LLaDA mirrors Llama 3 8B except: no causal mask (full bidirectional attention), vanilla multi-head attention (grouped-query attention is incompatible with the bidirectional formulation), and no KV cache at inference (the well-known efficiency wound — see caveats).

Reverse process (sampling / generation)

Generation runs the clock backward from t = 1 (all [MASK]) toward t = 0 over N discretized steps. Pseudocode for one step from time t down to s (s < t):

def denoise_step(x_t, t, s, model):
    # 1. Predict ALL masked positions at once (one forward pass)
    logits = model(x_t)                 # bidirectional; sees both sides
    x0_pred = sample_or_argmax(logits)  # provisional clean guess for every mask

    # 2. Fill every currently-masked position with the prediction
    x_filled = where(x_t == MASK, x0_pred, x_t)

    # 3. Re-mask a fraction (s/t of the predictions) to match the
    #    forward marginal at time s  -> these get reconsidered next step
    n_remask = round((s / t) * num_masked(x_t))
    remask_idx = choose_to_remask(x_filled, logits, n_remask)
    x_filled[remask_idx] = MASK
    return x_filled                      # now at time s

The re-masking strategy in step 3 is where quality is won or lost:

StrategyWhat it doesIn practice
Random re-maskingre-mask s/t of predicted tokens uniformly at randomthe "faithful to theory" baseline
Low-confidence re-maskingkeep the highest-confidence predictions, re-mask the least-confident s/tbest quality in LLaDA; analogous to confidence-annealing in AR decoding
Semi-autoregressive (block) decodingsplit the output into left-to-right blocks; diffuse within a block, then freeze it and move rightbridges AR and diffusion; the basis of Mercury, DiffusionGemma, and block-diffusion work

Knobs that define the speed/quality dial:

  • `N` (number of denoising steps). Fewer steps → faster but more independence error. LLaDA uses up to ~256 steps for quality-sensitive eval; DiffusionGemma's docs recommend a max of 48 steps, typically 12–16 with adaptive early-stopping (entropy threshold ≈ 0.005). The 4×–10× speedups all come from N ≪ L.
  • Tokens un-masked per step. Un-masking more positions per step is faster but worsens the independence violation (below).
  • Block size (for semi-AR). DiffusionGemma uses 256-token blocks with "block-autoregressive multi-canvas sampling": AR across blocks, diffusion within.

The core statistical problem (why this is hard, not just fast)

When the model un-masks k positions in one step, it samples each from its own marginal p_θ(xⁱ | xₜ) and assumes they are conditionally independent given the current canvas. Language is full of joint dependencies ("New ___" → both "York" and "Jersey" are high-probability individually, but you must not emit both incoherently). This conditional-independence assumption is the root cause of DLM quality degradation under aggressive parallelism — empirically characterized by ParallelBench (2026), which shows quality falls as you decode more tokens per step. Mitigations:

  • Confidence-aware parallel decoding — only un-mask tokens above a confidence threshold per step (Fast-dLLM); the rest wait.
  • Fewer tokens / more steps — trade the dial back toward quality.
  • Block decoding — limit the independence assumption to a small local block.

Solving the KV-cache wound

AR models cache keys/values so each new token is cheap. A naive bidirectional DLM re-attends over the whole sequence every step → no caching, so the per-step cost is high and the "parallel" win partly evaporates. Fast-dLLM (ICLR 2026) introduced a block-wise approximate KV cache: cache the K/V of the frozen prefix (prompt + completed blocks), reuse across denoising steps, refresh only at block boundaries — recovering large speedups training-free. This, plus confidence-aware decoding, is what makes 2026 DLMs competitive in wall-clock, not just in step-count.

Key ideas & tradeoffs

DimensionAutoregressive LLMDiffusion LM
Factorizationstrict left-to-right `∏ p(xᵢ\x_<i)`joint, order-agnostic; tokens revealed by confidence
Passes to emit L tokensL (sequential)N denoising steps, N ≪ L (parallel)
Attentioncausal maskbidirectional (sees both sides)
Infilling / FIMawkward (needs special training)native
Reversal cursesufferslargely avoided
KV cachetrivial, maturehard — needs block-cache approximations
Variable-length outputnatural (emit [EOS])awkward — canvas length often fixed up front
Sampling controltemperature, top-p, beamsteps N, remask strategy, confidence threshold, block size
Failure modeexposure bias, sequential latencyindependence violations under heavy parallelism

Headline 2026 data points (verified from sources):

  • LLaDA 8B vs Llama 3 8B (pretrained): MMLU 65.9 / 65.4, GSM8K 70.3 / 48.7, HumanEval 35.4 / 34.8, CMMLU 69.9 / 50.7. Reversal-poem: LLaDA 45.6 vs GPT-4o 34.3.
  • Mercury Coder (H100): 737–1109 tok/s, HumanEval 88–90%, FIM single-line ~93% — proprietary weights + proprietary inference engine.
  • DiffusionGemma: 26B MoE (~4B active), Gemma 4 backbone, ~4× faster than AR Gemma 4, Apache-2.0, natively served in vLLM at launch — the first open DLM with first-class production serving.

Honest caveats & open questions

  • "Near-AR quality at ~4× speed" is real but *conditional*. The speedup assumes you accept a step budget (N ≈ 12–48) and the matching quality hit, and that the serving stack has block-KV-cache + confidence decoding. Naive open DLMs without those tricks have historically been slower in wall-clock than AR despite needing fewer steps, because of the no-KV-cache penalty. Speed claims that quote tok/s on H100s with a proprietary engine (Mercury) are not directly comparable to a vanilla open checkpoint.
  • The independence assumption is a real ceiling, not a bug to be fully patched. ParallelBench shows there is an inherent parallelizability-vs-quality trade-off. You can push it with confidence thresholds, but you cannot make many-token-per-step decoding free of dependency errors. On tasks with tight long-range token coupling, DLMs degrade.
  • Agentic / long-horizon use is unproven. A 2026 reality-check ("The Bitter Lesson of Diffusion Language Models for Agentic Workflows") argues DLMs lag on multi-turn tool-use/agentic settings — partly because fixed-canvas generation fights variable-length, streaming, interruptible agent loops. Work on [EOS]-led variable-length DLMs is active but young.
  • Tooling maturity gap. AR has a decade of optimized kernels, KV-cache infra, structured-decoding, [[speculative-decoding]], and [[quantization]] support. DLM serving (block caching, adaptive step counts, vLLM support) only matured in 2026. Much of the published speed advantage depends on bespoke engines.
  • Disclosure asymmetry. LLaDA and MDLM are open with full math. Mercury is proprietary (closed weights, closed inference engine) — its architecture is described only as "transformer + coarse-to-fine diffusion," so treat its exact mechanism as undisclosed. DiffusionGemma is open-weight (Apache-2.0) but its docs describe decoding hyperparameters more than the training recipe.
  • Open theoretical question. Does the variational masked-diffusion objective ultimately reach AR-level likelihood at scale, or is there a persistent perplexity gap? MDLM closed much of it on small corpora; at 8B+ LLaDA is "competitive," not strictly better. Whether DLMs follow the same [[scaling-laws]] slope as AR is not yet settled.

How it connects to OpenAlice

OpenAlice's substrate is provider-agnostic — Alice talks to LLM backends through a config layer ([[model-routing]]), and her reasoning loops ([[agentic-loops]]) issue many short generations per turn (tool calls, classification, rewrites). That shape makes DLMs interesting but not yet load-bearing for us:

  • Where a DLM could help today: the latency-sensitive, short, structured generations in Alice's hot path — intent classification, tool-argument synthesis, code/FIM completions for the autonomous-coding capability (repo → PR), and fast inline edits. Mercury-class 737–1109 tok/s code generation is exactly the profile of a fast inner-loop coder; a block-diffusion FIM model maps cleanly onto patch-style edits. These are bounded-length, low-coupling tasks — the regime where the independence assumption hurts least.
  • Where to stay AR for now: Alice's personality-bearing, long-form, multi-turn companion replies. The lab's hard rule is that Alice's voice is preserved verbatim and her long-horizon coherence is non-negotiable — precisely the long-range-dependency regime where current DLMs degrade and where agentic-DLM results are still negative. Routing a personality turn through a parallel-decoded DLM would be exactly the kind of "optimize the soul away" move the project forbids.
  • Architectural reuse, not rip-and-replace. A DLM is still a [[attention-and-transformers|Transformer]]; it shares tokenizers ([[tokenization]]), [[positional-encoding]], and [[quantization]] machinery with the AR stack. The realistic OpenAlice play is additive routing: register a fast diffusion backend in the router for the narrow class of short/structured/latency-critical calls, A/B it on the bench, and keep AR for everything personality- or long-context-sensitive — mirroring how [[speculative-decoding]] and [[mixture-of-experts]] are treated as inference levers rather than identity changes.

In short: diffusion LMs are the most credible non-incremental attack on inference latency to land in production in 2026, but their wins are concentrated in short, weakly-coupled generations. For OpenAlice that is a targeted tool for the coding/inner-loop path, not a replacement for Alice's autoregressive voice.

See also

[[diffusion-models]] · [[attention-and-transformers]] · [[speculative-decoding]] · [[llm-inference-internals]] · [[mixture-of-experts]] · [[model-routing]] · [[scaling-laws]] · [[quantization]] · [[tokenization]] · [[positional-encoding]] · [[agentic-loops]] · [[deepseek-architecture]]