Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path →
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.
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.
Batching and speculative decoding soften this, but the fundamental shape — one token per step — stays. Diffusion changes the shape.
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.
■□□□□□□□ → ■■□□□□□□ → …
N passes for N tokens
████████ → ▓▓▓▓▓▓▓▓ → ■■■■■■■■
whole block in K passes
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.
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 diffusion | Text diffusion | |
|---|---|---|
| Data | continuous (pixels/latents) | discrete (tokens) |
| "Noise" | Gaussian perturbation | masking positions |
| Denoise step | predict & subtract noise | un-mask / re-predict tokens |
| Covered in | Diffusion Models | this 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.
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.
| Strategy | What it keeps each step | Where you'll meet it |
|---|---|---|
| Random remasking | A 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 remasking | The predictions the model is most sure of. The least confident go back under the mask. | LLaDA's default |
| Confidence threshold | Every 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 block | Any 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 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.
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.
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.
| Attention | KV cache | Output length | |
|---|---|---|---|
| Autoregressive | causal | exact, every past token | open-ended |
| Masked diffusion (LLaDA, Dream) | bidirectional over the whole sequence | none; every step recomputes | fixed before step 1 |
| Block diffusion (BD3-LMs) | causal between blocks, bidirectional within | exact for finished blocks | open-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.
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 → 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.
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.
| Model | Who and when | What it showed |
|---|---|---|
| LLaDA 8B | Renmin 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 7B | The 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 / Small | Inception 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 Diffusion | Google 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.
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.
The continuous cousin: Diffusion Models. The AR speedup: Speculative Decoding. Serving throughput: LLM Serving.
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.
Worked example: passes vs positions for one 512-token answer
Say a request has a 200-token prompt and needs a 512-token answer. Count two things for each decoder: forward passes, which set latency at small batch, and positions computed, which set the compute bill under load. Diffusion rows commit 8 tokens per step.
| Decoder | Passes | Positions computed | Arithmetic |
|---|---|---|---|
| Autoregressive, KV cache | 512 | 712 | prefill 200, then 1 new position per step |
| Masked diffusion, exact 512 allocation | 64 | 45,568 | 64 steps × (200 + 512) |
| Masked diffusion, 1,024 allocated | 128 | 156,672 | 128 steps × (200 + 1,024) |
| Block diffusion, B = 64, K = 8 | 64 | 4,296 | 200 + 8 blocks × 8 steps × 64 |
| Block diffusion, B = 64, K = 64 | 512 | 32,968 | 200 + 8 blocks × 64 steps × 64 |
Row 2 is the page’s KV-cache point in numbers: 8× fewer passes for 64× the compute of autoregression. Row 3 shows why the length hyperparameter matters. Over-allocating to 1,024 doubles the passes, because the sampler must fill the padding too, and pushes compute to about 220× autoregression. Row 4 is why block diffusion exists: the same 64 passes as row 2 for about a tenth of its compute, because finished blocks are cached. Row 5 is the no-free-lunch case. With K = B every step commits one token, so you get autoregression’s pass count and still pay 64 positions per pass.
Where this shows up in production and interviews
- Latency-bound code tools
Autocomplete and inline edits are short, checkable outputs that a person waits on, which is where the page’s near-parity on code benchmarks and 1,000-plus tokens per second line up. Mercury Coder is the commercial example the page cites.
- Filling in the middle
A masked model sees context on both sides of every gap, so editing a span inside existing text needs no special training trick. That any-order view is the same property behind the page’s Sudoku, Countdown and reversal results.
- Capacity planning
The worked example decides the hardware story. At batch size 1 the GPU is memory-bound and fewer passes win. On a busy server it is compute-bound, and positions computed is the number to watch, which favours block diffusion or an approximate cache such as Fast-dLLM’s.
- The interview version
Asked to cut generation latency, compare speculative decoding with diffusion decoding. Both commit several tokens per pass. Speculative decoding keeps the autoregressive model’s output distribution and its KV cache; diffusion changes the model and gives up exact caching unless it is block-structured. Then name the cost metric you would measure: passes, or positions.
Check yourself
Block size 32, 4 steps per block, a 300-token answer. How many passes, and why is the speedup over autoregression not exactly B/K = 8?
⌈300/32⌉ × 4 = 40 passes, so the speedup is 300/40 = 7.5×. The tenth block holds only 12 real tokens but still costs the full 4 steps. B/K is the per-block ratio; rounding up the block count costs a little at the end.
A LLaDA-style sampler reserves 1,024 positions for an answer that turns out to be 40 tokens. What does that cost?
Every step recomputes the prompt plus all 1,024 positions, and the step count is set by the allocation, not the answer. Nearly all of that compute goes to positions that end as discarded end-of-sequence padding. Fit the allocation to the expected length, or use block diffusion, which stops when a block contains end-of-sequence.
Low-confidence remasking on an instruction model keeps producing truncated reasoning. What is happening, and what is the fix?
The model is most confident about the end-of-sequence padding it saw in fine-tuning, so it commits the ending first and leaves too little room for the reasoning. That is the failure the LLaDA authors describe. Sampling block by block, left to right, stops the ending being decided first.
You serve a diffusion LLM at batch size 1 and it beats your autoregressive model on latency. At batch size 64 it loses on throughput. Why?
At batch 1, autoregressive decoding is memory-bound: compute sits idle while weights stream in, so diffusion’s extra positions are nearly free and its fewer passes win. At batch 64 the GPU is compute-bound, and the recomputation (64× in the worked example’s row 2) uses up throughput that could have served other requests.
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.
Explore the topic
See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.
More Handbooks
- The Prompting HandbookA friendly, hands-on field guide for everyday humans — learn the CRISP framework, spot bad prompts, practice with real recipes, play a drag-and-drop game, and test yourself with a quiz. No code required.Read →
- The Senior AI Engineer Interview Handbook60 questions across architecture, production incidents, agentic systems, RAG, evals, cost, safety, and leadership — what staff-level AI interviewers actually probe for.Read →
- The LLM Serving HandbookHow to serve large language models fast and cheap — prefill vs decode, the KV cache, continuous batching and PagedAttention (vLLM), quantization, speculative decoding, and the latency-vs-throughput tradeoffs that decide your inference bill.Read →
- The Transformers HandbookThe architecture behind every LLM, built up from scratch — tokens and embeddings, positional encoding, self-attention (query/key/value), multi-head attention, the transformer block (FFN, residuals, layer norm), and how a decoder-only model generates text autoregressively.Read →
- The Fine-Tuning HandbookWhen to fine-tune vs RAG vs prompting, full fine-tuning vs parameter-efficient methods, how LoRA and QLoRA make it cheap enough for a single GPU, why the data matters more than the method, catastrophic forgetting, and how to evaluate and decide.Read →
- The On-Device AI HandbookSmall models, everywhere: why 1–14B models got frontier-adjacent (distillation + textbook data), the napkin law of local inference (tokens/sec ≈ bandwidth ÷ bytes), quantization and the llama.cpp / GGUF / Ollama / MLX stack, the honest local-vs-cloud decision table, four hybrid patterns that ship, and the evals craft of choosing a small model that actually fits the device.Read →