Vibe Engines
YouTube

Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path

Handbooks  /  Diffusion LLMs
Handbook~13 min readInferenceworked math + runnable code
Handbook

Diffusion
LLMs.

Every chatbot you've used writes the same way: one token, then the next, then the next — a strictly sequential crawl where the length of the answer is the latency. Diffusion language models break that rule. They start from a blank, masked block and refine the whole thing at once over a handful of steps, deciding dozens of tokens per pass. That's where the 1,000-plus-tokens-per-second headlines come from — and it's a genuinely different way to generate text, not a faster version of the old one.

01

The autoregressive wall

Autoregressive (AR) models — GPT, Claude, Llama — generate token t+1 conditioned on tokens 1..t. That conditioning is the whole trick, and also the whole bottleneck: you cannot start token t+1 until token t exists. Generating N tokens means N sequential forward passes, so latency grows linearly with output length.

autoregressive: N tokens = N sequential passes  →  latency ∝ N (one token per pass)

Batching and speculative decoding soften this, but the fundamental shape — one token per step — stays. Diffusion changes the shape.

02

Block diffusion: decide many tokens at once

A diffusion LLM takes a block of B positions, starts them all masked, and runs K refinement (denoising) steps. Each step looks at the whole partially-filled block and commits more tokens, until after K steps the block is clean. The key number: it emits B/K tokens per pass instead of one.

Autoregressive crawl vs block denoise
AR
■□□□□□□□ → ■■□□□□□□ → …
N passes for N tokens
vs
Diffusion
████████ → ▓▓▓▓▓▓▓▓ → ■■■■■■■■
whole block in K passes
diffusion passes = ⌈N/B⌉·K  ·  speedup vs AR = B/K per block

With a 64-token block refined in 8 steps, that's 8 tokens per pass — an 8× drop in pass count versus AR. Push K down and throughput climbs; the runnable below counts the passes for any B and K.

03

Text diffusion is not image diffusion

This shares a name with the image diffusion that powers Stable Diffusion and friends — but the mechanism underneath is different in a way that matters. Image diffusion adds and removes continuous Gaussian noise from pixel or latent values; "a little noise" is a real-valued perturbation of a real-valued signal.

Text is discrete. You can't add 0.3 of Gaussian noise to the token "cat" — there's no halfway between "cat" and "cot" in token space. So text diffusion uses a discrete corruption process: instead of noising values, it masks tokens and learns to un-mask them. The "noise level" is which positions are hidden, and denoising is progressive un-masking.

Image diffusionText diffusion
Datacontinuous (pixels/latents)discrete (tokens)
"Noise"Gaussian perturbationmasking positions
Denoise steppredict & subtract noiseun-mask / re-predict tokens
Covered inDiffusion Modelsthis handbook

Same big idea — learn to reverse a corruption process, then run it from pure noise to generate — but "corruption" means something categorically different for tokens than for pixels.

04

Inside a denoising step: predict everything, keep the sure ones

One denoising step is one forward pass over the whole sequence: the prompt plus every response position, masked or not. The model predicts a token for every masked position at once. The sampler then decides which of those predictions to commit and which to throw back under the mask for the next step. That decision is the remasking strategy, and it matters as much as the model does.

StrategyWhat it keeps each stepWhere you'll meet it
Random remaskingA random subset of the predictions. Each is sent back under the mask with probability s/t as the noise level falls from t to s.LLaDA's baseline sampler
Low-confidence remaskingThe predictions the model is most sure of. The least confident go back under the mask.LLaDA's default
Confidence thresholdEvery prediction above a probability threshold, so how many tokens a step commits adapts to how easy the text is.Fast-dLLM's parallel decoding
Block by blockAny of the rules above, applied inside one block at a time, left to right.Block diffusion (BD3-LMs), LLaDA's block sampling

Here is low-confidence remasking on a six-position answer to "What is the capital of France?", committing two tokens per step (illustrative):

step 1: _ _ _ _ _ _  → keep the two surest: "Paris", "<eos>"
step 2: _ _ _ Paris _ <eos>  → keep "is", "."
step 3: _ _ is Paris . <eos>  → keep "The", "capital"
result: The capital is Paris. — the answer was written before the words that lead up to it

Notice that the length was fixed before step 1. In LLaDA, generation length is a hyperparameter. The sampler allocates that many masked positions up front, the model learns during fine-tuning to fill the unused tail with end-of-sequence tokens, and everything after the first one is discarded. Every step still pays for the whole allocation, so reserving 1,024 positions for a 40-token answer burns most of the compute.

