Diffusion Language Models › Sampling

Michael BrenndoerferNovember 17, 20264 min read
Language AI HandbookAll chapters
Part 19 of 67Alternative Sequence and Generative Architectures
Chapter 136Diffusion Language Models › Sampling
Reading section 7 of 13 · Sampling · 4 minSection 7 of 13 · 4 min

Section 7 of 13 · 4 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

Start each position at mm. At step kk, evaluate the denoiser on the current state, then draw each reveal decision with probability 1/k1/k for the linear schedule. For each selected position draw a clean token from its predicted categorical distribution. Copy the other positions through unchanged.

Schedules and the quality/latency dial

Changing TT changes both the number of model calls and the distribution of reveal groups. At T=LT=L, independent reveal decisions still allow some steps to reveal several tokens and others to reveal none. Alternatively, a decoder can explicitly reveal one position per call and require exactly LL calls. In that case every next draw conditions on the previously revealed tokens.

Heuristic sampling: where theory stops

Some decoders replace random Bernoulli selection with a fixed count such as ⌈n/k⌉\lceil n/k\rceil, where nn is the number of remaining masks. They can choose those positions at random or rank candidate tokens by the denoiser's confidence. LLaDA describes a confidence heuristic in which the lowest-confidence predictions at still-masked positions are kept masked. Tokens committed at earlier steps stay visible. A different revision algorithm may explicitly mask previous commitments again. Both selecting by confidence and revising positions change the sampler, so the likelihood bound from the derived random-reveal model does not automatically describe their output distributions.

Self-conditioning

A denoiser may also receive its own earlier clean estimate as input. This is called self-conditioning. It changes what the prediction depends on, beyond the current partial string and the time. To implement it, provide the same kind of signal during training that later steps will have at generation time. Training and inference implementations can have different costs if inference reuses an estimate that it has already computed.

Compute, latency, and the missing cache

Count only generated positions and hold the model width and prompt length fixed. Cached autoregressive decoding adds one new position per generation step. Naive full-sequence denoising recomputes all LL positions at each of its TT steps. The total counts are O(L)O(L) and O(TL)O(TL) respectively, before accounting for attention. With dense attention over LL positions, total attention work across the TT denoising rounds scales as O(TL2)O(TL^2) for fixed width.

The ratio below counts evaluated positions relative to the cached autoregressive baseline. Attention operations and elapsed time require separate accounting.

PythonIn [10]
CollapseExpand
import numpy as np

step_budgets = np.array([4, 8, 16, 32, 64])
relative_work = step_budgets.astype(float)
budget_labels = [str(int(t)) for t in step_budgets]
budget_xpos = np.arange(len(step_budgets))
VisualizationOut [11]
CollapseExpand
Bars show the ratio of generated-position evaluations for full-sequence denoising relative to cached autoregressive decoding.
At the same generated length, T full-sequence denoising rounds evaluate T times as many generated positions as the one-visit-per-position cached autoregressive baseline. The ratio counts position evaluations.

The naive denoiser may need fewer sequential network calls when T<LT<L. Timing depends on the cost of each call, memory movement, batch size, precision, hardware and implementation. Position counts alone give no wall-clock prediction. In a fully bidirectional transformer, even a visibly unchanged position can have a new hidden representation after a mask elsewhere is filled, which prevents ordinary causal KV caching across rounds. Block diffusion defines a different attention structure, allowing completed blocks to be cached while denoising the next block.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy