Masked Diffusion Trades Training Efficiency for Parallel Text Generation
Stanford adjunct professors Afshine and Shervine Amidi argue that diffusion language models change how Transformers generate text: instead of predicting one token at a time, they repeatedly refine a partially masked sequence. In their lecture, they present the approach’s potential for parallel generation and revision alongside its costs: inference speed depends on the workload and number of refinement steps, while the training comparisons they cite show a compute-efficiency gap against autoregressive models.

Diffusion changes the unit of generation, not the Transformer
? afshine-amidi frames diffusion language models as an alternative to the familiar next-token paradigm. The proposal is not to replace Transformers; it is to change how a model generates a sequence. In an autoregressive model, the system predicts one token, adds it to the context, and predicts the next. In a diffusion model, it starts with a heavily corrupted sequence and repeatedly turns it into a less corrupted one.
That difference matters because autoregressive generation requires one inference pass per output token. If a response is long, generation takes many sequential steps. Afshine points to reasoning models as a case where this can be especially costly: the model may produce a long reasoning chain before it reaches its response.
The instructors identify two other limits of the autoregressive setup. Its causal attention sees the current token and what came before, not what comes after. That can be restrictive for tasks such as filling in a piece of code when relevant context lies on both sides of the gap. And an autoregressive model cannot revise a token it has already generated. If an early choice is wrong, it can only try to recover by generating later tokens that make the sequence more coherent.
Diffusion changes the generation schedule. Instead of spending one pass on each output token, the model spends a chosen number of passes—diffusion steps—refining the sequence as a whole. In principle, the number of passes is tied to the number of refinement steps rather than directly to the number of output tokens. That is a motivation to explore the approach, not a guarantee that it will be faster in every workload.
The intuition comes from image generation. A diffusion model can begin with noise and repeatedly remove some of it until a clean image emerges. The model acts on the image as a whole rather than generating its pixels one at a time. Afshine also offers a sculpture analogy: a rough block is the starting material, and the sculptor removes what does not belong. The desired form is reached by refining an imperfect starting point.
For text, the corresponding idea is coarse-to-fine composition. Someone preparing a speech might first settle on its sections, then work out what belongs in each section, and finally refine the wording. A text diffusion model is intended to follow a comparable pattern: begin with a corrupted or incomplete sequence, make broad predictions, and refine them over multiple steps.
That suggests an encoder-only Transformer. Because the input is a partly corrupted sequence, the model needs to consider tokens on both sides of a gap; causal, decoder-only attention would impose the left-to-right restriction the new approach is meant to avoid. Afshine notes that the Transformer building blocks remain relevant, while the generation paradigm changes.
The distinction from BERT is important. BERT also uses an encoder and predicts masked tokens, but its masked-language-model objective is a pretext for learning language representations. Here, generation itself is the goal. A diffusion model also uses a sequence of noise levels, moving from heavily masked toward fully revealed, rather than predicting a fixed fraction of masked tokens once. The lecture contrasts BERT’s familiar 15% masking rate with diffusion’s sampled noise level, which ranges from little or no corruption to full corruption.
Continuous diffusion exposes the mismatch between embeddings and tokens
Images can be represented as continuous values, so the conventional diffusion procedure has a natural space in which to add noise. Text is different: its basic units are discrete tokens from a vocabulary. One proposed bridge is to represent each token by its embedding, a vector of floating-point values, then concatenate the vectors into a matrix for the whole sequence. Diffusion can operate on that continuous matrix.
In the image formulation Afshine presents, a forward process, denoted by q, progressively corrupts a clean example. For images, each step adds Gaussian noise according to a defined schedule. A learned reverse process, p with parameters θ, attempts to turn a noisy input into a less noisy one. The model can be trained to estimate the noise that was added; Afshine describes the associated image loss as an L2 regression loss.
The same broad construction can be applied to text embeddings: add noise to the matrix of token embeddings, then learn a reverse process that recovers a clean sequence representation. But denoising an embedding matrix does not automatically produce valid text. A point in the continuous space may not correspond to any token. One possible decoding procedure is to find the nearest valid token embedding for each denoised vector and map it back to the vocabulary.
Afshine outlines three problems with this approach. First, token embeddings occupy a high-dimensional space—on the order of thousands of dimensions in his example—and many locations in that space do not correspond to meaningful tokens. Second, an L2 loss measures error in embedding space, while the actual end goal is to select discrete tokens. The metric therefore does not directly optimize the outcome that matters after rounding. Third, Gaussian noise has a clear visual interpretation when added to an image, but it is less clear that adding Gaussian noise to text embeddings produces an equally meaningful form of corruption.
Researchers have proposed ways to address some of these difficulties. Afshine names clamping as a method for mapping noised embeddings back to token embeddings during the denoising process. He also describes using an embedding for the whole sequence rather than treating each token embedding independently, on the grounds that individually plausible tokens may form an incoherent sequence. These are presented as mitigations, not as a resolution of all the difficulties. The instructors describe continuous text diffusion as an active area of research with unresolved challenges.
The mismatch motivates a more direct question: can the corruption process operate on discrete tokens themselves, rather than borrowing the continuous representation used for images?
Masking gives discrete diffusion an explicit noise state
Discrete diffusion defines corruption directly in token space. A transition matrix, Q at time t, specifies the probability that a token at one step becomes another token at the next. The matrix has one row and one column for every vocabulary entry. A categorical distribution expresses probabilities over those discrete possibilities.
The lecture considers several ways to represent noise, including substituting a random vocabulary token. The formulation it develops uses a special [MASK] token. At each step, an ordinary token is either left unchanged or replaced by [MASK]. The probability of corruption at step t is written β_t; the probability of remaining unchanged is 1 − β_t.
Masking is an absorbing-state process. Once a token becomes [MASK], it stays masked at later steps. It cannot revert to its original token during the forward corruption process. This gives the process a simple structure: as noise increases, the sequence accumulates masked positions until, at the final step, the whole sequence can be masked.
The lecture also introduces α_t, the probability that an original token remains unmasked through time t. Since a token must survive each of the intermediate steps, α_t is the product of the probabilities of staying unmasked at those steps:
Equivalently, for an original token x₀ⁱ, the probability that its value is still present at time t is α_t, and the probability it has been replaced by [MASK] is 1 − α_t.
Here, i indexes a position in the sequence; t indicates the noise level. The instructors note that papers may use different time conventions—some use steps from zero to a fixed T, while others rescale time to the interval from zero to one. The notation changes, but the underlying idea is to specify how much corruption has occurred.
The masking progression makes the absorbing-state rule concrete. In the “A teddy bear is reading” example, an initial corruption might mask “A”; a later state can preserve that mask and mask “bear” as well. Subsequent states accumulate masks until the sequence is fully corrupted. This is not a sequence of independent replacements that can undo one another: the forward process preserves every earlier mask.
That monotonicity simplifies the reverse problem. If a token is visible at time t, it must also have been visible at the preceding step. If it is masked, its earlier state is uncertain: it may already have been masked, or it may still have been the original token. Those are the only two possibilities the later derivation needs to consider.
This forward process is straightforward to sample. Given a clean sequence, choose a noise level and mask tokens according to the schedule. Training will use these corrupted sequences to teach the model to recover the clean tokens.
A tractable training objective comes from bounding likelihood
The training goal is to learn a reverse process that generates clean sequences from noise. In the broadest formulation, the model should assign high probability to the training data: maximize pθ(x₀), or, for the usual log-likelihood objective, log pθ(x₀).
In autoregressive modeling, the sequence probability can be factored with the chain rule across token positions: each token is predicted given the preceding tokens. That factorization leads to the familiar next-token objective. Diffusion is deliberately not doing next-token prediction, so the same factorization does not provide its training loss.
Instead, the derivation factors across noise levels. The model’s reverse process moves from a noisier sequence toward a less noisy one. In principle, the probability of the clean sequence can be written by summing over possible intermediate corrupted sequences—or trajectories—between the clean data and full noise. But the number of possible trajectories is too large for direct computation.
Shervine Amidi presents a standard way to handle the intractability: find a tractable lower bound on the log-likelihood and maximize that. The forward process q supplies samples of corrupted trajectories, and Jensen’s inequality gives a lower bound called the evidence lower bound, or ELBO. The derivation’s purpose is to replace a sum over all possible trajectories with an expression that can be evaluated using the known corruption process and the learned reverse process.
If you compute something that you know for sure is smaller than what you care about, if you maximize that lower bound, then your hope is that what you care about will be maximized.
Expanding the ELBO for the masked process yields a sum of KL divergences between the known forward transitions and the reverse transitions the model is learning. A KL divergence measures the difference between two probability distributions; it is nonnegative and is zero when the distributions match.
Masking makes the relevant forward posterior computable. Consider a position i at step t, with the clean token x₀ⁱ known. If the token at step t is not masked, it must also have been unmasked at step t − 1: a token cannot leave the absorbing [MASK] state. If the token is masked at step t, then at step t − 1 it could either already have been masked or still have been the original clean token.
The probability of the latter case, conditional on being masked at t, is written:
The remaining probability, 1 − r_t, corresponds to the token having already been masked at t − 1. Thus the forward posterior over the previous token state has only two possibilities when the current token is masked: [MASK], or the original token x₀ⁱ.
The learned reverse process uses the model’s estimate of the clean token, written πθ(x₀ⁱ | x_t,t). In the formulation shown, when the current token is masked, the reverse process assigns probability 1 − r_t to keeping it masked, and distributes the remaining probability r_t over clean-token predictions according to πθ. When the current token is not masked, the previous state is determined by the absorbing-state rule.
Once these terms can be computed, the KL-based lower bound can be reduced to a loss on the masked positions. Under the lecture’s stated rescaling, time t ranges from zero to one and α_t = 1 − t. This is a linear noise schedule: at time t, the probability of masking a token is t. The resulting displayed loss is:
The 1/t weighting belongs to this particular rescaling and schedule, not to every possible discrete-diffusion formulation. The expectation samples a clean training sequence, a noise level, and a corrupted version under the defined forward process. The sum scores only positions that were masked in that corrupted version, using the model’s probability for the original token.
The practical interpretation is simpler than the derivation: give the model a corrupted sequence and a noise level, ask it to predict the clean tokens hidden by the corruption, and train those predictions against the originals.
Training samples corruption; inference gradually reveals the response
Training begins by sampling a noise level t between zero and one. The sequence is corrupted so that each token has probability t of being masked. A diffusion model receives that partially masked sequence and the noise level, predicts the masked tokens, and computes the loss on those predictions. The loss is backpropagated through the model, and the process is repeated.
Noise level is sampled across the interval, so the model sees sequences with different amounts of corruption. At low noise, most tokens remain visible; at high noise, little of the original sequence is available. The model is trained to predict the original values at the positions masked in each sampled example.
Inference reverses the direction of the training corruption. The model begins with a fully masked response, at 100% noise, and repeatedly predicts tokens for the masked positions. It does not necessarily commit every predicted token immediately. The reverse transition described earlier allows some predictions to remain masked while others become visible. The sequence therefore becomes progressively less noisy.
The example illustrates the process with a response of fixed length. A first pass might predict “A brown bear is sleeping,” but the reverse step commits only some of the positions and remasks others. A later pass uses the now partly revealed sequence as context to predict again. The process continues through lower noise levels until all positions have been revealed. In the final state, the remaining masks are filled and the response is complete.
The prompt is treated differently from the response. In the user-facing setting Afshine describes, the prompt remains fixed and is not masked; it anchors the generation. The response tokens are generated with bidirectional access to the prompt and to other positions in the response. This preserves the prompt as context while allowing the model to use information on both sides of a response position.
The procedure’s parallelism does not mean that the output is settled after one pass. The model may keep some positions masked, update others, and run again on the revised sequence. The number of passes is therefore a central design choice: more steps provide more opportunities to refine the sequence, while each step requires another model pass.
Parallel predictions create a coordination problem
Because a diffusion model predicts multiple masked positions in parallel, its choices can conflict. Shervine illustrates this with “The teddy [MASK] [MASK] reading.” The two gaps might be filled with “bear is” or “bears are.” But if the positions are sampled independently from their current contexts, the model could produce “The teddy bears is reading.” Each prediction may have appeared plausible without the other newly sampled token in context, even though the pair is inconsistent.
One response is remasking: allow the model to revisit tokens it has already committed. A token can be hidden again, then predicted in the context of the other revealed tokens. In the favorable example, remasking “bears” gives the model a chance to select “bear” when it sees the surrounding “is.” This creates a route for self-correction that an irrevocably left-to-right sequence does not have.
But random remasking can make a good sequence worse. The model might remask a token that was already correct and replace it with a worse choice. A natural refinement is to target tokens by confidence: remask those the model considers least likely. That approach has a complication. Confidence scores recorded when a token was first generated may have been calculated in a different context. A token can have looked likely before its neighboring positions were filled, yet become implausible once the sequence changes.
The example distinguishes those cases. “Bears” and “is” may each have had high probability when predicted against the same incomplete context, because the other position was still masked. Their combined result is grammatically inconsistent. A confidence score from that earlier point might therefore fail to identify either token for revision. The context has changed; the model needs to assess the candidate tokens against the sequence as it now stands.
The lecture describes a second approach: assess token likelihood under the current context, then target the least likely positions. In the “bears is” example, the current sequence can reveal that both “bears” and “is” now have low probability in context, making them candidates for remasking. The instructors say some papers explore training a classifier to identify tokens that should be revisited. They do not present remasking as a settled remedy; the examples show both its potential and its failure modes.
The benefit of parallel prediction therefore comes with a coordination problem. A model can fill multiple gaps in one pass, but those choices may not be mutually compatible. Iterative refinement and targeted revision are ways to address that problem, at the cost of additional computation.
Per-pass speed depends on prompt and response length
A diffusion model’s parallel predictions do not automatically make it faster than an autoregressive model. Afshine’s comparison is conditional: it considers a large prompt and a small response. In an autoregressive system, decoding time includes a prompt-prefill phase plus generation passes proportional to output length. The prefill computes prompt representations, including the keys and values used during generation. Once those are cached, each subsequent pass processes only one new token.
A diffusion system, in the comparison shown, starts with the prompt and a noisy response and uses a fixed number of passes to produce the response. It does not have the same separate prefill stage, but each pass processes a sequence with bidirectional attention. Afshine treats the cost of that pass as roughly comparable in order of magnitude to the autoregressive prompt-prefill computation, while noting that architecture and attention differences can affect the comparison.
This comparison has two terms: the number of passes and the time per pass. In autoregression, the number of passes grows with the response length. In diffusion, the number is the chosen number of refinement steps. But a diffusion pass can involve processing all response positions, while an autoregressive pass after prefill processes a single new token and can reuse cached keys and values. For the large-prompt, small-response case in the lecture, autoregression can therefore be faster: it needs only a few generation passes, each relatively cheap after the prompt has been processed.
That result is not a general latency ranking. Total decoding time depends on both the number of passes and the work in each pass, as well as prompt size, response length, caching, and attention pattern. “Parallel” describes how positions are predicted; it does not, by itself, settle total latency.
Afshine then considers ways to improve diffusion inference. One is to reduce the cost of each pass by reusing prompt representations. Bidirectional attention means the prompt’s hidden representations can change as response tokens are revealed, so they cannot simply be treated as fixed without qualification. The work cited on the slide, dLLM-Cache: Accelerating Diffusion Large Language Models with Adaptive Caching (Liu et al., 2025), studies how much those representations change. The idea is to compute them once, or refresh them periodically, and reuse them between refreshes.
In the results displayed for that work, increasing the interval K_p between cache refreshes reduces computation while accuracy is described as roughly preserved. Afshine also notes that accuracy sometimes increases when the cache is not refreshed, and speculates that newly revealed tokens may introduce noise into prompt representations. The example makes the trade-off concrete: refreshing less often saves work, but the representations being reused are approximations to those the model would calculate with updated context.
Another way to change the work per pass is to relax full bidirectionality. Afshine describes Block Diffusion: Interpolating Between Autoregressive and Diffusion Language Models (Arriola et al., 2025), which divides positions into blocks. Attention is bidirectional within a block, while completed blocks can be treated as fixed context for later ones and accessed causally. The scheme is presented as globally autoregressive but locally bidirectional.
The motivating contrast in the displayed comparison is that standard autoregression supports arbitrary-length generation and key-value caching but is sequential, while full diffusion is parallelizable but, in the comparison shown, uses fixed-length generation and lacks the same cache. Block diffusion is offered as a way to combine some of these properties: parallel generation within blocks, caching across completed blocks, and generation in an autoregressive order between blocks. The block structure is presented as a way to balance parallelism and reuse, not as a claim that all trade-offs disappear.
The other major factor is the number of passes. Afshine describes distillation as one way to reduce it. A teacher model can take several small denoising steps, while a student is trained to match the teacher’s end distribution in fewer steps. In the example, the teacher moves from “[MASK] [MASK]” to “teddy [MASK]” and then to “teddy bear,” while the student learns to make the larger jump directly.
The intermediate teacher predictions provide information for training the student, including a richer context for later token predictions. The lecture describes comparing the student’s token distributions with the teacher’s, using the teacher’s intermediate predictions to inform what the student should produce in fewer steps. The work cited on the slide, Beyond Autoregression: Fast LLMs via Self-Distillation Through Time (Deschenaux et al., 2024), is described as progressively reducing the number of steps: a student can first learn to replace a pair of teacher steps, then be trained again to make a larger jump. Afshine gives about ten steps as an order of magnitude reached in that work.
These techniques address different terms in inference time. Caching and block structure aim to reduce the cost of a pass; distillation aims to reduce the number of passes. The reported results and speed comparisons are tied to the particular studies, methods, and settings shown.
The training signal helps explain the quality gap
The instructors contrast diffusion training with autoregressive teacher forcing. In autoregressive training, the model receives the ground-truth sequence as input and is trained against targets at every position. Each prediction is conditioned on a ground-truth context. The sequence’s token predictions can be processed in parallel across the batch even though inference generation is sequential.
In masked diffusion training, a sampled corruption may leave only a subset of positions as targets in a given pass. The model spends computation on the whole sequence but directly receives a loss signal only for the masked tokens it is asked to predict. Moreover, those targets attend to representations that may themselves correspond to masked, unresolved positions. Shervine characterizes this as a weaker signal than the autoregressive case.
The contrast is not simply about the number of labels. In the autoregressive setup, each target is paired with a context made up of ground-truth tokens. In the diffusion setup, the context is a sampled mixture of revealed tokens and masks. A prediction may therefore depend on representations that have not yet been resolved. The lecture presents these two features—fewer directly supervised positions per pass and unresolved context—as reasons diffusion requires more compute to reach similar loss in the cited comparisons.
In the comparisons shown, autoregressive models produce higher-quality results under an equivalent compute budget. A chart attributed on the slide to Scaling up Masked Diffusion Models on Text (Nie et al., 2024) reports a 16-fold compute gap between masked diffusion models and autoregressive models at comparable validation loss:
The instructors qualify that comparison: the objectives are not directly comparable, since the diffusion result is based on an ELBO while the autoregressive result uses cross-entropy. The chart therefore does not put identical training objectives on both sides.
They then discuss a later analysis, shown as Revisiting the 16x Pretraining Compute Gap between Diffusion and Autoregressive Language Models (Wang et al., 2026), that attempts to compare the objectives more directly by following the diffusion model’s commit order and injecting ground truth at the appropriate steps. The procedure is described as recovering a single trajectory for comparison: ground-truth information is supplied at the relevant points, and the resulting predictions can be fitted against that trajectory.
The chart gives several compute multiples from that analysis. It reports 17.8× for MDM ELBO, 12.8× for MDM DUEL, and 9.6×, 7.8×, 6.3×, and 3.0× for the listed block or design variants. The displayed labels associate those variants with different model designs and block sizes, including E2D2 at block sizes 32, 16, 8, and 4. Shervine characterizes the result as typically around ten times less compute-efficient in the comparison, rather than necessarily sixteen times, and says the revised analysis is “not far” from the earlier result. These figures belong to the specific methods and comparisons displayed, not to every diffusion model or training setup.
The gap creates a tension in the case for diffusion. Its parallel generation can improve response speed for a user, but the training signal described here is less efficient, and quality can lag under a fixed training-compute budget. Whether the inference advantage justifies the training cost depends on the application and on the models and comparison method involved.
The proposed compromise is fast drafting with autoregressive verification
The instructors frame a possible synthesis around the strengths they have contrasted: diffusion models can generate multiple tokens in parallel, while autoregressive models are described as higher quality. The proposed pattern resembles speculative decoding. In ordinary speculative decoding, a fast draft model proposes tokens and a stronger autoregressive target model checks them. If the target accepts the proposals, the system advances more quickly than it would by generating each token with the target alone.
The limitation is that a conventional draft model is still autoregressive, so drafting remains sequential. The lecture describes a variant in which a diffusion model drafts several tokens in parallel, then an autoregressive model verifies them. Afshine says speedups are seen in practice and shows results attributed on the slide to DFlash: Block Diffusion for Flash Speculative Decoding (Chen et al., 2026). In the displayed table, average speedup is reported as 4.91× at temperature zero and 4.24× at temperature 0.6, with task-specific figures that vary. Those values are tied to the model and settings shown.
The discussion also distinguishes user-level latency from throughput across batches. The lecture notes that diffusion may offer much faster generation for an individual user, while reducing the ability to parallelize across batches. The advantage is not captured by a single tokens-per-second number for every deployment setting.
Diffusion may also suit coding tasks in which the model must fill a gap using context on both sides—a fill-in-the-middle setup—and where quick feedback loops matter. This connects the architectural advantage of bidirectional context with an application in which the needed continuation may be constrained by code already present after the gap.
The remaining challenges are substantial in the account given. Training is more expensive under the comparisons shown. Work is needed to adapt useful autoregressive techniques, including post-training approaches, to diffusion. The direction proposed is to combine their advantages rather than assume that either generation paradigm is unconditionally superior.