The schedule changes accuracy, not just speed. In the LLaDA paper, the 8B Instruct model scores 69.4 on GSM8K under pure diffusion sampling with low-confidence remasking, and 78.6 when it is sampled block by block. The authors trace the gap to "extensive EOS token padding in the SFT data, causing early termination in low-confidence remasking." The model is most confident about the padding, so it commits the ending first and squeezes the reasoning out. Forcing left-to-right blocks stops that.

05

The catch: bidirectional attention breaks the KV cache

An autoregressive model is cheap per step for a reason that has nothing to do with pass count: its KV cache. Under a causal mask, token 37 never attends to anything after it, so its keys and values are final the moment it is generated. Each new step computes one new position and reads the rest from memory.

Masked diffusion gives that up to get parallelism. The LLaDA paper says so directly: the model "does not use a causal mask," and as a result "LLaDA is incompatible with KV caching." Every position attends to every other position, the prompt included. When a step commits even one token, the hidden states of every position above the first layer shift, and so do their keys and values. Each denoising step is therefore a full forward pass over the prompt and the entire allocated response.

AR step        = compute 1 new position, read the rest from the KV cache
diffusion step = recompute P + L positions (prompt + whole allocated response)

Illustrative: a 1,000-token prompt and a 256-token answer. AR does one 1,000-token prefill and then 256 one-token steps, about 1,256 positions computed. Full-sequence diffusion at 4 tokens per step runs 64 steps of 1,256 positions each, about 80,000. That's 4× fewer passes for roughly 64× more compute.

That trade can still win at small batch sizes. Single-stream AR decoding is bound by memory bandwidth: each step streams the full weights to produce one token while the compute units sit mostly idle, and a diffusion step puts that idle compute to work. The bill arrives under load, when a batched server is compute-bound and the recomputation eats throughput you could have served (see LLM Serving).

This is the real motive for block diffusion. Arriola et al.'s BD3-LMs (an ICLR 2025 oral) make the model autoregressive across blocks and diffusion within one. A finished block never changes again, so its keys and values are cached like an AR prefix, and each step recomputes only the block being denoised. The same move removes the fixed-length limit: the model keeps emitting blocks until one contains end-of-sequence.

AttentionKV cacheOutput length
Autoregressivecausalexact, every past tokenopen-ended
Masked diffusion (LLaDA, Dream)bidirectional over the whole sequencenone; every step recomputesfixed before step 1
Block diffusion (BD3-LMs)causal between blocks, bidirectional withinexact for finished blocksopen-ended, block by block

The other route is to approximate. Fast-dLLM (Wu et al., May 2025) adds a training-free, block-wise approximate KV cache to LLaDA and Dream, reusing keys and values that barely move between adjacent steps. It pairs the cache with confidence-threshold decoding and reports up to 27.6× higher throughput with minimal accuracy loss.

06

The speed–quality knob

The number of steps K is a dial, and it trades throughput against coherence. Fewer steps means more tokens committed simultaneously per pass — faster, but riskier: tokens chosen in the same step can't fully condition on one another, so they can come out mutually inconsistent (the classic diffusion failure where a sentence is locally fine but globally muddled). More steps restores that conditioning and the coherence with it, at the cost of speed.

K → 1 (few steps): max throughput, more parallel-commitment error
K → B (many steps): approaches autoregressive quality, loses the speed win

The honest picture: diffusion LLMs win big where raw speed beats the last few quality points — high-throughput drafting, latency-critical UX, cheap bulk generation — while autoregressive still tends to lead on the hardest, most sequential reasoning, where every token really does depend on the one before it. It's a new point on the speed-quality frontier, not a strict upgrade.

07

The named models: LLaDA, Dream, Mercury, Gemini Diffusion

Four systems carry most of what is public about diffusion language models. Every figure below comes from the builder's own paper or page.

ModelWho and whenWhat it showed
LLaDA 8BRenmin University of China and Ant Group, February 2025. Base and Instruct weights on Hugging Face under MIT.Trained from scratch on 2.3T tokens, then fine-tuned on 4.5M pairs. The base model beats LLaMA3 8B on GSM8K (70.3 vs 48.7) and roughly ties it on MMLU (65.9 vs 65.4). The Instruct model, fine-tuned only with no RL, trails LLaMA3 8B Instruct overall.
Dream 7BThe University of Hong Kong and Huawei Noah's Ark Lab, April 2025. Weights on Hugging Face under Apache-2.0.Initialized from Qwen2.5 7B's autoregressive weights and trained on 580B tokens. Strong on planning tasks such as Countdown and Sudoku, and its decoding order is tunable from left-to-right to fully random.
Mercury Coder Mini / SmallInception Labs, tech report June 2025. Commercial.1,109 and 737 tokens/sec on NVIDIA H100s. The report claims up to 10× the speed of speed-optimized frontier models at comparable quality.
Gemini DiffusionGoogle DeepMind, shown at Google I/O in May 2025. An experimental demo behind a waitlist.1,479 tokens/sec average sampling speed, excluding 0.84 s of overhead. Close to Gemini 2.0 Flash-Lite on code (HumanEval 89.6% vs 90.2%, MBPP 76.0% vs 75.8%), behind on GPQA Diamond (40.4% vs 56.5%) and Global MMLU Lite (69.1% vs 79.0%).

The Gemini Diffusion row sums up the field: near-parity on code, where answers are short and checkable, and a real gap on knowledge- and reasoning-heavy benchmarks. Diffusion's wins show up where any-order generation helps. Dream beats autoregressive models of its size on Countdown and Sudoku, where the end constrains the start. On LLaDA's reversal test (completing the line before a given line of a Chinese poem), the 8B Instruct model scores 45.6 to GPT-4o's 34.3, while trailing badly in the forward direction (51.8 vs 82.7).

Each builder measured speed on its own hardware, so compare a diffusion figure with the autoregressive baseline in the same report, not with another vendor's number.

08

Where it fits

Inception's Mercury Coder Mini (1,109 tokens/sec on an H100) and Google's Gemini Diffusion (1,479 tokens/sec) both clear a thousand tokens per second, which is what you'd predict from emitting a block every handful of passes. That makes them compelling for interactive coding assistants, autocomplete at scale, and any workload where a human is watching the text stream in.

For an engineer the takeaway is a new axis to reach for: when latency dominates and the task tolerates a small quality trade, a diffusion decoder can be a step-change, not a tweak. Pair it with the image-diffusion foundations for the shared math, and with speculative decoding for the autoregressive world's answer to the same latency problem.

Read next

The continuous cousin: Diffusion Models. The AR speedup: Speculative Decoding. Serving throughput: LLM Serving.

RUN IT YOURSELF

Count the passes: autoregressive vs block diffusion

The whole speed story is a pass count. Autoregressive decoding needs one forward pass per token, so N tokens cost N passes. Block diffusion refines a block of B tokens in K steps and emits B/K tokens per pass — so its total is ⌈N/B⌉·K. Watch the speedup equal B/K, watch it vanish when K rises to B (denoising every token separately is just autoregression), and change the block size and step count.

CPython · WebAssembly
Frequently asked

Quick answers

What is a diffusion LLM?

A model that generates text by iterative denoising of a masked block instead of one token at a time — filling many positions in parallel over a few refinement steps, which unlocks far higher tokens-per-second than autoregressive decoding.

How does it differ from image diffusion?

Image diffusion perturbs continuous pixel/latent values with Gaussian noise. Text is discrete, so text diffusion masks tokens and learns to un-mask them — the "noise" is which positions are hidden, not a real-valued perturbation.

Why is it faster?

Autoregressive decoding needs N sequential passes for N tokens. Block diffusion decides B tokens in K steps, emitting B/K tokens per pass — so when K ≪ B the pass count drops sharply.

Why can't a diffusion LLM use a normal KV cache?

Because its attention is bidirectional. In an autoregressive model a causal mask means a token never attends to later positions, so its keys and values are final once it is generated and can be cached. A masked diffusion model like LLaDA lets every position attend to every other, so committing any token changes the keys and values of all positions, and each denoising step must recompute the whole sequence. Block diffusion restores exact caching by making attention causal between blocks, and Fast-dLLM approximates a cache by reusing keys and values that barely change between steps.

What's the trade-off?

Fewer steps = faster but more parallel-commitment error (tokens chosen together can't fully condition on each other). More steps recovers coherence at the cost of speed. Diffusion wins where speed beats the last few quality points.

The Diffusion LLMs Handbook · Vibe Engines · 2026 · throughput and benchmark figures from the LLaDA and Dream papers, Inception Labs' Mercury report and Google DeepMind's Gemini Diffusion page ·more handbooks →
Finished this one? 0 / 208 Handbooks done
NextAutoregressive vs Diffusion LLMs Next on the “How models actually work” ladder · rung 9 of 11

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More Handbooks