Skip to content
AIAI Wranglers

22 Diffusion Language Models

Introduction and Motivation

Language generation has been dominated by autoregressive (AR) models. From early recurrent neural networks to modern Transformers such as GPT [12], LLaMA [13], and their successors, the dominant paradigm is simple: generate text one token at a time, left to right, by factoring the joint probability as (AR Factorization)pΞΈ(𝒙)=pΞΈ(x1)∏i=2LpΞΈ(xi|x1,…,xiβˆ’1), where 𝒙=(x1,x2,…,xL) is a sequence of tokens from a vocabulary 𝒱 of size K. This factorization is exact by the chain rule of probability; no approximation is needed. Training is straightforward via teacher forcing, and generation proceeds token by token.

Yet this very simplicity conceals fundamental limitations. Consider the following:

  • Sequential bottleneck. Generating L tokens requires L serial forward passes through the network. Each pass is memory-bandwidth bound on modern GPUs, leading to poor hardware utilization. Even with a peak of order 1015 FLOP/s available, the GPU sits mostly idle waiting for memory.

  • Left-to-right commitment. Once a token is generated, it cannot be revised. The model must commit to each word before seeing the rest of the sentence. Humans do not write this way; we draft, revise, and refine.

  • The reversal curse. Autoregressive models trained on β€œA is B” struggle to answer β€œWhat is B?” with β€œA”, because the left-to-right factorization never conditions on the latter part of a sequence to predict the former [1].

  • No native infilling. Filling in a blank in the middle of a sentence requires special training modifications (fill-in-the-middle) that are not part of the natural AR framework.

Meanwhile, in the domain of images, diffusion models have achieved spectacular success. Models like DDPM [14], Stable Diffusion [15], and DALL-E [16] generate images by iteratively denoising from pure noise, producing all pixels simultaneously rather than one at a time. The quality of generated images has surpassed that of GANs in many settings. This raises a natural question:

[colback=defbluebg, colframe=defblue, boxrule=0.8pt] Central Question: Can we build diffusion models for language that rival or surpass autoregressive LLMs, while gaining the benefits of parallel generation, bidirectional context, and iterative refinement?

This chapter tells the story of how this question has been progressively answered. We begin by reviewing the key background: diffusion models for images, and the classical masked autoregressive models that foreshadow many ideas in diffusion language models. We then identify the fundamental challenge (language is discrete, not continuous) and show how this challenge has been addressed through discrete diffusion processes, culminating in the modern masked diffusion language models (MDLMs). We trace the development from D3PM [17] through MDLM [18] and SEDD [19] to the large-scale LLaDA [5], LLaDA 2.0 [20], and Mercury [8] models. Along the way, we present detailed mathematical derivations, TikZ diagrams of the key processes, and discussions of the practical advantages and challenges.

Comparison of autoregressive (AR) and diffusion generation. AR generates tokens sequentially, left to right. Diffusion starts from a fully masked sequence and progressively unmasks tokens in parallel, allowing bidirectional context at every step.

Background: Autoregressive and Masked Models

Before diving into diffusion, it is instructive to review the classical masked and autoregressive generative models for sequences. These models share deep connections with diffusion language models, and understanding them provides essential intuition.

Autoregressive Models: NADE, MADE, PixelRNN, PixelCNN

The autoregressive factorization is the backbone of many generative models. The key design choice is how to parameterize each conditional pΞΈ(xi|x<i).

NADE (Neural Autoregressive Density Estimation).

NADE [21] models each conditional using a single-hidden-layer neural network that shares parameters across positions. For a D-dimensional binary vector 𝒙: p(𝒙)=∏d=1Dp(xd|𝒙<d),𝒉d=Οƒ(𝒄+𝐖:,<d𝒙<d),p(xd=1|𝒙<d)=Οƒ(𝒃d+𝐕d,:𝒉d), where Οƒ is the sigmoid function, 𝐖 and 𝐕 are weight matrices, and 𝒄 and 𝒃 are bias vectors. The crucial feature is that the hidden activation 𝒉d depends only on the preceding variables 𝒙<d, enforcing the autoregressive property.

Remark 1.

NADE requires D forward passes to compute the full density p(𝒙) and to generate all dimensions, since each conditional depends on the previous outputs. This sequential nature is the same bottleneck that plagues all autoregressive models.

MADE (Masked Autoencoder for Distribution Estimation).

MADE [22] achieves the autoregressive property in a single forward pass by applying carefully designed binary masks to the weight matrices of a standard autoencoder. Each input unit is assigned its own index, m(xd)=d∈{1,…,D}, and each hidden unit is assigned a number m(k)∈{1,…,Dβˆ’1} indicating which input dimensions it is allowed to depend on. The mask for a weight connecting unit k in layer β„“ to unit kβ€² in layer β„“+1 is: 𝐌kβ€²,kβ„“=𝟏[mβ„“+1(kβ€²)β‰₯mβ„“(k)]. The output mask ensures p(xd|β‹…) depends only on 𝒙<d: 𝐌d,kout=𝟏[d>mL(k)].

MADE architecture with masking. Solid arrows indicate active connections; dashed gray arrows indicate masked (zeroed) connections. The number inside each hidden unit indicates its assigned ordering number m(k). Output x^d depends only on inputs x1,…,xdβˆ’1.

Remark 2.

The key insight of MADE is that masking can enforce autoregressive structure within a single forward pass. This is conceptually important for diffusion language models, where masking plays a central but different role: rather than enforcing ordering constraints, it defines the corruption (forward) process.

PixelRNN and PixelCNN.

For image generation, PixelRNN [23] applies the autoregressive factorization to pixels, scanning the image in raster order (top to bottom, left to right): p(𝒙)=∏i=1N2p(xi|x1,…,xiβˆ’1), where each pixel xi takes values in {0,1,…,255} (modeled via a softmax over 256 categories). PixelRNN uses LSTM layers to capture long-range dependencies along the raster scan. PixelCNN [24] replaces the recurrence with masked convolutions, convolutional filters that are zeroed out for β€œfuture” pixels, ensuring the autoregressive property.

PixelCNN masked convolution. The raster-scan ordering defines which pixels are β€œknown” (blue) when predicting the current pixel (red). The convolution filter is masked so that future pixels (white/gray) have zero weight.

Order-Agnostic Autoregressive Models and XLNet

An important precursor to diffusion language models is the order-agnostic autoregressive model. XLNet [11] proposed training an autoregressive model over all possible permutations of the input sequence: β„’XLNet=π”ΌΟ€βˆΌUniform(SL)[βˆ’βˆ‘i=1Llog⁑pΞΈ(xΟ€(i)|xΟ€(1),…,xΟ€(iβˆ’1))], where SL is the set of all permutations of {1,…,L}. At each training step, a random permutation is sampled, and the model learns to predict each token given the preceding tokens in that permutation order.

This is significant because:

  • Unlike BERT, XLNet is a proper generative model: it can assign exact likelihoods to sequences.

  • Unlike standard AR models, it sees bidirectional context during training (through permuted orders).

  • The expected loss over all permutations gives equal weight to every possible conditioning pattern.

Remark 3.

We will see in Section Theoretical Results that absorbing discrete diffusion implicitly averages over all factorization orders, making it equivalent to XLNet's objective in the continuous-time limit. However, diffusion models achieve this through the elegant mechanism of masking and unmasking, without explicitly enumerating permutations. This connection was formally established by Ou et al. [2].

Relationship between autoregressive, order-agnostic, masked, and diffusion models. Standard AR uses one factorization order. XLNet averages over all orders. BERT predicts masks without ordering. Masked diffusion combines all three: it implicitly averages over all orders (like XLNet), uses masked prediction (like BERT), and provides principled generation through the reverse process.

The following table summarizes the key properties of these model families:

PropertyARNADE/MADEBERTDiffusion
Generative modelYesYesNoYes
Exact likelihoodYesYesNoVia ELBO
Bidirectional contextNoVia ensemblesYesYes
Parallel generationNoNoN/AYes
All factorization ordersNoVia orderingsN/AYes (implicit)
Iterative refinementNoNoN/AYes

Masked Language Modeling (BERT)

A different approach to modeling sequences, which will prove central to diffusion language models, is masked language modeling (MLM), introduced by BERT [3]. Rather than factoring the distribution autoregressively, BERT randomly masks a fraction of tokens (typically 15%) and trains a bidirectional Transformer to predict the masked tokens from the unmasked context: β„’MLM=βˆ’π”Όπ’™βˆΌpdata𝔼mask[βˆ‘i∈maskedlog⁑pΞΈ(xi|𝒙unmasked)].

BERT was originally designed as a representation learner, not a generative model. However, the connection between masking and diffusion turns out to be profound. As we will show in Section Masked Diffusion Language Models (MDLM), the training objective of masked diffusion language models is precisely a weighted average of MLM losses at different masking rates. BERT's MLM can be viewed as training a diffusion model at a single, fixed noise level.

Remark 4.

The connection between BERT and diffusion provides a surprising bridge: encoder-only models (BERT-style), traditionally used for understanding tasks, can be turned into principled generative models by simply modifying the training loss to weight different masking rates appropriately.

Recap: Diffusion Models for Images

We briefly recap the continuous diffusion framework for images, which forms the foundation for understanding the discrete extensions needed for language. This material is covered in detail in earlier chapters; here we highlight the aspects most relevant to the discrete setting.

Forward Process (Adding Noise)

Given a data point 𝒙0∼pdata, the forward process adds Gaussian noise over T steps: q(𝒙t|𝒙tβˆ’1)=𝒩(𝒙t;1βˆ’Ξ²t𝒙tβˆ’1,Ξ²t𝐈), where Ξ²1,…,Ξ²T is a noise schedule. Defining Ξ±t=1βˆ’Ξ²t and Ξ±β€Ύt=∏s=1tΞ±s, the marginal at any time t is available in closed form: (Continuous Forward Marginal)q(𝒙t|𝒙0)=𝒩(𝒙t;Ξ±β€Ύt𝒙0,(1βˆ’Ξ±β€Ύt)𝐈). As tβ†’T with appropriate scheduling, Ξ±β€ΎTβ‰ˆ0 and 𝒙Tβ‰ˆπ’©(𝟎,𝐈).

Reverse Process (Denoising)

The reverse process generates data by denoising: pΞΈ(𝒙tβˆ’1|𝒙t)=𝒩(𝒙tβˆ’1;𝝁θ(𝒙t,t),Οƒt2𝐈). The true reverse posterior, conditioned on 𝒙0, is also Gaussian: q(𝒙tβˆ’1|𝒙t,𝒙0)=𝒩(𝒙tβˆ’1;𝝁~t(𝒙t,𝒙0),Ξ²~t𝐈), where 𝝁~t and Ξ²~t are known functions of 𝒙t, 𝒙0, and the noise schedule.

Training Objective

The ELBO decomposes into a sum of KL divergences: log⁑p(𝒙0)β‰₯𝔼q[log⁑pΞΈ(𝒙0|𝒙1)βˆ’βˆ‘t=2TDKL(q(𝒙tβˆ’1|𝒙t,𝒙0)β€–pΞΈ(𝒙tβˆ’1|𝒙t))βˆ’DKL(q(𝒙T|𝒙0)β€–p(𝒙T))]. With the 𝒙0-prediction parameterization, this simplifies to a reweighted MSE loss. For the Ο΅-prediction parameterization (DDPM), the loss becomes: β„’simple=𝔼t,𝒙0,𝝐[β€–πβˆ’πΞΈ(𝒙t,t)β€–2].

Continuous diffusion for images. The forward process gradually adds Gaussian noise. The reverse process learns to denoise, generating images from pure noise.

Why Continuous Diffusion Does Not Directly Work for Language

Language tokens live in a discrete space 𝒱={1,2,…,K}. Adding Gaussian noise to a one-hot vector produces a continuous vector that no longer corresponds to any valid token. Several attempts have been made to apply continuous diffusion to text by embedding tokens into a continuous space [25][26], but these approaches face fundamental difficulties:

  1. Embedding-space mismatch. Rounding a continuous diffusion output back to the nearest token embedding introduces errors that accumulate during sampling.

  2. No natural metric. Unlike pixel values where nearby values are similar (pixel 128 is close to 129), tokens have no natural ordering or distance metric. The word β€œcat” is not β€œclose to” β€œbat” in any meaningful geometric sense that Gaussian noise respects.

  3. High dimensionality. Modern vocabularies have K=32,000 to 150,000 tokens. Operating in this high-dimensional discrete space via continuous relaxations is wasteful.

Remark 5.

This difficulty motivates the development of discrete diffusion models, diffusion processes that operate directly on categorical variables, replacing Gaussian noise with structured corruption processes such as uniform noise or masking.

Discrete Diffusion: The D3PM Framework

The first principled framework for diffusion in discrete spaces was D3PM (Structured Denoising Diffusion Models in Discrete State-Spaces) [17]. D3PM generalizes DDPM to categorical data by replacing Gaussian transitions with categorical transitions defined by stochastic matrices.

Setup

Consider a single token x0∈{1,2,…,K}, represented as a one-hot vector in ℝK⁑. The forward process is a Markov chain defined by transition matrices 𝐐tβˆˆβ„KΓ—K⁑, where entry [𝐐t]ij=q(xt=j|xtβˆ’1=i).

Definition 1 (D3PM Forward Process).

The forward process corrupts data via: q(xt|xtβˆ’1)=Categorical⁑(xt;xtβˆ’1𝐐t), where xtβˆ’1 is treated as a row vector and 𝐐t is a row-stochastic matrix (rows sum to 1).

The marginal at time t given the initial data x0 is computed via the cumulative product: (D3PM Marginal)q(xt|x0)=Categorical⁑(xt;x0𝐐‾t),where𝐐‾t=𝐐1𝐐2⋯𝐐t.

This is the discrete analogue of the Gaussian marginal . Just as Ξ±β€Ύt controls how much of the original signal remains in continuous diffusion, 𝐐‾t controls how much of the original token identity is preserved.

Types of Transition Matrices

D3PM considers three types of transition matrices, each inducing a different corruption process:

1. Uniform Diffusion.

𝐐tunif=(1βˆ’Ξ²t)𝐈+Ξ²tKπŸ™β‘πŸ™βŠ€β‘, where πŸ™β‘ is the all-ones vector. With probability 1βˆ’Ξ²t the token is kept, and with probability Ξ²t it is resampled uniformly from all K states. Reading this off the matrix, the token is retained with total probability 1βˆ’Ξ²t+Ξ²t/K and moves to each other state with probability Ξ²t/K, so every row sums to 1βˆ’Ξ²t+Kβ‹…Ξ²t/K=1. The stationary distribution is uniform over all tokens.

2. Absorbing State Diffusion.

(Absorbing Transition)[𝐐tabs]ij={1βˆ’Ξ²tifΒ i=jΒ andΒ iβ‰ [ᴍᴀsα΄‹]Ξ²tifΒ j=[ᴍᴀsα΄‹]Β andΒ iβ‰ [ᴍᴀsα΄‹]1ifΒ i=j=[ᴍᴀsα΄‹]0otherwise Tokens either stay the same or transition to a special absorbing state [ᴍᴀsα΄‹]. Once masked, a token remains masked. The stationary distribution is a point mass on [ᴍᴀsα΄‹].

3. Discretized Gaussian Diffusion.

[𝐐tgauss]ij∝exp⁑(βˆ’c|iβˆ’j|2), for some constant c. This imposes ordinal structure: nearby states are more likely transitions. This is suitable for data with natural ordering, such as discretized pixel values.

Two types of discrete transition processes, drawn for K=3. Left: Uniform diffusion: with probability 1βˆ’Ξ² the token is kept and with probability Ξ² it is resampled uniformly, so it stays put with total probability 1βˆ’Ξ²+Ξ²/3 and moves to each other state with probability Ξ²/3; every row sums to 1, and the stationary distribution, not the one-step kernel, is the uniform one. Right: Absorbing state diffusion: tokens either stay or transition to a special [ᴍᴀsα΄‹] state, which is absorbing (once masked, always masked). The absorbing process is most relevant for language diffusion models.

Reverse Posterior

Using Bayes' theorem, the true reverse posterior (conditioned on knowing x0) is: (D3PM Reverse Posterior)q(xtβˆ’1|xt,x0)=q(xt|xtβˆ’1)q(xtβˆ’1|x0)q(xt|x0). In categorical/matrix form: (D3PM Reverse Categorical)q(xtβˆ’1|xt,x0)=Categorical⁑(xtβˆ’1;xt𝐐tβŠ€βŠ™x0𝐐‾tβˆ’1βˆ‘j[xt𝐐tβŠ€βŠ™x0𝐐‾tβˆ’1]j), where βŠ™ denotes the elementwise (Hadamard) product. This is the discrete analogue of the Gaussian posterior in continuous DDPM.

x0-Parameterization and Training

The model learns pΞΈ(xtβˆ’1|xt) using the x0-parameterization: a neural network predicts a distribution over clean data p~ΞΈ(x0|xt), and then the reverse transition is computed by plugging this prediction into the Bayes posterior: (D3PM X0 Param)pΞΈ(xtβˆ’1|xt)=βˆ‘x^0q(xtβˆ’1|xt,x^0)p~ΞΈ(x^0|xt).

The training objective is the variational bound (VB) on the negative log-likelihood. Every term below is non-negative, so β„’VBβ‰₯βˆ’log⁑pΞΈ(x0): it is the negated ELBO, and it is minimised. (D3PM VLB)β„’VB=𝔼x0[DKL(q(xT|x0)β€–p(xT))βŸβ„’T+βˆ‘t=2T𝔼q(xt|x0)[DKL(q(xtβˆ’1|xt,x0)β€–pΞΈ(xtβˆ’1|xt))]βŸβ„’t+(βˆ’π”Όq(x1|x0)[log⁑pΞΈ(x0|x1)])βŸβ„’0].

Since all distributions are categorical, the KL divergences have closed-form expressions: DKL(Categorical⁑(𝒑)β€–Categorical⁑(𝒒))=βˆ‘k=1Kpklog⁑pkqk.

Remark 6.

Austin et al. found that training with the variational bound alone can be unstable. They propose an auxiliary cross-entropy loss: β„’aux=λ𝔼q(x0,xt)[βˆ’log⁑p~ΞΈ(x0|xt)], which directly encourages the network to predict x0 accurately from any noisy xt. The total loss is β„’=β„’VB+β„’aux.

Algorithm 1: D3PM Training.

[t]

  1. repeat
  2. Sample x0∼pdata
  3. Sample t∼Uniform({1,…,T})
  4. Sample xt∼q(xt|x0)=Categorical⁑(xt;x0𝐐‾t)
  5. Compute p~ΞΈ(x0|xt) via neural network
  6. Compute pΞΈ(xtβˆ’1|xt) via x0-parameterization
  7. Compute β„’t=DKL(q(xtβˆ’1|xt,x0)β€–pΞΈ(xtβˆ’1|xt))
  8. Update ΞΈ via gradient descent on β„’t+Ξ»β„’aux
  9. until converged

Masked Diffusion Language Models (MDLM)

While D3PM provides a general framework for discrete diffusion, it was MDLM (Simple and Effective Masked Diffusion Language Models) [18] that demonstrated that a careful specialization to the absorbing state (masking) process, combined with a simplified training objective, could dramatically close the gap with autoregressive models. MDLM was published at NeurIPS 2024 and represents a key turning point for the field.

Forward Process: Masking

MDLM focuses exclusively on absorbing-state diffusion. For a sequence 𝒙0=(x01,…,x0L), each token is independently either kept or masked: (MDLM Forward)q(zti|x0i)=Categorical⁑(zti;Ξ±tx0i+(1βˆ’Ξ±t)π’Ž), where π’Ž is the one-hot vector for the [ᴍᴀsα΄‹] token, Ξ±t∈[0,1] is a decreasing noise schedule with Ξ±0=1 (no masking) and Ξ±1=0 (fully masked), and t∈[0,1] is continuous time.

In words: at time t, each token independently survives with probability Ξ±t or is masked with probability 1βˆ’Ξ±t.

The MDLM forward (masking) process. As time t increases from 0 to 1, tokens are independently replaced by [ᴍᴀsα΄‹] with increasing probability 1βˆ’Ξ±t. At t=0 the sequence is clean; at t=1 it is fully masked.

Simplified Reverse Posterior

For absorbing-state diffusion, the reverse posterior simplifies dramatically compared to the general D3PM case: (MDLM Reverse Posterior)q(zsi|zti,x0i)={Categorical⁑(zsi;zti)ifΒ ztiβ‰ [ᴍᴀsα΄‹]Categorical⁑(zsi;(1βˆ’Ξ±s)π’Ž+(Ξ±sβˆ’Ξ±t)x0i1βˆ’Ξ±t)ifΒ zti=[ᴍᴀsα΄‹] for 0≀s<t≀1.

Remark 7 (Key structural property).

If a token is not masked at time t, it deterministically stays the same at time s<t. Only masked tokens have non-trivial reverse transitions. This is the β€œcarry-over” property: once unmasked, always unmasked.

The SUBS Parameterization

The learned reverse process substitutes the neural network prediction 𝒙θ(𝒛t,t) for the true 𝒙0: pΞΈ(zsi|𝒛t)=q(zsi|zti,x0i=xΞΈi(𝒛t,t)). Two structural constraints are imposed on the network output:

  1. Zero masking probability: The network never predicts [ᴍᴀsα΄‹] as a clean token: ⟨xΞΈi(𝒛t,t),π’ŽβŸ©=0. In practice, the logit for [ᴍᴀsα΄‹] is set to βˆ’βˆž before the softmax.

  2. Carry-over unmasking: If ztiβ‰ [ᴍᴀsα΄‹], the output simply copies the input: zsi=zti.

Rao-Blackwellized Training Objective

The main contribution of MDLM is a dramatically simplified training objective obtained by analytically computing expectations (Rao-Blackwellization). Starting from the D3PM-style ELBO with complex KL divergences, the carry-over and zero-masking constraints allow the diffusion loss to simplify to:

Theorem 1 (MDLM Discrete-Time Loss).

The discrete-time Rao-Blackwellized diffusion loss is: (MDLM Discrete LOSS)β„’diffusion=βˆ‘i=1T𝔼q[Ξ±s(i)βˆ’Ξ±t(i)1βˆ’Ξ±t(i)βˆ‘β„“=1L(βˆ’log⁑⟨xΞΈβ„“(𝒛t(i),t(i)),x0β„“βŸ©)], where the inner product ⟨xΞΈβ„“(𝒛t,t),x0β„“βŸ© is the predicted probability of the true token at position β„“, and the weight Ξ±sβˆ’Ξ±t1βˆ’Ξ±t depends on the noise schedule. Since s<t and Ξ±t is decreasing, that weight is non-negative, and so is each βˆ’logβ‘βŸ¨β‹…,β‹…βŸ©: the whole expression is a non-negative quantity to be minimised.

This is simply a weighted cross-entropy loss evaluated only at masked positions. Compared to the D3PM parameterization, this has lower variance because expectations are computed analytically rather than estimated via sampling.

Continuous-Time Limit

Taking Tβ†’βˆž, the discrete sum becomes an integral:

Theorem 2 (MDLM Continuous-Time NELBO).

The continuous-time negative ELBO is: (MDLM Continuous LOSS)β„’NELBO∞=𝔼q∫01βˆ’Ξ±tβ€²1βˆ’Ξ±tβˆ‘β„“=1L(βˆ’log⁑⟨xΞΈβ„“(𝒛t,t),x0β„“βŸ©)dt, where Ξ±tβ€²=dΞ±t/dt is the derivative of the noise schedule. Because Ξ±t decreases, βˆ’Ξ±tβ€²>0 and the weight βˆ’Ξ±tβ€²1βˆ’Ξ±t is positive; for the linear schedule Ξ±t=1βˆ’t it is exactly 1/t.

Noise Schedule Invariance

A remarkable property emerges through the change of variables Ξ³=log⁑(1βˆ’Ξ±t): (MDLM Schedule Invariant)β„’NELBO∞=βˆ’π”Όqβˆ«βˆ’βˆž0βˆ‘β„“=1Llog⁑⟨xΞΈβ„“(𝒛γ,Ξ³),x0β„“βŸ©dΞ³.

Proposition 1 (Schedule Invariance).

The continuous-time NELBO is invariant to the functional form of Ξ±t. The noise schedule affects only the forward process marginals (and hence training dynamics and variance), but not the converged objective value.

This eliminates one degree of hyperparameter freedom: any monotone schedule running from Ξ±0=1 down to Ξ±1=0 converges to the same objective, since those are exactly the conditions under which Ξ³=log⁑(1βˆ’Ξ±t) sweeps the full range (βˆ’βˆž,0].

Connection to Masked Language Modeling

For a sequence of length L, the MDLM objective can be written as: β„’NELBO∞=𝔼q∫01βˆ’Ξ±tβ€²1βˆ’Ξ±tβˆ‘β„“=1L(βˆ’log⁑⟨xΞΈβ„“(𝒛t,t),x0β„“βŸ©)dt. At each time t, the masking rate is 1βˆ’Ξ±t, and the loss is the cross-entropy of predicting masked tokens, which is precisely masked language modeling (MLM) at that masking rate. The integral averages over all masking rates from 0 to 1, weighted by βˆ’Ξ±tβ€²1βˆ’Ξ±t.

Remark 8.

MDLM training is a weighted average of MLM losses across different masking rates. This provides a formal bridge: BERT [3] performs MLM at a single fixed masking rate (15%), while MDLM averages over all masking rates with principled weighting. This endows encoder-only models with generation capability without sacrificing their representation quality.

The conceptual progression from BERT's masked language modeling to MDLM to a full diffusion generative model. BERT trains at a single masking rate; MDLM integrates over all rates with the weighting βˆ’Ξ±tβ€²/(1βˆ’Ξ±t) derived from the diffusion ELBO, which is 1/t on the linear schedule. That weighted objective already is the diffusion loss; what the last step adds is the ancestral sampler that turns the trained denoiser into a generative model.

Score Entropy Discrete Diffusion (SEDD)

An alternative approach to discrete diffusion, developed concurrently with MDLM, is SEDD (Score Entropy Discrete Diffusion) [19], which won the ICML 2024 Best Paper award. Instead of parameterizing the reverse process directly, SEDD learns ratios of probabilities, the discrete analogue of the score function.

The Concrete Score

In continuous diffusion, the score βˆ‡π’™log⁑pt(𝒙) is the key object. In discrete spaces, there are no gradients. SEDD defines the concrete score as the ratio: sΞΈ(𝒙,t)π’šβ‰ˆpt(π’š)pt(𝒙), for states π’š that are β€œneighbors” of 𝒙 (differing at a single position). This is the discrete analogue of the Stein score, since: βˆ‡π’™log⁑p(𝒙)=βˆ‡π’™p(𝒙)p(𝒙). A key advantage is that normalizing constants cancel in ratios: p(π’š)p(𝒙)=ef(π’š)/Zef(𝒙)/Z=ef(π’š)ef(𝒙).

Continuous-Time Markov Chain (CTMC)

SEDD operates in continuous time. The forward process is governed by a rate matrix 𝐑: dptdt=pt𝐑(t),p0=pdata,

For absorbing diffusion, the rate matrix is: R(i,j)={Οƒβ€²(t)ifΒ j=[ᴍᴀsα΄‹]Β andΒ iβ‰ [ᴍᴀsα΄‹]βˆ’Οƒβ€²(t)ifΒ i=jΒ andΒ iβ‰ [ᴍᴀsα΄‹]0otherwise where Οƒβ€²(t)=dΟƒ(t)/dt is the rate of masking. Each non-mask token transitions to [ᴍᴀsα΄‹] at rate Οƒβ€²(t). Note that pt is a row vector and 𝐑(t) acts on the right, so that the generator axioms hold in the usual orientation: off-diagonal entries are non-negative and every row of 𝐑(t) sums to zero, which is what conserves total probability.

Score Entropy Loss

The score entropy loss for estimating the concrete score is: (Score Entropy)β„’SE=π”Όπ’™βˆΌpt[βˆ‘π’šβˆΌπ’™wπ’™π’š(sΞΈ(𝒙,t)π’šβˆ’rπ’™π’šlog⁑sΞΈ(𝒙,t)π’š+K(rπ’™π’š))],rπ’™π’š=defpt(π’š)pt(𝒙), where π’šβˆΌπ’™ denotes neighbors of 𝒙, wπ’™π’šβ‰₯0 are the transition rates of the forward process, and (Score Entropy Normalizer)K(r)=r(log⁑rβˆ’1) is the normalizing term that makes the per-neighbour loss bottom out at exactly zero. Writing β„“(s)=sβˆ’rlog⁑s+K(r), we have β„“β€²(s)=1βˆ’r/s, which vanishes only at s=r; β„“β€²β€²(s)=r/s2>0 on the positive ray, so β„“ is strictly convex there; and β„“(r)=rβˆ’rlog⁑r+rlog⁑rβˆ’r=0. Hence:

  • Convex in sΞΈ, ensuring stable optimization.

  • Non-negative, equaling zero if and only if sΞΈ(𝒙,t)π’š=pt(π’š)/pt(𝒙).

  • The discrete analogue of the Fisher divergence used in continuous score matching.

Remark 9.

For absorbing diffusion, the concrete score factorizes into a time-dependent scalar times the conditional distribution of clean data: pt(x^i|context)pt([ᴍᴀsα΄‹]|context)=eβˆ’Οƒβ€Ύ(t)1βˆ’eβˆ’Οƒβ€Ύ(t)β‹…p0(x^i|unmaskedΒ tokens). This connects SEDD directly to masked language modeling: the learned score is essentially predicting the clean token distribution, scaled by a known time-dependent factor. Since Ξ±t=eβˆ’Οƒβ€Ύ(t) (Section The Continuous-Time Markov Chain Perspective), that scalar is Ξ±t/(1βˆ’Ξ±t), which is the same quantity that appears in the MDLM reverse posterior; the two remarks are one statement in two notations.

Detailed Derivation: From D3PM to MDLM

The transition from D3PM to MDLM involves several mathematical simplifications that are instructive to derive in full detail. We walk through each step, starting from the general D3PM ELBO and arriving at the clean MDLM objective.

Step 1: Specializing to the Absorbing Process

Recall from the general D3PM framework that the reverse posterior is given by . For the absorbing transition matrix , the cumulative product 𝐐‾t has a particularly clean form. For a single token: 𝐐‾t=∏k=1t𝐐kabs. Since each step either keeps the token (with probability 1βˆ’Ξ²k) or masks it (with probability Ξ²k), the probability that a token survives to time t is: Ξ±t=def∏k=1t(1βˆ’Ξ²k). The marginal is then: (Absorbing Marginal)q(xt|x0)={Ξ±tifΒ xt=x0Β (tokenΒ survives)1βˆ’Ξ±tifΒ xt=[ᴍᴀsα΄‹]Β (tokenΒ isΒ masked)0otherwise This is exactly the MDLM forward process written in discrete time.

Step 2: Computing the Reverse Posterior Explicitly

We now derive from first principles. Using Bayes' theorem: q(xtβˆ’1|xt,x0)=q(xt|xtβˆ’1)q(xtβˆ’1|x0)q(xt|x0).

Case 1: xtβ‰ [ᴍᴀsα΄‹].

If xt is a real token (not masked), then xt=x0 (the only way a real token appears at time t is if it was never masked). In this case, xtβˆ’1 must also equal x0: q(xtβˆ’1=x0|xt=x0,x0)=1. The one-line Bayes check: the numerator is q(xt=x0|xtβˆ’1=x0)q(xtβˆ’1=x0|x0)=(Ξ±t/Ξ±tβˆ’1)β‹…Ξ±tβˆ’1=Ξ±t and the denominator is q(xt=x0|x0)=Ξ±t, so the ratio is 1; the competing candidate xtβˆ’1=[ᴍᴀsα΄‹] has numerator q(xt=x0|xtβˆ’1=[ᴍᴀsα΄‹])=0, because the mask is absorbing. This is the β€œcarry-over” property: unmasked tokens remain fixed.

Case 2: xt=[ᴍᴀsα΄‹].

We need to compute: q(xtβˆ’1|xt=[ᴍᴀsα΄‹],x0)=q(xt=[ᴍᴀsα΄‹]|xtβˆ’1)q(xtβˆ’1|x0)q(xt=[ᴍᴀsα΄‹]|x0). The first numerator factor is a one-step transition and the second is a marginal given x0; below we keep both time indices explicit so the two are never confused.

The denominator is q(xt=[ᴍᴀsα΄‹]|x0)=1βˆ’Ξ±t from .

Sub-case 2a: xtβˆ’1=x0 (token was unmasked at tβˆ’1, then masked at t).

q(xtβˆ’1=x0|xt=[ᴍᴀsα΄‹],x0)=q(xt=[ᴍᴀsα΄‹]|xtβˆ’1=x0)β‹…q(xtβˆ’1=x0|x0)1βˆ’Ξ±t=Ξ²tβ‹…Ξ±tβˆ’11βˆ’Ξ±t. Since Ξ±t=Ξ±tβˆ’1(1βˆ’Ξ²t), we have Ξ²tΞ±tβˆ’1=Ξ±tβˆ’1βˆ’Ξ±t, so: (Posterior Unmask)q(xtβˆ’1=x0|xt=[ᴍᴀsα΄‹],x0)=Ξ±tβˆ’1βˆ’Ξ±t1βˆ’Ξ±t.

Sub-case 2b: xtβˆ’1=[ᴍᴀsα΄‹] (token was already masked at tβˆ’1).

(Posterior Staymask)q(xtβˆ’1=[ᴍᴀsα΄‹]|xt=[ᴍᴀsα΄‹],x0)=q(xt=[ᴍᴀsα΄‹]|xtβˆ’1=[ᴍᴀsα΄‹])β‹…q(xtβˆ’1=[ᴍᴀsα΄‹]|x0)1βˆ’Ξ±t=1β‹…(1βˆ’Ξ±tβˆ’1)1βˆ’Ξ±t.

We can verify these sum to 1: Ξ±tβˆ’1βˆ’Ξ±t1βˆ’Ξ±t+1βˆ’Ξ±tβˆ’11βˆ’Ξ±t=Ξ±tβˆ’1βˆ’Ξ±t+1βˆ’Ξ±tβˆ’11βˆ’Ξ±t=1βˆ’Ξ±t1βˆ’Ξ±t=1.βœ“

Combining both cases yields exactly .

Step 3: From KL Divergence to Cross-Entropy

The D3PM variational bound contains terms of the form: β„’t=𝔼q(xt|x0)[DKL(q(xtβˆ’1|xt,x0)β€–pΞΈ(xtβˆ’1|xt))].

For the absorbing process, when xtβ‰ [ᴍᴀsα΄‹], both the true and learned reverse posteriors are deterministic (keeping xt unchanged), so the KL is zero. The non-trivial contribution comes only from xt=[ᴍᴀsα΄‹]: β„’t=Pr⁑[xt=[ᴍᴀsα΄‹]|x0]β‹…DKL(q(xtβˆ’1|[ᴍᴀsα΄‹],x0)β€–pΞΈ(xtβˆ’1|[ᴍᴀsα΄‹]))=(1βˆ’Ξ±t)β‹…DKL(q(β‹…)β€–pΞΈ(β‹…)).

With the SUBS parameterization and the zero-masking-probability constraint, the reverse distribution at a masked position takes the form: pΞΈ(xtβˆ’1|xt=[ᴍᴀsα΄‹])={1βˆ’Ξ±tβˆ’11βˆ’Ξ±tifΒ xtβˆ’1=[ᴍᴀsα΄‹]Ξ±tβˆ’1βˆ’Ξ±t1βˆ’Ξ±tβ‹…pΞΈv(x0=v|xt)ifΒ xtβˆ’1=vβ‰ [ᴍᴀsα΄‹] where pΞΈv(x0=v|xt) is the network's predicted probability for token v.

The KL divergence between the true and learned posteriors at a masked position can be expanded: DKL(q(xtβˆ’1|[ᴍᴀsα΄‹],x0)β€–pΞΈ(xtβˆ’1|[ᴍᴀsα΄‹]))=1βˆ’Ξ±tβˆ’11βˆ’Ξ±tlog⁑(1βˆ’Ξ±tβˆ’1)/(1βˆ’Ξ±t)(1βˆ’Ξ±tβˆ’1)/(1βˆ’Ξ±t)+Ξ±tβˆ’1βˆ’Ξ±t1βˆ’Ξ±tlog⁑(Ξ±tβˆ’1βˆ’Ξ±t)/(1βˆ’Ξ±t)(Ξ±tβˆ’1βˆ’Ξ±t)β‹…pΞΈx0(x0|xt)/(1βˆ’Ξ±t)=Ξ±tβˆ’1βˆ’Ξ±t1βˆ’Ξ±tlog⁑1pΞΈx0(x0|xt)=βˆ’Ξ±tβˆ’1βˆ’Ξ±t1βˆ’Ξ±tlog⁑pΞΈ(x0|xt).

This is the Rao-Blackwellization: the KL divergence at masked positions reduces to a weighted negative log-probability of the true token. The weighting Ξ±tβˆ’1βˆ’Ξ±t1βˆ’Ξ±t is exactly the coefficient in the MDLM loss .

Step 4: Summing Over Positions and Time

For a sequence of length L with independent masking, summing over all positions and time steps: βˆ‘t=1Tβ„’t=βˆ’βˆ‘t=1T𝔼q(𝒙t|𝒙0)[Ξ±tβˆ’1βˆ’Ξ±t1βˆ’Ξ±tβˆ‘β„“=1L𝟏[xtβ„“=[ᴍᴀsα΄‹]]β‹…log⁑pΞΈ(x0β„“|𝒙t)].

Taking Tβ†’βˆž and using Ξ±tβˆ’1βˆ’Ξ±tβ†’βˆ’Ξ±tβ€²dt (where Ξ±tβ€²=dΞ±t/dt<0): β„’diffusion=βˆ’βˆ«01𝔼q[βˆ’Ξ±tβ€²1βˆ’Ξ±tβˆ‘β„“=1L𝟏[xtβ„“=[ᴍᴀsα΄‹]]β‹…log⁑pΞΈ(x0β„“|𝒙t)]dt. Since Ξ±t is decreasing, Ξ±tβ€²<0, so βˆ’Ξ±tβ€²>0 and the weight is positive. This recovers the MDLM continuous-time NELBO .

Step 5: The Change of Variables to Schedule Invariance

The schedule invariance result follows from the substitution Ξ³=log⁑(1βˆ’Ξ±t), which yields dΞ³=βˆ’Ξ±tβ€²1βˆ’Ξ±tdt. The integral becomes: β„’diffusion=βˆ’βˆ«βˆ’βˆž0𝔼q[βˆ‘β„“=1L𝟏[xΞ³β„“=[ᴍᴀsα΄‹]]β‹…log⁑pΞΈ(x0β„“|𝒙γ)]dΞ³.

The key observation is that Ξ³ absorbs the entire schedule-dependent weighting, leaving an integral that depends only on the masking probability 1βˆ’Ξ±t=eΞ³ (since Ξ³=log⁑(1βˆ’Ξ±t)). Two different schedules Ξ±t and Ξ±~t that sweep through the same range of masking probabilities will produce the same integral, just traversed at different speeds. (Here Ξ±~t names a second schedule; the prime continues to mean d/dt throughout.)

Remark 10.

This schedule invariance is unique to the continuous-time limit. In practice with finite T, the schedule affects training dynamics and variance. Linear (Ξ±t=1βˆ’t), cosine, and geometric schedules all converge to similar final performance but may train at different speeds.

Worked Example: MDLM on a 3-Token Vocabulary

To make these derivations concrete, consider a toy example with two real tokens, 𝒱={A,B}, so K=2, plus the extra [ᴍᴀsα΄‹] state, giving three states per position; the sequence length is L=2. (Throughout this chapter K counts the real vocabulary, and [ᴍᴀsα΄‹] is an additional state appended to it.)

Example 1.

Let 𝒙0=(A,B) and suppose Ξ±t=1βˆ’t (linear schedule). At time t=0.4:

  • Each token is masked independently with probability 1βˆ’Ξ±0.4=0.4.

  • Possible states of 𝒙t: (A,B) with prob 0.36; (A,[ᴍᴀsα΄‹]) with prob 0.24; ([ᴍᴀsα΄‹],B) with prob 0.24; ([ᴍᴀsα΄‹],[ᴍᴀsα΄‹]) with prob 0.16.

Consider the state 𝒙t=([ᴍᴀsα΄‹],B). The model must predict the first token. The training loss contribution for this state at this time is: βˆ’Ξ±tβ€²1βˆ’Ξ±tβ‹…(βˆ’log⁑pΞΈ(x01=A|[ᴍᴀsα΄‹],B))=10.4β‹…(βˆ’log⁑pΞΈ(A|[ᴍᴀsα΄‹],B)).

Notice the weight 1/t=1/0.4=2.5, against 1/0.9β‰ˆ1.1 at t=0.9. The weight is not a preference for easy examples: it exactly cancels the number of terms being summed. At masking rate t the expected number of masked positions is L(1βˆ’Ξ±t)=Lt, so the expected contribution of that rate is (1/t)β‹…Lt=L, the same at every t. Integrating over t gives L(Ξ±0βˆ’Ξ±1)=L for any schedule running from 1 down to 0. The 1/t is what makes the measure over masking rates uniform; it is the reason MDLM is an average of MLM losses rather than a reweighting of them.

The Continuous-Time Markov Chain Perspective

The discrete-time formulations of D3PM and MDLM have natural continuous-time analogues via continuous-time Markov chains (CTMCs). This perspective, developed in Campbell et al. [27] and refined in SEDD [19], provides elegant theoretical properties and connects discrete diffusion to the score-based framework.

Rate Matrices and the Master Equation

A CTMC over a finite state space {1,…,K} is characterized by a rate matrix (or generator) 𝐑(t)βˆˆβ„KΓ—K⁑, where:

  • Rij(t)β‰₯0 for iβ‰ j (transition rate from state i to state j)

  • Rii(t)=βˆ’βˆ‘jβ‰ iRij(t) (rows sum to zero)

The probability distribution 𝒑t=(pt(1),…,pt(K)) evolves according to the master equation (Kolmogorov forward equation): (Master Equation)d𝒑tdt=𝒑t𝐑(t).

This is the discrete-space analogue of the Fokker-Planck equation in continuous diffusion. The solution is: 𝒑t=𝒑0exp⁑(∫0t𝐑(s)ds), where the matrix exponential gives the transition probability matrix.

The Absorbing Rate Matrix

For masked diffusion, the rate matrix is: (Absorbing RATE)Rij(t)={Οƒβ€²(t)ifΒ j=[ᴍᴀsα΄‹]Β andΒ iβ‰ [ᴍᴀsα΄‹]βˆ’Οƒβ€²(t)ifΒ i=jΒ andΒ iβ‰ [ᴍᴀsα΄‹]0otherwise where Οƒβ€²(t)=dΟƒ(t)/dt>0 controls the masking rate.

In matrix form, for a 3-state system {1,2,[ᴍᴀsα΄‹]}: 𝐑(t)=Οƒβ€²(t)(βˆ’1010βˆ’11000).

The masking probability at time t is: Pr⁑[xt=[ᴍᴀsα΄‹]|x0β‰ [ᴍᴀsα΄‹]]=1βˆ’eβˆ’Οƒβ€Ύ(t),whereΒ Οƒβ€Ύ(t)=∫0tΟƒβ€²(s)ds. Comparing with MDLM's Ξ±t: we have Ξ±t=eβˆ’Οƒβ€Ύ(t), or equivalently Οƒβ€Ύ(t)=βˆ’log⁑αt.

The Reverse CTMC

The time-reversed CTMC has rate matrix: (Reverse RATE)Rβ€Ύij(t)=pt(j)pt(i)Rji(t). This is the discrete analogue of Anderson's reverse-time SDE. The ratio pt(j)/pt(i) is exactly the concrete score, which SEDD learns to estimate.

For the absorbing process, the reverse rate simplifies: the only non-trivial transitions are from [ᴍᴀsα΄‹] to real tokens, with rate: Rβ€Ύ[ᴍᴀsα΄‹],v(t)=pt(v)pt([ᴍᴀsα΄‹])β‹…Οƒβ€²(t).

Remark 11.

This reveals why MDLM and SEDD are closely related: MDLM directly parameterizes p0(v|unmaskedΒ context) (the conditional clean distribution), while SEDD parameterizes pt(v)/pt([ᴍᴀsα΄‹]) (the concrete score). For absorbing diffusion, these are related by a known time-dependent factor: pt(v|context)pt([ᴍᴀsα΄‹]|context)=Ξ±t1βˆ’Ξ±tβ‹…p0(v|unmaskedΒ context).

Forward and reverse CTMCs for absorbing diffusion. The forward process masks tokens at rate Οƒβ€²(t). The reverse process unmasks them at rates proportional to the concrete score pt(v)/pt([ᴍᴀsα΄‹]).

Large Language Diffusion Models (LLaDA)

With the theoretical foundations from MDLM and SEDD, the next question was: can masked diffusion models scale to the size and capability of modern LLMs? LLaDA (Large Language Diffusion Models) [5] provided a resounding β€œyes,” demonstrating that an 8-billion parameter diffusion model can match or exceed autoregressive models on many benchmarks.

Core Thesis

LLaDA challenges the prevailing assumption that autoregressive formulations are necessary for emergent LLM capabilities such as in-context learning, instruction following, and chain-of-thought reasoning. The authors argue that these capabilities arise from the interplay between Transformers, model scale, data scale, and Fisher consistency, a statistical property guaranteeing that the model can recover the true data distribution with sufficient data and capacity, rather than from the left-to-right factorization specifically.

Definition 2 (Fisher Consistency).

A generative model family {pΞΈ:θ∈Θ} is Fisher consistent for a data distribution pdata if, given infinite data and a sufficiently expressive network: ΞΈβˆ—=arg maxθ⁑𝔼pdata[log⁑pΞΈ(𝒙)]⟹pΞΈβˆ—=pdata. Both autoregressive models and masked diffusion models satisfy this property.

Forward and Reverse Process

LLaDA uses the same masking-based forward process as MDLM, but with a clearer presentation in terms of continuous time t∈[0,1]:

Forward process (token-level):

(Llada Forward)qt|0(xti|x0i)={1βˆ’tifΒ xti=x0itifΒ xti=[ᴍᴀsα΄‹] At t=0, no tokens are masked; at t=1, all tokens are masked. This is the simplest possible masking schedule: Ξ±t=1βˆ’t.

Reverse process (token-level):

For 0≀s<t≀1, the reverse transition has four cases: (Llada Reverse)qs|t(xsi|𝒙t)={1ifΒ xtiβ‰ [ᴍᴀsα΄‹]Β andΒ xsi=xti(stayΒ unmasked)0ifΒ xtiβ‰ [ᴍᴀsα΄‹]Β andΒ xsiβ‰ xti(cannotΒ change)stifΒ xti=[ᴍᴀsα΄‹]Β andΒ xsi=[ᴍᴀsα΄‹](stayΒ masked)tβˆ’stβ‹…q0|t(xsi|𝒙t)ifΒ xti=[ᴍᴀsα΄‹]Β andΒ xsiβ‰ [ᴍᴀsα΄‹](unmask)

Remark 12 (Time-Free Parameterization).

A crucial insight from LLaDA: the optimal predictor q0|t(x0i|𝒙t)=pdata(x0i|𝒙tunmasked) depends only on which tokens are visible, not on the timestep t. This means the mask predictor pΞΈ does not need time as an input, a significant simplification.

Training Objective

The LLaDA training loss is: (Llada LOSS)β„’(ΞΈ)=βˆ’π”Όt∼U(0,1],𝒙0∼pdata,𝒙t∼qt|0[1tβˆ‘i=1L𝟏[xti=[ᴍᴀsα΄‹]]β‹…log⁑pΞΈ(x0i|𝒙t)].

The 1/t weighting is theoretically motivated: it ensures that the loss is a valid upper bound on the negative log-likelihood: βˆ’π”Όπ’™0∼pdata[log⁑pΞΈ(𝒙0)]≀ℒ(ΞΈ).

Remark 13.

This 1/t weighting distinguishes LLaDA from MaskGIT [4], which omits this term and thus lacks a principled maximum-likelihood foundation. The per-token weight 1/t is larger at small t, but the expected number of masked positions at rate t is Lt, so the expected contribution of each rate is (1/t)(Lt)=L: the weighting makes the measure over masking rates exactly uniform. That is precisely what turns a masked language model trained at one rate into a likelihood-based generative model.

Architecture

LLaDA 8B uses essentially the same Transformer architecture as LLaMA 3 8B. One design decision differs, and the table below shows it together with the consequence that follows from it:

FeatureLLaDA 8BLLaMA3 8B
AttentionFull bidirectionalCausal (left-to-right)
KV cacheNot applicableUsed for fast inference
Positional encodingRoPERoPE
NormalizationRMSNormRMSNorm
ActivationSwiGLUSwiGLU
Parameters∼8B∼8B

The key architectural change is removing the causal attention mask, allowing the model to attend to all positions bidirectionally. This is essential for the diffusion formulation, where the model needs to use both left and right context to predict masked tokens. However, it means that the KV cache optimization, crucial for fast autoregressive inference, is not directly applicable.

Supervised Fine-Tuning for Diffusion Models

For instruction following, LLaDA uses a modified SFT loss where only the response tokens are subject to masking: (Llada SFT)β„’SFT(ΞΈ)=βˆ’π”Όt,𝒑0,𝒓0,𝒓t[1tβˆ‘i=1Lβ€²πŸ[rti=[ᴍᴀsα΄‹]]β‹…log⁑pΞΈ(r0i|𝒑0,𝒓t)], where 𝒑0 are the prompt tokens (always unmasked), 𝒓0 are the response tokens (subject to masking), and Lβ€² is the response length.

Experimental Results: How Good Are Diffusion Language Models?

Before describing the sampling algorithms, let us examine the empirical evidence for diffusion language models to understand how they compare with autoregressive models across various tasks.

Language Modeling Perplexity (MDLM)

MDLM [18] provides the first strong evidence that masked diffusion can approach autoregressive performance. On the One Billion Word benchmark (LM1B) with 110M parameter models:

ModelTypePerplexity (↓)
Transformer (AR, retrained)Autoregressive20.86
BERT-MouthMLM generation≀142.89
D3PM (absorbing)Discrete diffusion≀76.90
DiffusionBERTDiscrete diffusion≀63.78
SEDDScore-based discrete≀32.79
MDLMMasked diffusionβ‰€πŸπŸ‘.𝟎𝟎

MDLM achieves a 17% improvement over SEDD (the prior best diffusion model) and comes within ∼10% of the AR baseline. The progression from D3PM (≀76.90) to MDLM (≀23.00) demonstrates the power of the simplified Rao-Blackwellized objective.

Benchmark Results at Scale (LLaDA 8B)

LLaDA 8B [5], trained on 2.3 trillion tokens, provides the first comparison of diffusion models with modern LLMs at the 8B parameter scale:

BenchmarkLLaDA 8BLLaMA3 8BLLaMA2 7B
(2.3T tokens)(15T tokens)(2T tokens)
MMLU65.965.445.9
GSM8K70.753.114.3
MATH27.315.13.2
HumanEval33.534.212.8
HumanEval-FIM73.873.326.9
HellaSwag72.579.176.0
WinoGrande74.877.372.5
Bold marks the stronger of LLaDA 8B and LLaMA3 8B on each row. LLaDA leads on four of the seven and trails on three: HumanEval by 0.7, HellaSwag by 6.6 and WinoGrande by 2.5.

The largest margins are on mathematics (GSM8K: 70.7 vs. 53.1; MATH: 27.3 vs. 15.1), obtained with 2.3T training tokens against LLaMA3's 15T. This suggests that the bidirectional architecture may have advantages for mathematical reasoning, while the commonsense benchmarks, where LLaDA trails, suggest the advantage is not uniform across task types.

Post-SFT Performance

After supervised fine-tuning, LLaDA 8B Instruct (using only SFT, no RLHF/DPO) achieves:

BenchmarkLLaDA 8B Instruct
MMLU65.5
ARC-C88.5
HumanEval49.4
GSM8K78.6
MATH26.6

These results are competitive with AR models that use RLHF alignment, suggesting that the diffusion training paradigm provides strong instruction-following capabilities even without explicit preference optimization.

Representation Quality (MDLM on GLUE)

A key question is whether the diffusion training objective degrades the representation quality of encoder-only models. MDLM tests this by fine-tuning a BERT model with the MDLM objective and evaluating on GLUE:

TaskARBERTBERT+MDLM
MNLI (m/mm)80.9/80.884.4/85.484.8/85.1
QQP (F1)87.088.488.5
SST-290.192.292.2
CoLA33.454.857.7
Average74.981.682.1
The average row covers the full GLUE suite, not only the four tasks displayed, so it will not reproduce as the mean of the columns above it.

Fine-tuning BERT with the MDLM objective does not degrade representation quality; it actually slightly improves it (82.1 vs. 81.6 average) while adding generative capabilities. This demonstrates that diffusion training and representation learning are compatible.

Scaling Laws for Diffusion Language Models

LLaDA demonstrates that diffusion language models exhibit scaling behavior comparable to autoregressive models. Testing across FLOPs from 1020 to 1023 on six benchmarks, diffusion models follow the same general scaling trend as ARMs.

Illustrative scaling behavior of diffusion vs. autoregressive language models. Both follow similar scaling trends, with the gap narrowing at larger compute budgets. Based on trends reported in LLaDA [5].

An important finding from the scaling experiments is that likelihood metrics alone are insufficient predictors of downstream task performance for diffusion models. This contrasts with AR models, where lower perplexity reliably predicts better downstream performance. For diffusion models, the ELBO (which is an upper bound on negative log-likelihood) does not always correlate with task-specific metrics, suggesting that evaluation strategies for diffusion models need further development.

Sampling Algorithms and Remasking Strategies

Generation in diffusion language models works by iteratively unmasking tokens. Starting from a fully masked sequence 𝒓1=([ᴍᴀsα΄‹],…,[ᴍᴀsα΄‹]), the model progressively reveals tokens over N steps. The key design choice is the remasking strategy: after the model predicts all masked tokens, which predictions should be kept and which should be re-masked for refinement?

Random Remasking

The simplest approach randomly selects which tokens to remask:

Algorithm 2: Sampling with Random Remasking (LLaDA).

[t]

  1. Input: Mask predictor pΞΈ, prompt 𝒑0, response length L, steps N
  2. Initialize 𝒓1=([ᴍᴀsα΄‹],…,[ᴍᴀsα΄‹]) Fully masked
  3. for k=1,2,…,N
  4. t←1βˆ’(kβˆ’1)/N, s←1βˆ’k/N
  5. 𝒓^0←arg max⁑pΞΈ(𝒓0|𝒑0,𝒓t) Predict all masked positions
  6. if s>0
  7. Randomly remask ⌊sβ‹…LβŒ‹ of the predicted tokens so ⌊L(1βˆ’s)βŒ‹ stand committed
  8. 𝒓s← result
  9. return 𝒓0

Low-Confidence Remasking

A more effective strategy is to remask the tokens that the model is least confident about:

Algorithm 3: Sampling with Low-Confidence Remasking (LLaDA).

[t]

  1. Input: Mask predictor pΞΈ, prompt 𝒑0, response length L, steps N
  2. Initialize 𝒓1=([ᴍᴀsα΄‹],…,[ᴍᴀsα΄‹])
  3. for k=1,2,…,N
  4. t←1βˆ’(kβˆ’1)/N, s←1βˆ’k/N
  5. for each masked position i
  6. Predict pΞΈ(r0i|𝒑0,𝒓t) and compute confidence ci=maxv⁑pΞΈ(r0i=v|𝒑0,𝒓t)
  7. nkβ†βŒŠLβ‹…(1βˆ’s)βŒ‹=⌊kL/NβŒ‹ Cumulative number committed by step k
  8. Ξ”k←nkβˆ’nkβˆ’1 New commitments this step, with n0=0
  9. Commit the Ξ”k highest-confidence predictions among the currently masked positions; remask the rest
  10. 𝒓s← result
  11. return 𝒓0

Remark 14.

Note that nk counts all positions committed so far, not the ones committed on this step; the per-step count is the difference Ξ”k. Applying nk to the masked-only pool would over-commit early and finish before step N: at L=9, N=3 it commits 3 then 6, exhausting the sequence at step two of three, whereas the cumulative reading gives the intended 3, 3, 3.

Low-confidence remasking is the default strategy in LLaDA and consistently outperforms random remasking. The intuition is clear: by keeping the most confident predictions and re-predicting the uncertain ones with additional context from the newly revealed tokens, the model iteratively refines its output.

Low-confidence remasking in action. Step 1: all tokens are masked, and the model predicts all positions. High-confidence predictions (green) are kept; low-confidence ones (red) are remasked. Step 2: with the context of the kept tokens, the model re-predicts the remaining positions with better accuracy.

Block Diffusion: Semi-Autoregressive Generation

Block diffusion [6] interpolates between fully parallel diffusion and fully sequential autoregressive generation. The sequence is divided into blocks, and blocks are generated left-to-right (autoregressively), while tokens within each block are generated via diffusion (in parallel).

Block diffusion: a semi-autoregressive generation scheme. Blocks are generated left-to-right (autoregressive order), while tokens within each block are generated via diffusion (parallel). This enables flexible trade-offs between speed and quality.

Write B for the block size, so a sequence of length L is divided into L/B blocks 𝒙=(𝒙1,𝒙2,…,𝒙L/B) and block k is conditioned on all earlier blocks 𝒙<k. The block diffusion loss is: β„’BDLM(ΞΈ)=𝔼[βˆ’Ξ±tβ€²1βˆ’Ξ±tβˆ‘k=1L/Bβˆ‘i𝟏[xt,ki=[ᴍᴀsα΄‹]]β‹…(βˆ’log⁑pΞΈ(x0,ki|𝒙0,<k,𝒙t,k))], with the same positive weight wt=βˆ’Ξ±tβ€²/(1βˆ’Ξ±t) as before, equal to 1/t on the linear schedule. Every factor is non-negative.

The block size controls the trade-off:

  • B=1: fully autoregressive, L blocks, one token committed per pass

  • B=L: fully diffusion-based, a single block

  • 1<B<L: semi-autoregressive, L/B blocks, at most B positions committed per pass, and Lβˆ’B tokens of frozen prefix before the last block

Remark 15.

The mechanism, rather than any single benchmark number, is the point: shrinking B buys each prediction more committed left context at the cost of more sequential passes, and growing B trades that context away for parallelism. The autoregressive and fully-parallel samplers are the two endpoints of one dial [6].

Detailed Analysis of Masking Schedules

The masking schedule Ξ±t determines how quickly tokens are corrupted during the forward process. While the continuous-time NELBO is schedule-invariant at convergence, the schedule significantly affects training dynamics, variance, and finite-step sampling quality.

Common Schedules

Linear Schedule.

Ξ±t=1βˆ’t for t∈[0,1]. This is the simplest choice and is used in LLaDA. The masking rate increases linearly, and the weight βˆ’Ξ±tβ€²1βˆ’Ξ±t=1t diverges as tβ†’0 (few tokens masked), placing heavy emphasis on near-complete sequences.

Cosine Schedule.

Ξ±t=cos2⁑(Ο€t/2). Inspired by the cosine schedule for continuous diffusion [28], this provides the smoothest start, masking very slowly for small t and then, past the midpoint, more aggressively than the linear schedule (at t=0.9, Ξ±t=0.0245 against the linear 0.1): βˆ’Ξ±tβ€²1βˆ’Ξ±t=Ο€sin⁑(Ο€t/2)cos⁑(Ο€t/2)1βˆ’cos2⁑(Ο€t/2)=Ο€cos⁑(Ο€t/2)sin⁑(Ο€t/2)=Ο€cot⁑(Ο€t/2).

Geometric (Exponential) Schedule.

Ξ±t=eβˆ’Οƒt for some rate parameter Οƒ>0: βˆ’Ξ±tβ€²1βˆ’Ξ±t=Οƒeβˆ’Οƒt1βˆ’eβˆ’Οƒt.

Comparison of masking schedules. All take Ξ±0=1 (no masking). The linear and cosine schedules reach Ξ±1=0 exactly; the geometric schedule Ξ±t=eβˆ’Οƒt approaches 0 only as tβ†’βˆž, and at Οƒ=3 it still leaves eβˆ’3=0.0498, about five tokens in every hundred unmasked at t=1. In practice one either reads it on [0,∞) or picks Οƒ large enough that the residual is negligible (Οƒ=9.21 gives Ξ±1=10βˆ’4). The cosine schedule has the smoothest start; the geometric schedule masks aggressively early.

Effect on Training Variance

At each training step, we sample a time t∼U(0,1] and compute the loss at that masking level. The variance of the gradient estimator depends on the schedule through the weight w(t)=βˆ’Ξ±tβ€²1βˆ’Ξ±t:

  • When w(t) varies widely, the gradient estimator has high variance.

  • The linear schedule has w(t)=1/t, which diverges as tβ†’0, leading to occasionally very large gradients when a nearly-complete sequence is sampled.

  • Low-discrepancy time sampling (e.g., stratified sampling of t) can reduce this variance significantly [7].

Mask Ratio Bandwidth

LLaDA 2.0 introduces mask ratio bandwidth: clipping the noise schedule to [Ξ±min⁑,Ξ±max⁑] instead of [0,1], which avoids the extreme masking rates that cause high variance: Ξ±~t=Ξ±min⁑+(Ξ±maxβ‘βˆ’Ξ±min⁑)β‹…Ξ±t. This clips the masking level rather than the time: it is an affine rescaling of Ξ±, which corresponds to a restriction of t to a subinterval only for the linear schedule. For the cosine schedule with Ξ±min⁑=0.05, Ξ±max⁑=0.95 the induced reparametrisation departs from the affine prediction by up to 0.042 in t.

Training Algorithms in Detail

We present the complete training algorithms for both pre-training and supervised fine-tuning of diffusion language models.

Algorithm 4: MDLM / LLaDA Pre-Training.

[t]

  1. Input: Bidirectional Transformer pΞΈ, data distribution pdata, schedule Ξ±t
  2. repeat
  3. Sample sequence 𝒙0=(x01,…,x0L)∼pdata
  4. Sample time t∼U(0,1]
  5. for each position β„“=1,…,L Independent masking
  6. With probability 1βˆ’Ξ±t: set ztℓ←[ᴍᴀsα΄‹]
  7. Otherwise: set ztℓ←x0β„“
  8. Forward pass: compute pΞΈ(x0β„“|𝒛t) for all β„“ Single forward pass
  9. Compute loss: β„’=βˆ’1tβ‹…1|{β„“:ztβ„“=[ᴍᴀsα΄‹]}|βˆ‘β„“:ztβ„“=[ᴍᴀsα΄‹]log⁑pΞΈ(x0β„“|𝒛t)
  10. Update ΞΈ via gradient descent on β„’
  11. until converged

Algorithm 5: Diffusion Language Model SFT (Instruction Tuning).

[t]

  1. Input: Pre-trained pΞΈ, prompt-response pairs (𝒑,𝒓)
  2. repeat
  3. Sample (𝒑0,𝒓0)βˆΌπ’ŸSFT
  4. Sample t∼U(0,1]
  5. for each response position i=1,…,Lβ€² Only mask response
  6. With probability 1βˆ’Ξ±t: set rti←[ᴍᴀsα΄‹]
  7. Otherwise: set rti←r0i
  8. Concatenate: 𝒛t=(𝒑0,𝒓t) Prompt always visible
  9. Forward pass: compute pΞΈ(r0i|𝒛t) for all masked positions i
  10. Compute loss: β„’SFT=βˆ’1tβ‹…1|{i:rti=[ᴍᴀsα΄‹]}|βˆ‘i:rti=[ᴍᴀsα΄‹]log⁑pΞΈ(r0i|𝒑0,𝒓t)
  11. Update ΞΈ
  12. until converged

Remark 16 (Comparison with AR SFT).

In autoregressive SFT, the prompt tokens are processed via teacher forcing (the model sees the prompt and predicts the response left-to-right). In diffusion SFT, the prompt is simply concatenated as unmasked context, and no architectural change is needed. The prompt is always fully visible, and the response is the only part subject to masking and prediction.

Detailed Sampling Procedures

We present the complete sampling algorithms, including the newly introduced ancestral sampling variant and the semi-autoregressive extension.

Ancestral Sampling (Principled but Slow)

The most principled sampling method follows the learned reverse process exactly:

Algorithm 6: Ancestral Sampling for Masked Diffusion.

[H]

  1. Input: Trained model pΞΈ, response length L, number of steps N
  2. Initialize 𝒛1=([ᴍᴀsα΄‹],…,[ᴍᴀsα΄‹])
  3. for k=1,…,N
  4. t←1βˆ’(kβˆ’1)/N, s←1βˆ’k/N
  5. Compute pΞΈ(x0β„“|𝒛t) for all masked positions β„“ Forward pass
  6. for each position β„“
  7. if ztβ„“=[ᴍᴀsα΄‹]
  8. With probability s/t: keep zsβ„“=[ᴍᴀsα΄‹] Stay masked
  9. With probability 1βˆ’s/t: sample zsβ„“βˆΌpΞΈ(x0β„“|𝒛t) Unmask
  10. else
  11. zsβ„“=ztβ„“ Carry over (already unmasked)
  12. return 𝒛0

At each step, each masked token either stays masked (with probability s/t) or is unmasked by sampling from the predicted distribution. This follows the exact reverse posterior .

Caching Optimization

When no new tokens are unmasked in a step (which can happen, especially with few remaining masked tokens), the forward pass can be skipped entirely. Furthermore, if the model does not use time conditioning (as suggested by Remark Remark 12), consecutive steps with the same set of unmasked tokens produce identical predictions, so those passes can be reused. How much this saves depends entirely on the sampler and the schedule: it is the fraction of steps that commit nothing.

Semi-Autoregressive (SAR) Generation

For sequences longer than the context window L, MDLM introduces a sliding-window approach:

Algorithm 7: Semi-Autoregressive Generation (MDLM).

[H]

  1. Input: Model pΞΈ, context window L, prefix overlap Lβ€², total length Ltotal
  2. Generate initial window 𝒙^1:L via standard reverse diffusion
  3. output←𝒙^1:L
  4. while |output|<Ltotal
  5. prefix←𝒙^Lβˆ’Lβ€²+1:L Last Lβ€² tokens as fixed prefix
  6. Initialize new window: 𝒛1=(prefix,[ᴍᴀsα΄‹],…,[ᴍᴀsα΄‹])
  7. Generate via reverse diffusion with prefix fixed (carry-over ensures prefix stays)
  8. Append the Lβˆ’Lβ€² newly generated tokens (positions Lβ€²+1 through L of the new window) to output
  9. Slide window forward
  10. return output After m windows, Ltotal=L+(mβˆ’1)(Lβˆ’Lβ€²)

Semi-autoregressive generation with sliding windows. The prefix (green) from the previous window provides context for generating new tokens (gray/masked) in the next window. The overlap ensures coherence between windows.

Advantages over Autoregressive LLMs

Diffusion language models offer several structural advantages over their autoregressive counterparts. These advantages are not merely theoretical; they have been demonstrated empirically in recent large-scale models.

Parallel Generation

The most obvious advantage is parallelism. In autoregressive generation, producing L tokens requires L serial forward passes, each of which reads the full KV cache but produces only a single token. This makes AR inference memory-bandwidth bound on modern GPUs, leading to poor hardware utilization.

Diffusion models, in contrast, process and refine all tokens simultaneously in each denoising step. If the model requires N denoising steps (typically Nβ‰ͺL), the total number of forward passes is N rather than L. Each forward pass has much higher arithmetic intensity (ratio of compute to memory operations), better saturating modern GPU compute units.

Example 2.

Mercury Coder achieves 1,109 tokens/second on H100 GPUs, compared to approximately 60–200 tokens/second for comparable autoregressive models. This represents a 5–10Γ— speedup, achieved purely through the diffusion generation paradigm [8].

Bidirectionality and the Reversal Curse

Autoregressive models factor the distribution left-to-right, which creates a fundamental asymmetry. If trained on β€œA is B,” the model learns p(B|A) but not p(A|B). This is the reversal curse [1].

Diffusion language models are inherently bidirectional: they use full attention (no causal mask), conditioning on both left and right context simultaneously. This means they naturally learn both directions.

Example 3 (Reversal Curse Experiment from LLaDA).

On Chinese poem completion (given first half, complete second half vs. given second half, complete first half):

ModelForwardReversal
GPT-4o82.7%34.3%
Qwen2.5 7B75.9%38.0%
LLaDA 8B48.8%42.4%
LLaDA surpasses GPT-4o on the reversal task (42.4% vs. 34.3%). Read the gaps rather than the levels: GPT-4o drops 48.4 points from forward to reversal and Qwen2.5 drops 37.9, while LLaDA drops 6.4. The autoregressive models are stronger in the forward direction and collapse in the reverse; LLaDA is more balanced.

Native Fill-in-the-Middle

Because diffusion models condition bidirectionally, fill-in-the-middle (FIM) is natively supported without special training modifications. Given a prefix and suffix, the model can generate the middle by treating the prefix and suffix as unmasked context and the middle as the masked region to be diffused.

LLaDA achieves 73.8% on HumanEval-FIM versus LLaMA3's 73.3%, despite LLaMA3 requiring specific FIM training.

Iterative Refinement and Error Correction

Perhaps the most intriguing advantage is the ability to self-correct. In autoregressive generation, once a token is emitted, it cannot be changed. An early mistake propagates through the entire remaining sequence. Diffusion models, through the remasking mechanism, can revisit and revise earlier decisions.

In low-confidence remasking (Algorithm alg:confidence_remasking), the model naturally identifies positions where it is uncertain and re-predicts them with additional context. This provides a built-in form of error correction that autoregressive models lack.

Remark 17 (Fault Tolerance).

In settings where early tokens may be corrupted (e.g., noisy inputs, adversarial prompts), diffusion models are more robust because they can use the full bidirectional context, including later, uncorrupted tokens, to correct earlier errors. Autoregressive models, processing left-to-right, cannot look ahead to verify consistency.

Flexible Generation Order

Autoregressive models are committed to a single generation order (left-to-right). Diffusion models can generate tokens in any order; the order is determined dynamically by the confidence scores and remasking strategy. This flexibility allows the model to:

  • Generate high-certainty tokens first (e.g., function signatures before implementations).

  • Fill in details after establishing the overall structure.

  • Naturally handle tasks like code completion where the generation order is not left-to-right.

Classifier-Free Guidance for Diffusion Language Models

Classifier-free guidance (CFG) [29], a technique that dramatically improves conditional generation quality in image diffusion models, can also be applied to diffusion language models.

CFG for Conditional Text Generation

In the image domain, CFG interpolates between conditional and unconditional predictions: 𝝐~ΞΈ(𝒙t,t,c)=(1+w)𝝐θ(𝒙t,t,c)βˆ’w𝝐θ(𝒙t,t), where w>0 is the guidance strength and c is the condition (e.g., text prompt).

For masked diffusion language models, the analogous formulation operates on the predicted token logits. Given a prompt 𝒑 and a masked response 𝒓t, the guided logits are: β„“~ΞΈi=(1+w)β„“ΞΈi(𝒑,𝒓t)βˆ’wβ„“ΞΈi(𝒓t), where β„“ΞΈi(𝒑,𝒓t) are the conditional logits (with prompt) and β„“ΞΈi(𝒓t) are the unconditional logits (prompt replaced with masks or dropped).

Remark 18.

LLaDA reports that CFG β€œconsistently benefits” conditional generation quality, but disables it in the main results for fair comparison with AR models. The ability to trade off diversity for quality via a guidance parameter is a unique advantage of the diffusion framework.

Comparison with AR Temperature Scaling

In autoregressive models, the analogue of CFG is temperature scaling: pΟ„(xi|𝒙<i)∝pΞΈ(xi|𝒙<i)1/Ο„, where Ο„<1 sharpens the distribution (more deterministic) and Ο„>1 flattens it (more diverse).

CFG in diffusion models is more powerful than simple temperature scaling because it leverages the difference between conditional and unconditional predictions, which captures information about what the prompt specifically requests. Temperature scaling merely adjusts the sharpness without such semantic grounding.

Classifier-free guidance for diffusion language models. The guided prediction amplifies what the prompt specifically contributes beyond the unconditional prediction, improving adherence to the prompt.

Challenges: Generation Speed and What Makes It Slow

Despite the advantages, diffusion language models face significant challenges related to generation speed and efficiency. Understanding these challenges is crucial for appreciating the engineering innovations in models like Mercury and LLaDA 2.0.

The Cost of Multiple Denoising Steps

While diffusion models process all tokens in parallel per step, they require multiple denoising steps (typically 16–256) to generate high-quality output. Each step involves a full forward pass through the Transformer. If the model uses N=64 steps and the autoregressive model generates L=512 tokens:

  • AR model: 512 forward passes, each producing 1 token (but using efficient KV cache)

  • Diffusion model: 64 forward passes, each processing all 512 tokens

The AR model benefits enormously from the KV cache: after the first pass, each subsequent pass only processes a single new token, reusing cached key-value pairs. The diffusion model must process the full sequence at each step, because unmasking changes the content of already-processed positions and so invalidates any cached keys and values, making each individual forward pass much more expensive.

No KV Cache

The fundamental incompatibility between bidirectional attention and the KV cache is the single biggest efficiency challenge:

  • AR models with KV cache: After the prefill phase, each token generation requires attention computation proportional to O(L) (attending to all cached tokens), but the computation is done only for the new token.

  • Diffusion models: Each denoising step requires full self-attention over all L tokens, with cost O(L2), simply because there are L queries rather than one. What the masking breaks is not the attention pattern, which is the same complete pattern at every step, but the cache: unmasking rewrites the token content at positions whose keys and values were already computed, so the stored 𝐊 and 𝐕 no longer describe those positions and must be recomputed.

Quality-Speed Trade-off

The number of denoising steps N directly controls the trade-off between generation quality and speed:

  • More steps: better quality (more refinement iterations), slower generation.

  • Fewer steps: faster generation, but tokens may not be sufficiently refined.

Finding the optimal N is an active research challenge. LLaDA shows that results are relatively insensitive to N within a reasonable range, but extremely few steps (e.g., N=1) significantly degrade quality.

Illustrative quality-speed trade-off for diffusion language models. Quality improves with more denoising steps but with diminishing returns. Generation speed decreases proportionally. The AR baseline requires no such trade-off but is limited in throughput.

Arithmetic Intensity Analysis

To understand the speed difference between AR and diffusion models quantitatively, consider the arithmetic intensity (AI), the ratio of floating-point operations to bytes transferred from memory: AI=FLOPsBytesΒ transferred.

AR inference (generation phase).

After the prefill, each token generation step involves:

  • Reading the model weights: O(dmodel2) bytes per layer. For a model with P parameters in bf16 this is 2P bytes, and it is the dominant transfer.

  • Reading the KV cache: O(Lβ‹…dmodel) bytes, smaller than the weight read at typical L and dmodel.

  • Computing one token against those weights: 2P FLOPs.

  • AI β‰ˆ2P/2P=1 FLOP per byte at batch size one, independent of model size: memory-bandwidth bound.

Diffusion inference (each denoising step).

Each step involves:

  • Reading model weights: O(dmodel2) bytes (same as AR)

  • Computing attention for L query tokens: O(L2β‹…dmodel) FLOPs

  • AI β‰ˆO(L), compute bound for long sequences

The key insight is that diffusion inference has LΓ— higher arithmetic intensity than AR generation-phase inference. An H100 SXM5 delivers 3.35,TB/s of HBM3 bandwidth against a dense bf16 tensor-core peak of 989.5,TFLOP/s, so the ridge point, where the machine stops being bandwidth bound and starts being compute bound, is AIridge=989.5Γ—10123.35Γ—1012=295Β FLOPsΒ perΒ byte. AR generation sits at AI β‰ˆ1, which reaches 1/295=0.34% of peak: over 99% of the compute is idle. Even at AI =10 only 3.4% of peak is used. Diffusion inference can reach AI β‰ˆL, which for L in the hundreds crosses the ridge and puts the machine on the compute roof instead.

Roofline model illustrating why diffusion models achieve higher throughput. The attainable rate is min⁑(BWΓ—AI,peak): it rises with slope +1 along the bandwidth roof and flattens at the compute ceiling, and the two meet at the ridge point AI =295. AR generation sits at AI β‰ˆ1, far down the bandwidth roof. Diffusion steps process many tokens per pass, reaching arithmetic intensities in the hundreds and touching the compute ceiling. Numbers are for an H100 SXM5: 3.35,TB/s HBM3 and 989.5,TFLOP/s dense bf16. Converting the attainable rate to tokens per second requires dividing by the FLOPs per token, which is done separately in the text.

Speculative Decoding and Fast Inference

Several techniques have been developed to accelerate diffusion language model inference, drawing inspiration from both the diffusion model literature and the autoregressive speculative decoding paradigm.

Confidence-Aware Parallel (CAP) Decoding

Introduced in LLaDA 2.0 [20], CAP training adds an auxiliary confidence loss that minimizes entropy selectively on correctly predicted tokens: β„’(ΞΈ)=β„’SFT(ΞΈ)+Ξ»β„’conf(ΞΈ). The confidence loss sharpens the model's probability distributions for tokens it can predict well, enabling more tokens to be unmasked in a single step. This effectively reduces the required number of denoising steps while maintaining accuracy.

With CAP training, LLaDA 2.0-flash achieves 535 tokens/second, a 2.1Γ— speedup over comparable AR baselines at 237–256 tokens/second.

Adaptive Step Count

Mercury [8] uses a dynamic step count that adjusts based on output complexity:

  • Simple structured outputs: ∼8 denoising steps

  • Complex reasoning: 16–20 denoising steps

This allows the system to automatically navigate the speed/quality trade-off without manual tuning.

Speculative Decoding for Diffusion

In autoregressive models, speculative decoding uses a small β€œdraft” model to propose multiple tokens in parallel, which are then verified by the large model. An analogous approach for diffusion models:

  1. A fast, small diffusion model generates a draft sequence in few steps.

  2. The large model refines the draft in one or two additional denoising steps.

  3. The refinement step leverages the bidirectional context to correct errors in the draft.

This naturally fits the diffusion paradigm because the refinement step is exactly what the model already does: denoising a partially correct sequence is a special case of denoising a partially masked sequence.

Scaling Up: LLaDA 2.0 and Mercury

The most recent frontier has been scaling diffusion language models to compete with state-of-the-art LLMs. Two prominent efforts are LLaDA 2.0 and Mercury.

LLaDA 2.0: From 8B to 100B via AR Conversion

LLaDA 2.0 [20] introduces a key insight: rather than training diffusion language models from scratch (which faces a maturity gap in data and infrastructure compared to AR models), convert pre-trained AR models into diffusion models.

Three-Phase Block-Level Training.

The conversion uses a Warmup-Stable-Decay (WSD) scheme:

  1. Warmup: Progressively increase the block size from 1 (fully AR) to 4096 (full sequence MDLM): 1β†’4β†’32β†’64β†’4096.

  2. Stable: Full-sequence MDLM training at block size 4096 for deep bidirectional understanding.

  3. Decay: Gradually reduce block size from 4096 back to 32 for efficient inference.

LLaDA 2.0's three-phase training scheme for converting autoregressive models to diffusion models. The block size gradually increases during warmup, stays at full sequence length during stable training, and decreases during decay for inference efficiency.
Mixture-of-Experts Architecture.

LLaDA 2.0 uses MoE (Mixture-of-Experts) architectures:

LLaDA 2.0-miniLLaDA 2.0-flash
Total parameters16B100B
Active parameters1.4B6.1B
Layers2032
Experts256 routed + 1 shared256 routed + 1 shared
Context length32,76832,768
Post-Training Pipeline.

LLaDA 2.0 introduces several innovations for post-training:

  1. Complementary masking: Generates two antithetical training instances from a single sequence: one uses a random mask, the other its logical inverse. Every token appears unmasked exactly once per pair, doubling effective data utilization.

  2. Mask ratio bandwidth: Clips the noise schedule to [αmin⁑,αmax⁑] instead of [0,1], avoiding extreme masking rates that induce high gradient variance.

  3. DPO for diffusion: Adapts Direct Preference Optimization using the ELBO as a surrogate for the intractable log-likelihood: β„’DPO(ΞΈ)=βˆ’π”Ό(𝒄,𝒙w,𝒙l)[log⁑σ(Ξ²[Δℬ(𝒙w|𝒄)βˆ’Ξ”β„¬(𝒙l|𝒄)])], where Δℬ(𝒙|𝒄)=ℬθ(𝒙|𝒄)βˆ’β„¬ΞΈref(𝒙|𝒄) is the difference in ELBO between the current and reference model.

Results.

LLaDA 2.0-flash (100B total, 6.1B active) achieves an overall average of 73.18 across 47 benchmarks, competitive with Qwen3-30B (73.60) and its AR base model Ling-flash-2.0 (72.15). Notable strengths include:

  • HumanEval: 94.51% (vs. 93.29% for Qwen3-30B)

  • MBPP: 88.29% (vs. 86.65% for Qwen3-30B)

  • AIME 2025: 60.00% (competitive with 61.88%)

Mercury: Ultra-Fast Commercial-Scale Diffusion

Mercury [8] from Inception Labs represents the first commercial-scale diffusion language model, designed for maximum throughput.

Architecture.

Mercury uses a standard Transformer architecture; the key difference is the training loss (diffusion denoising instead of next-token prediction) and the generation algorithm (iterative denoising instead of sequential sampling). The architecture choice is explicitly stated to be β€œorthogonal to the fact that Mercury models are diffusion-based.”

Key Speed Results.
ModelSpeed (tok/s)HumanEval
Mercury Coder Mini1,10988.0%
Mercury Coder Small73790.0%
Claude 3.5 Haiku6186.0%
GPT-4o Mini5988.0%
Gemini 2.0 Flash Lite20190.0%

Mercury Coder Mini is approximately 5–18Γ— faster than comparable models while maintaining competitive quality.

Why So Fast?

The fundamental advantage comes from the diffusion generation paradigm:

  1. Higher arithmetic intensity: Each denoising step processes many tokens in parallel, better saturating GPU compute units.

  2. Fewer total forward passes: Even with ∼10 denoising steps for 100 tokens, that is 10Γ— fewer forward passes than AR.

  3. Proprietary inference engine: Custom kernels optimized for parallel denoising workloads with dynamically batched sampling.

Theoretical Results

The theoretical understanding of discrete diffusion has advanced significantly alongside the empirical progress. We survey key results that provide convergence guarantees and illuminate the connections between discrete and continuous diffusion.

Convergence Bounds for Discrete Diffusion

Theorem 3 (Convergence via Uniformization, Chen et al. 2024 [9]).

For absorbing-state discrete diffusion with vocabulary size K and sequence length d, using the uniformization-based exact sampler (no discretization error): DKL(pdataβ€–p^)≀dβ‹…eβˆ’T+Tβ‹…Ο΅score, where T is the time horizon and Ο΅score is the score estimation error. Setting T=O(log⁑(d/Ο΅)) yields O(dlog⁑(d/Ο΅)Ο΅) expected computational steps.

Theorem 4 (Improved Convergence for Absorbing Diffusion, Liang et al. 2025 [10]).

For absorbing-state discrete diffusion with tau-leaping and early stopping, to achieve Ο΅-KL divergence, the required number of steps is: O~(dΟ΅)(linearΒ inΒ dimensionΒ d), improving upon O~(d2/Ο΅) for uniform-rate matrices. The absorbing structure enables tighter score bounds: for large t, the score decays as 1/t, reducing computational requirements.

Equivalence to All-Order Autoregressive

A remarkable theoretical result connects absorbing discrete diffusion to autoregressive modeling:

Theorem 5 (Ou et al. 2024 [2]).

For absorbing discrete diffusion in the continuous-time limit Tβ†’βˆž, the denoising cross-entropy loss is exactly the uniform average, over all L! generation orders, of the autoregressive negative log-likelihood in that order: β„’DCE∞(𝒙0)=π”ΌΟ€βˆΌUniform(SL)[βˆ’βˆ‘i=1Llog⁑pΞΈ(x0Ο€(i)|x0Ο€(1),…,x0Ο€(iβˆ’1))], where SL is the set of all permutations of {1,…,L}. Each ordering's term is itself an upper bound on βˆ’log⁑pΞΈ(𝒙0) when the network's conditionals are not chain-rule consistent, so β„’DCE∞(𝒙0)β‰₯βˆ’log⁑pΞΈ(𝒙0), with equality exactly when the predicted conditionals agree with one joint distribution.

Remark 19.

This reveals that absorbing discrete diffusion implicitly averages over all possible generation orders, providing a connection to order-agnostic autoregressive models like XLNet [11]. A standard left-to-right AR model uses a single ordering; the diffusion model uses all orderings.

Proof Sketch.

The key idea is a change of variables from continuous time to the masking probability Ξ»(t)=1βˆ’eβˆ’Οƒβ€Ύ(t)=1βˆ’Ξ±t. The continuous-time NELBO is: β„’=∫01𝔼q(𝒙t|𝒙0)[βˆ’Ξ±tβ€²1βˆ’Ξ±tβˆ‘β„“πŸ[xtβ„“=[ᴍᴀsα΄‹]]β‹…(βˆ’log⁑pΞΈ(x0β„“|𝒙t))]dt, where βˆ’Ξ±tβ€²/(1βˆ’Ξ±t)=Οƒβ€²(t)Ξ±t/(1βˆ’Ξ±t) under Ξ±t=eβˆ’Οƒβ€Ύ(t). Under the change of variables to Ξ»=1βˆ’Ξ±t, the integral over λ∈[0,1] can be decomposed combinatorially. At masking level Ξ», each subset S of positions is masked with probability: Pr⁑[maskedΒ positions=S]=Ξ»|S|(1βˆ’Ξ»)Lβˆ’|S|. Integrating over Ξ» from 0 to 1 and summing over all possible subsets S (with appropriate combinatorial weighting), the integral naturally decomposes into a sum over all L! permutations. For each permutation Ο€, the contribution is exactly the negative log-likelihood under the autoregressive factorization in order Ο€: ∫011Ξ»βˆ‘SβŠ†[L]Pr⁑[masked=S]βˆ‘β„“βˆˆS(βˆ’log⁑pΞΈ(x0β„“|𝒙0[L]βˆ–S))dΞ»=1L!βˆ‘Ο€βˆˆSLβˆ‘i=1Lβˆ’log⁑pΞΈ(x0Ο€(i)|𝒙0Ο€(<i)). The weight here is the diffusion weight 1/Ξ», and it is what makes the constant come out to exactly 1. Take any term with |S|=k. On the left it is integrated against Ξ»kβˆ’1(1βˆ’Ξ»)Lβˆ’k, giving the Beta integral ∫01Ξ»kβˆ’1(1βˆ’Ξ»)Lβˆ’kdΞ»=B(k,Lβˆ’k+1)=(kβˆ’1)!(Lβˆ’k)!L!. On the right, exactly (kβˆ’1)!(Lβˆ’k)! of the L! orderings charge that same term, namely those that place the kβˆ’1 other elements of S last in any order after position β„“, and the Lβˆ’k unmasked positions first in any order. The two coefficients agree term by term, so the identity holds with constant 1.

Example 4 (Two-token case).

Take L=2 over {A,B}2 with the joint p(AA)=0.48,p(AB)=0.12,p(BA)=0.16,p(BB)=0.24, and evaluate at 𝒙0=(A,A). The two orderings split the same total differently:

  • Ο€1=(1,2): βˆ’log⁑p(x1=A)=βˆ’log⁑0.60=0.5108, then βˆ’log⁑p(x2=A|x1=A)=βˆ’log⁑0.80=0.2231.

  • Ο€2=(2,1): βˆ’log⁑p(x2=A)=βˆ’log⁑0.64=0.4463, then βˆ’log⁑p(x1=A|x2=A)=βˆ’log⁑0.75=0.2877.

Each column sums to 0.7340=βˆ’log⁑0.48, so the average is βˆ’log⁑p(x1,x2). This is the chain rule, and it is a tautology whenever the conditionals come from one joint distribution.

The content of the theorem is what happens when they do not. A network predicts each conditional separately, and nothing forces pΞΈ(x1)pΞΈ(x2|x1) and pΞΈ(x2)pΞΈ(x1|x2) to agree. Charging the model the average price over every ordering is exactly the pressure that pulls those separately predicted conditionals towards a single consistent joint; by Jensen, the average is at least βˆ’log⁑pΞΈ(𝒙0), with equality only at consistency.

Parallels Between Discrete and Continuous Diffusion

The following table summarizes the deep mathematical parallels:

Continuous DiffusionDiscrete Diffusion
Fokker-Planck equationMaster equation
SDE: d𝒙=f(𝒙,t)dt+g(t)d𝐖CTMC with rate matrix 𝐑
Score: βˆ‡π’™log⁑pt(𝒙)Concrete score: pt(π’š)/pt(𝒙)
Fisher divergenceScore entropy
Denoising score matchingDenoising score entropy
Gaussian noise scheduleMasking probability schedule
Anderson's reverse SDEReverse CTMC
ItΓ΄ integral + GirsanovPoisson random measure + discrete Girsanov

DPO and Alignment for Diffusion Language Models

Aligning language models with human preferences is critical for safe and useful deployment. While RLHF and DPO are well-established for autoregressive models, adapting them to diffusion models poses unique challenges.

The Challenge: Intractable Log-Likelihood

Standard DPO requires computing the log-likelihood of responses under the model: β„’DPO=βˆ’π”Ό(𝒄,𝒙w,𝒙l)[log⁑σ(Ξ²[log⁑pΞΈ(𝒙w|𝒄)pref(𝒙w|𝒄)βˆ’log⁑pΞΈ(𝒙l|𝒄)pref(𝒙l|𝒄)])].

For autoregressive models, log⁑pΞΈ(𝒙|𝒄)=βˆ‘ilog⁑pΞΈ(xi|𝒙<i,𝒄) is tractable (just sum the per-token log-probabilities). For diffusion models, log⁑pΞΈ(𝒙) requires marginalizing over all possible denoising trajectories, which is generally intractable.

ELBO as a Surrogate

LLaDA 2.0 solves this by substituting the ELBO for the log-likelihood. The block diffusion ELBO provides a tractable lower bound: ℬBDLM(ΞΈ,𝒙|𝒄)=𝔼t,𝒙t[βˆ’Ξ±tβ€²1βˆ’Ξ±tβˆ‘kβˆ‘i𝟏[xt,ki=[ᴍᴀsα΄‹]]β‹…log⁑pΞΈ(xki|𝒄,𝒙<k,𝒙t,k)]. The weight is the positive wt=βˆ’Ξ±tβ€²/(1βˆ’Ξ±t) and each log⁑pθ≀0, so ℬBDLM≀0, as a bound on a log-likelihood must be. It is the negative of the loss β„’BDLM above, and a larger ℬ means a better fit, which is what makes the preference comparison below point the right way.

The diffusion DPO loss becomes: β„’DPO-diff(ΞΈ)=βˆ’π”Ό[log⁑σ(Ξ²[Δℬ(𝒙w|𝒄)βˆ’Ξ”β„¬(𝒙l|𝒄)])], where Δℬ(𝒙|𝒄)=ℬθ(𝒙|𝒄)βˆ’β„¬ΞΈref(𝒙|𝒄).

Remark 20.

The ELBO surrogate introduces a gap: we optimize a lower bound on the log-likelihood ratio rather than the ratio itself. In practice, this gap appears small; LLaDA 2.0 reports effective preference learning with Ξ²=0.1 and 1.5 million preference pairs. The theoretical justification is that for well-trained diffusion models, the ELBO is tight (close to the true log-likelihood).

Complementary Masking for Efficient DPO

Computing the ELBO requires estimating the loss over random masking patterns, which introduces variance. LLaDA 2.0's complementary masking technique is particularly valuable for DPO:

  • For each preference pair (𝒙w,𝒙l), generate a random mask π’Ž.

  • Compute the loss for both π’Ž and its complement π’Žβ€Ύ=1βˆ’π’Ž.

  • Average the two estimates.

Across the pair, every token is masked, and therefore supervised, exactly once, and appears as context exactly once. It is the supervision, not the context, that carries the variance: each token contributes exactly one loss term per pair instead of a random number of them, which is what stabilises the ELBO estimate and the DPO training built on it.

Complementary masking. Two antithetical masks are generated from a single random mask, ensuring every token appears unmasked in exactly one of the two instances. This reduces variance in ELBO estimation.

Putting It All Together: A Comparison

We conclude with a comprehensive comparison of the key models discussed in this chapter:

ModelYearParamsTypeKey Innovation
D3PM2021SmallGeneral discrete diffusionTransition matrices
SEDD2024110MScore-based discreteConcrete score
MDLM2024110MMasked diffusionRao-Blackwell simplification
LLaDA20258BLarge masked diffusionScaling to LLM size
LLaDA 2.0202516B/100BMoE masked diffusionAR-to-diffusion conversion
Mercury2025UndisclosedCommercial diffusionUltra-fast inference

Conclusion and Open Problems

Diffusion language models have progressed from a theoretical curiosity to competitive alternatives to autoregressive LLMs in just a few years. The key insight, that masking-based discrete diffusion is equivalent to weighted masked language modeling, provides both theoretical elegance and practical simplicity. Models like LLaDA, LLaDA 2.0, and Mercury have demonstrated that diffusion models can match AR models on benchmarks while offering unique advantages in parallelism, bidirectionality, and iterative refinement.

Open Problems.

  1. Closing the quality gap. While diffusion models are competitive, the largest AR models (GPT-4, Claude) still lead on the hardest reasoning and coding benchmarks. Can diffusion models close this gap?

  2. RLHF and alignment. DPO has been adapted for diffusion (via ELBO surrogates), but full RLHF with PPO remains unexplored. How should reward models interact with the iterative denoising process?

  3. Length generalization. Diffusion models require specifying the output length in advance. How can we make the output length adaptive without sacrificing the parallel generation advantage?

  4. Efficient attention for diffusion. The incompatibility with KV cache is a fundamental limitation. Can we design attention mechanisms that maintain bidirectionality while enabling incremental computation?

  5. Multimodal diffusion. Diffusion already excels at images. Can a single diffusion model handle both language and vision in a unified framework?

  6. Online / streaming generation. Autoregressive models naturally support streaming (tokens appear as they are generated). Diffusion models produce all tokens at once at the end. Can diffusion models support streaming via progressive unmasking with partial output?

  7. Reasoning with diffusion. The iterative refinement of diffusion is reminiscent of the β€œthink, draft, revise” process of reasoning. Can this be formalized into a chain-of-thought-like framework for diffusion models?

  8. Theoretical optimality. Is there a fundamental information-theoretic advantage to diffusion over autoregressive generation for certain distribution classes? Or are the advantages purely computational?

Remark 21.

The rapid progress in diffusion language models suggests that the β€œautoregressive monopoly” on language generation may be ending. Just as diffusion models disrupted the GAN-dominated image generation landscape, they may reshape the language modeling landscape, not by replacing autoregressive models entirely, but by offering a complementary paradigm with distinct strengths.

Continuous Diffusion Approaches for Text: What Went Wrong?

Before discrete diffusion models succeeded, several attempts were made to apply continuous diffusion to text. Understanding why these approaches fell short provides useful context.

Diffusion-LM

Diffusion-LM [25] operates by embedding each token into a continuous vector space and then applying standard Gaussian diffusion to the sequence of embeddings. The forward process adds Gaussian noise to the embeddings: q(𝒛t|𝒛0)=𝒩(𝒛t;Ξ±β€Ύt𝒛0,(1βˆ’Ξ±β€Ύt)𝐈), where 𝒛0=(Embed(x01),…,Embed(x0L))βˆˆβ„LΓ—d⁑ is the sequence of token embeddings.

The Rounding Problem.

After denoising, the continuous output 𝒛^0 must be mapped back to discrete tokens. Diffusion-LM uses a learned rounding function: x^i=arg minvβˆˆπ’±β‘β€–z^0iβˆ’Embed(v)β€–2. This nearest-neighbor rounding introduces errors because:

  1. Small errors in the continuous space can map to completely different tokens.

  2. The embedding space is high-dimensional, and nearest-neighbor search is noisy.

  3. Errors compound across the sequence, and each rounding error changes the context for other tokens.

Results.

On LM1B, Diffusion-LM achieved perplexity ≀118.62, dramatically worse than the discrete approaches (MDLM: ≀23.00). The continuous relaxation fundamentally loses the discrete structure of language.

DiffuSeq and Continuous Text Generation

DiffuSeq [26] applied continuous diffusion to sequence-to-sequence tasks (machine translation, summarization). While achieving reasonable results on these constrained tasks, it still suffered from the rounding problem and was significantly slower than autoregressive baselines.

Lessons Learned

The failure of continuous approaches and the success of discrete ones teach an important lesson:

Remark 22.

Respecting the discrete nature of language is essential. Unlike images, where pixel values have natural ordering and continuous interpolation is meaningful (a pixel value of 127.5 is between 127 and 128), language tokens have no such structure. The word β€œcat” has no meaningful β€œinterpolation” with β€œdog”. Discrete diffusion processes, particularly absorbing-state (masking) diffusion, naturally handle this by operating directly on the token space, never requiring continuous relaxation.

This lesson extends to other discrete domains. DNA sequences, protein sequences, and molecular graphs all benefit from discrete diffusion approaches rather than continuous relaxations. MDLM demonstrated competitive results on DNA modeling, confirming the broad applicability of the discrete framework.

Applications Beyond Standard Text Generation

Diffusion language models have unique properties that make them particularly well-suited for certain applications.

Code Generation and Completion

Code has natural β€œfill-in-the-middle” structure: developers often write function signatures and docstrings before implementations. Diffusion models excel at this because:

  • Bidirectional context: The model sees both the function signature (above) and the test cases (below) when filling in the implementation.

  • Iterative refinement: Complex code can be drafted and refined, allowing the model to ensure consistency across the implementation.

  • Native FIM: No special training is needed, as fill-in-the-middle is the natural operating mode.

Mercury Coder's strong performance on coding benchmarks (HumanEval: 90.0%, MBPP: 76.6% for Small variant) validates this advantage.

Controlled and Constrained Generation

Diffusion models naturally support constrained generation: fixing certain tokens and generating the rest. For example:

  • Template filling: Given a template β€œDear [NAME], Thank you for your [REASON]. We will [ACTION].” the diffusion model fills in the blanks using bidirectional context.

  • Lexically constrained generation: Requiring specific keywords to appear in the output can be enforced by initializing those tokens as unmasked.

  • Style transfer: Keeping content words fixed while regenerating function words can change the style of text while preserving meaning.

Constrained generation with diffusion language models. Fixed tokens (blue) are kept unmasked throughout the reverse process. The model generates the remaining tokens (green) using bidirectional context from both the fixed tokens and previously generated tokens.

Biological Sequence Design

MDLM has been applied to DNA sequence modeling with competitive results. The masking-based approach is natural for biological sequences because:

  • Biological sequences are discrete (nucleotides or amino acids).

  • The function of a position depends on both flanking regions (bidirectional context).

  • Protein engineering often involves fixing certain regions (e.g., active sites) while optimizing others, naturally expressed as constrained diffusion.

Machine Translation and Editing

Non-autoregressive translation (NAT) is a long-standing goal in machine translation. Diffusion models provide a principled framework for NAT:

  1. Encode the source sentence 𝒔 as context.

  2. Initialize the target as fully masked: 𝒓1=([ᴍᴀsα΄‹],…,[ᴍᴀsα΄‹]).

  3. Run the reverse diffusion process conditioned on 𝒔.

This allows the translation to be generated in parallel, with iterative refinement ensuring fluency and accuracy. The bidirectional context is particularly valuable for translation, where word order may differ between source and target languages.

Historical Timeline and Development

The development of diffusion language models has been remarkably rapid. We present a timeline highlighting the key milestones:

Timeline of key developments in diffusion models for language, from the thermodynamic formulation (Sohl-Dickstein et al., 2015) and DDPM (Ho et al., 2020), through the discrete foundations (D3PM, 2021) and simplified objectives (MDLM and SEDD, 2024), to large-scale competitive models (LLaDA and Mercury, 2025).

Exercises

Exercise 1 (Forward Process Statistics).

Consider a sequence of length L=100 with the linear masking schedule Ξ±t=1βˆ’t.

  1. What is the expected number of masked tokens at time t=0.3?

  2. What is the variance of the number of masked tokens at time t=0.3?

  3. What is the probability that at least 50 tokens are masked at t=0.3?

Hint: The number of masked tokens follows a Binomial distribution.

Exercise 2 (Reverse Posterior Verification).

Verify that the reverse posterior probabilities in equation and sum to 1. Then compute q(xtβˆ’1=x0|xt=[ᴍᴀsα΄‹],x0) for Ξ±t=0.5 and Ξ±tβˆ’1=0.6, and interpret the result.

Exercise 3 (Schedule Invariance).

Show that for the change of variables Ξ³=log⁑(1βˆ’Ξ±t), the differential element transforms as: βˆ’Ξ±tβ€²1βˆ’Ξ±tdt=dΞ³. Verify this for the linear schedule Ξ±t=1βˆ’t and the exponential schedule Ξ±t=eβˆ’Οƒt.

Exercise 4 (Comparing AR and Diffusion Inference Cost).

Consider generating L=1024 tokens with a dense Transformer of P parameters, stored in bf16. Count both the weight traffic and the arithmetic, since the ratio between them is what decides where the machine runs.

  1. An AR step with a KV cache reads all P weights (2P bytes) and does 2P FLOPs for the one new token. What is the arithmetic intensity of a single step, and why does it not depend on P?

  2. A diffusion step reads the same 2P bytes but does 2PL FLOPs, since it evaluates L positions in one pass. What is its arithmetic intensity?

  3. Total FLOPs for the whole sequence: 2PL for AR over L steps, and 2PLN for diffusion over N steps. Diffusion therefore does N times more arithmetic. Using the H100 figures from Section Arithmetic Intensity Analysis (3.35,TB/s and 989.5,TFLOP/s dense bf16, ridge at AI =295), estimate the wall-clock time of each on the appropriate roof, and find the largest N for which diffusion is still faster.

  4. Where does the argument break down as L grows, once the O(L2dmodel) attention term stops being negligible against 2PL?

Exercise 5 (Implementing MDLM Loss).

Write pseudocode (or actual code in your language of choice) for the MDLM training loss. Your implementation should:

  1. Sample a batch of sequences from the dataset.

  2. Sample a random time t for each sequence.

  3. Mask tokens independently with probability 1βˆ’Ξ±t.

  4. Forward pass through a bidirectional Transformer.

  5. Compute the 1/t-weighted cross-entropy loss over masked positions only.

Exercise 6 (SEDD Score Entropy).

Show that the score entropy loss is convex in sΞΈ and achieves its minimum when sΞΈ(𝒙,t)π’š=pt(π’š)/pt(𝒙) for all 𝒙,π’š.

Hint: Take the derivative with respect to sΞΈ(𝒙,t)π’š and set it to zero.

Exercise 7 (Block Diffusion Trade-offs).

Consider a sequence of length L=256 generated using block diffusion with block size B and N denoising steps per block.

  1. Express the total number of neural network forward passes as a function of B and N.

  2. What is the total for B=1 with N=1 (fully autoregressive)? For B=256 with N steps (a single diffused block)?

  3. Treating B as continuous, what block size minimizes the total forward passes if N=log⁑B? Which integer block sizes bracket that optimum?

Exercise 8 (Reversal Curse).

Explain mathematically why an autoregressive model trained with the factorization p(𝒙)=∏ip(xi|x<i) cannot guarantee that p(x1|x2) is well-modeled, even if p(x2|x1) is perfectly learned. Then explain why a masked diffusion model naturally avoids this issue.

Hint: Consider Bayes' theorem and what information the AR factorization provides about reverse conditionals.

Exercise 9 (Research: Designing a Better Remasking Strategy).

Propose a remasking strategy that goes beyond random and low-confidence remasking. Consider:

  1. Using the model's uncertainty (e.g., entropy of the predicted distribution) rather than just the maximum probability.

  2. Using positional information (e.g., remasking tokens that are far from already-confident tokens).

  3. Using a learned remasking policy trained to minimize the expected number of denoising steps.

Discuss the trade-offs of each approach.

References

  1. The reversal curse: LLMs trained on ``A is B'' fail to learn ``B is A''

    Lukas Berglund, Meg Tong, Max Kaufmann, Mikita Balesni, Asa Cooper Stickland, Tomasz Korbak, Owain Evans

    arXiv preprint arXiv:2309.12288 Β· 2023

    BibTeX
    @article{berglund2023reversal,
      title={The reversal curse: {LLMs} trained on ``{A} is {B}'' fail to learn ``{B} is {A}''},
      author={Berglund, Lukas and Tong, Meg and Kaufmann, Max and Balesni, Mikita and Stickland, Asa Cooper and Korbak, Tomasz and Evans, Owain},
      journal={arXiv preprint arXiv:2309.12288},
      year={2023}
    }

    Journal article

  2. Your absorbing discrete diffusion secretly models the conditional distributions of clean data

    Jingyang Ou, Shen Nie, others

    arXiv preprint arXiv:2406.03736 Β· 2024

    BibTeX
    @article{shi2024absorbing,
      title={Your absorbing discrete diffusion secretly models the conditional distributions of clean data},
      author={Ou, Jingyang and Nie, Shen and others},
      journal={arXiv preprint arXiv:2406.03736},
      year={2024}
    }

    Journal article

  3. BERT: Pre-training of deep bidirectional transformers for language understanding

    Jacob Devlin, Ming-Wei Chang, Kenton Lee, Kristina Toutanova

    Proceedings of NAACL-HLT, pp. 4171-4186 Β· 2019

    BibTeX
    @article{devlin2019bert,
      title={{BERT}: Pre-training of deep bidirectional transformers for language understanding},
      author={Devlin, Jacob and Chang, Ming-Wei and Lee, Kenton and Toutanova, Kristina},
      journal={Proceedings of NAACL-HLT},
      pages={4171--4186},
      year={2019}
    }

    Journal article

  4. MaskGIT: Masked generative image transformer

    Huiwen Chang, Han Zhang, Lu Jiang, Ce Liu, William T Freeman

    Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 11315-11325 Β· 2022

    BibTeX
    @article{chang2022maskgit,
      title={{MaskGIT}: Masked generative image transformer},
      author={Chang, Huiwen and Zhang, Han and Jiang, Lu and Liu, Ce and Freeman, William T},
      journal={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
      pages={11315--11325},
      year={2022}
    }

    Journal article

  5. Large language diffusion models

    Shen Nie, Fengqi Zhu, Zebin You, Xiaolu Zhang, Jingyang Ou, Jun Hu, Jun Zhou, Yankai Lin, et al.

    arXiv preprint arXiv:2502.09992 Β· 2025

    BibTeX
    @article{nie2025large,
      title={Large language diffusion models},
      author={Nie, Shen and Zhu, Fengqi and You, Zebin and Zhang, Xiaolu and Ou, Jingyang and Hu, Jun and Zhou, Jun and Lin, Yankai and Wen, Ji-Rong and Li, Chongxuan},
      journal={arXiv preprint arXiv:2502.09992},
      year={2025}
    }

    Journal article

  6. Block diffusion: Interpolating between autoregressive and diffusion language models

    Marianne Arriola, Aaron Gokaslan, Subham Sekhar Sahoo, Volodymyr Kuleshov

    arXiv preprint arXiv:2503.09573 Β· 2025

    BibTeX
    @article{arriola2024block,
      title={Block diffusion: Interpolating between autoregressive and diffusion language models},
      author={Arriola, Marianne and Gokaslan, Aaron and Sahoo, Subham Sekhar and Kuleshov, Volodymyr},
      journal={arXiv preprint arXiv:2503.09573},
      note={ICLR 2025},
      year={2025}
    }

    Journal article

  7. Variational Diffusion Models

    Diederik Kingma, Tim Salimans, Ben Poole, Jonathan Ho

    Advances in Neural Information Processing Systems, vol. 34, pp. 21696-21707 Β· 2021

    BibTeX
    @inproceedings{kingma2021variational,
      title={Variational Diffusion Models},
      author={Kingma, Diederik and Salimans, Tim and Poole, Ben and Ho, Jonathan},
      booktitle={Advances in Neural Information Processing Systems},
      volume={34},
      pages={21696--21707},
      year={2021}
    }

    Conference paper

  8. Mercury: Ultra-fast language models based on diffusion

    Samar Khanna, Siddhant Kharbanda, Shufan Li, Harshit Varma, Eric Wang, Sawyer Birnbaum, Ziyang Luo, Yanis Miraoui, et al.

    arXiv preprint arXiv:2506.17298 Β· 2025

    BibTeX
    @article{khanna2025mercury,
      title={Mercury: Ultra-fast language models based on diffusion},
      author={Khanna, Samar and Kharbanda, Siddhant and Li, Shufan and Varma, Harshit and Wang, Eric and Birnbaum, Sawyer and Luo, Ziyang and Miraoui, Yanis and Palrecha, Akash and Ermon, Stefano and Grover, Aditya and Kuleshov, Volodymyr},
      journal={arXiv preprint arXiv:2506.17298},
      year={2025}
    }

    Journal article

  9. How discrete and continuous diffusion meet: Comprehensive analysis of discrete diffusion models via a stochastic integral framework

    Yinuo Ren, Haoxuan Chen, others

    arXiv preprint arXiv:2410.03601 Β· 2024

    BibTeX
    @article{chen2024discrete,
      title={How discrete and continuous diffusion meet: Comprehensive analysis of discrete diffusion models via a stochastic integral framework},
      author={Ren, Yinuo and Chen, Haoxuan and others},
      journal={arXiv preprint arXiv:2410.03601},
      year={2024}
    }

    Journal article

  10. Absorb and Converge: Provable Convergence Guarantee for Absorbing Discrete Diffusion Models

    Yuchen Liang, Renxiang Huang, Lifeng Lai, Ness Shroff, Yingbin Liang

    arXiv preprint arXiv:2506.02318 Β· 2025

    BibTeX
    @article{liang2025absorb,
      title={Absorb and Converge: Provable Convergence Guarantee for Absorbing Discrete Diffusion Models},
      author={Liang, Yuchen and Huang, Renxiang and Lai, Lifeng and Shroff, Ness and Liang, Yingbin},
      journal={arXiv preprint arXiv:2506.02318},
      year={2025}
    }

    Journal article

  11. XLNet: Generalized autoregressive pretraining for language understanding

    Zhilin Yang, Zihang Dai, Yiming Yang, Jaime Carbonell, Ruslan R Salakhutdinov, Quoc V Le

    Advances in Neural Information Processing Systems, vol. 32 Β· 2019

    BibTeX
    @article{yang2019xlnet,
      title={{XLNet}: Generalized autoregressive pretraining for language understanding},
      author={Yang, Zhilin and Dai, Zihang and Yang, Yiming and Carbonell, Jaime and Salakhutdinov, Ruslan R and Le, Quoc V},
      journal={Advances in Neural Information Processing Systems},
      volume={32},
      year={2019}
    }

    Journal article

  12. Language Models are Unsupervised Multitask Learners

    Alec Radford, Jeff Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever

    OpenAI Β· 2019

    BibTeX
    @techreport{radford2019language,
      title={Language Models are Unsupervised Multitask Learners},
      author={Radford, Alec and Wu, Jeff and Child, Rewon and Luan, David and Amodei, Dario and Sutskever, Ilya},
      institution={OpenAI},
      year={2019}
    }

    Technical report

  13. LLaMA: Open and Efficient Foundation Language Models

    Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, others

    arXiv preprint arXiv:2302.13971 Β· 2023

    BibTeX
    @article{touvron2023llama,
      author    = {Touvron, Hugo and Lavril, Thibaut and Izacard, Gautier and Martinet, Xavier and Lachaux, Marie-Anne and others},
      title     = {{LLaMA}: Open and Efficient Foundation Language Models},
      journal   = {arXiv preprint arXiv:2302.13971},
      year      = {2023}
    }

    Journal article

  14. Denoising Diffusion Probabilistic Models

    Jonathan Ho, Ajay Jain, Pieter Abbeel

    Advances in Neural Information Processing Systems, vol. 33, pp. 6840-6851 Β· 2020

    BibTeX
    @inproceedings{ho2020denoising,
      title={Denoising Diffusion Probabilistic Models},
      author={Ho, Jonathan and Jain, Ajay and Abbeel, Pieter},
      booktitle={Advances in Neural Information Processing Systems},
      volume={33},
      pages={6840--6851},
      year={2020}
    }

    Conference paper

  15. High-resolution image synthesis with latent diffusion models

    Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, Bjorn Ommer

    Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10684-10695 Β· 2022

    BibTeX
    @article{rombach2022high,
      title={High-resolution image synthesis with latent diffusion models},
      author={Rombach, Robin and Blattmann, Andreas and Lorenz, Dominik and Esser, Patrick and Ommer, Bj{\"o}rn},
      journal={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
      pages={10684--10695},
      year={2022}
    }

    Journal article

  16. Hierarchical text-conditional image generation with CLIP latents

    Aditya Ramesh, Prafulla Dhariwal, Alex Nichol, Casey Chu, Mark Chen

    arXiv preprint arXiv:2204.06125 Β· 2022

    BibTeX
    @article{ramesh2022hierarchical,
      title={Hierarchical text-conditional image generation with {CLIP} latents},
      author={Ramesh, Aditya and Dhariwal, Prafulla and Nichol, Alex and Chu, Casey and Chen, Mark},
      journal={arXiv preprint arXiv:2204.06125},
      year={2022}
    }

    Journal article

  17. Structured denoising diffusion models in discrete state-spaces

    Jacob Austin, Daniel D Johnson, Jonathan Ho, Daniel Tarlow, Rianne van den Berg

    Advances in Neural Information Processing Systems, vol. 34, pp. 17981-17993 Β· 2021

    BibTeX
    @article{austin2021structured,
      title={Structured denoising diffusion models in discrete state-spaces},
      author={Austin, Jacob and Johnson, Daniel D and Ho, Jonathan and Tarlow, Daniel and van den Berg, Rianne},
      journal={Advances in Neural Information Processing Systems},
      volume={34},
      pages={17981--17993},
      year={2021}
    }

    Journal article

  18. Simple and effective masked diffusion language models

    Subham Sekhar Sahoo, Marianne Arriola, Yair Schiff, Aaron Gokaslan, Edgar Marroquin, Justin T Chiu, Alexander Rush, Volodymyr Kuleshov

    Advances in Neural Information Processing Systems, vol. 37 Β· 2024

    BibTeX
    @article{sahoo2024simple,
      title={Simple and effective masked diffusion language models},
      author={Sahoo, Subham Sekhar and Arriola, Marianne and Schiff, Yair and Gokaslan, Aaron and Marroquin, Edgar and Chiu, Justin T and Rush, Alexander and Kuleshov, Volodymyr},
      journal={Advances in Neural Information Processing Systems},
      volume={37},
      year={2024}
    }

    Journal article

  19. Discrete diffusion modeling by estimating the ratios of the data distribution

    Aaron Lou, Chenlin Meng, Stefano Ermon

    Proceedings of the International Conference on Machine Learning Β· 2024

    BibTeX
    @article{lou2024discrete,
      title={Discrete diffusion modeling by estimating the ratios of the data distribution},
      author={Lou, Aaron and Meng, Chenlin and Ermon, Stefano},
      journal={Proceedings of the International Conference on Machine Learning},
      year={2024}
    }

    Journal article

  20. LLaDA 2.0: Scaling up diffusion language models to 100B

    Tiwei Bie, Maosong Cao, Kun Chen, Lun Du, others

    arXiv preprint arXiv:2512.15745 Β· 2025

    BibTeX
    @article{llada2,
      title={{LLaDA} 2.0: Scaling up diffusion language models to 100B},
      author={Bie, Tiwei and Cao, Maosong and Chen, Kun and Du, Lun and others},
      journal={arXiv preprint arXiv:2512.15745},
      year={2025}
    }

    Journal article

  21. The Neural Autoregressive Distribution Estimator

    Hugo Larochelle, Iain Murray

    Proceedings of the 14th International Conference on Artificial Intelligence and Statistics (AISTATS) Β· 2011

    BibTeX
    @inproceedings{larochelle2011neural,
      title={The Neural Autoregressive Distribution Estimator},
      author={Larochelle, Hugo and Murray, Iain},
      booktitle={Proceedings of the 14th International Conference on Artificial Intelligence and Statistics (AISTATS)},
      year={2011}
    }

    Conference paper

  22. MADE: Masked Autoencoder for Distribution Estimation

    Mathieu Germain, Karol Gregor, Iain Murray, Hugo Larochelle

    Proceedings of the 32nd International Conference on Machine Learning (ICML) Β· 2015

    BibTeX
    @inproceedings{germain2015made,
      title={{MADE}: Masked Autoencoder for Distribution Estimation},
      author={Germain, Mathieu and Gregor, Karol and Murray, Iain and Larochelle, Hugo},
      booktitle={Proceedings of the 32nd International Conference on Machine Learning (ICML)},
      year={2015}
    }

    Conference paper

  23. Pixel Recurrent Neural Networks

    Aaron van den Oord, Nal Kalchbrenner, Koray Kavukcuoglu

    Proceedings of the 33rd International Conference on Machine Learning (ICML) Β· 2016

    BibTeX
    @inproceedings{oord2016pixel,
      title={Pixel Recurrent Neural Networks},
      author={van den Oord, A\"{a}ron and Kalchbrenner, Nal and Kavukcuoglu, Koray},
      booktitle={Proceedings of the 33rd International Conference on Machine Learning (ICML)},
      year={2016}
    }

    Conference paper

  24. Conditional Image Generation with PixelCNN Decoders

    Aaron van den Oord, Nal Kalchbrenner, Lasse Espeholt, Koray Kavukcuoglu, Oriol Vinyals, Alex Graves

    Advances in Neural Information Processing Systems (NeurIPS) Β· 2016

    BibTeX
    @inproceedings{oord2016conditional,
      title={Conditional Image Generation with {PixelCNN} Decoders},
      author={van den Oord, A\"{a}ron and Kalchbrenner, Nal and Espeholt, Lasse and Kavukcuoglu, Koray and Vinyals, Oriol and Graves, Alex},
      booktitle={Advances in Neural Information Processing Systems (NeurIPS)},
      year={2016}
    }

    Conference paper

  25. Diffusion-LM improves controllable text generation

    Xiang Lisa Li, John Thickstun, Ishaan Gulrajani, Percy Liang, Tatsunori B Hashimoto

    Advances in Neural Information Processing Systems, vol. 35, pp. 4328-4343 Β· 2022

    BibTeX
    @article{li2022diffusion,
      title={Diffusion-{LM} improves controllable text generation},
      author={Li, Xiang Lisa and Thickstun, John and Gulrajani, Ishaan and Liang, Percy and Hashimoto, Tatsunori B},
      journal={Advances in Neural Information Processing Systems},
      volume={35},
      pages={4328--4343},
      year={2022}
    }

    Journal article

  26. Diffuseq: Sequence to sequence text generation with diffusion models

    Shansan Gong, Mukai Li, Jiangtao Feng, Zhiyong Wu, Lingpeng Kong

    Proceedings of the International Conference on Learning Representations Β· 2023

    BibTeX
    @article{gong2023diffuseq,
      title={Diffuseq: Sequence to sequence text generation with diffusion models},
      author={Gong, Shansan and Li, Mukai and Feng, Jiangtao and Wu, Zhiyong and Kong, Lingpeng},
      journal={Proceedings of the International Conference on Learning Representations},
      year={2023}
    }

    Journal article

  27. A continuous time framework for discrete denoising models

    Andrew Campbell, Joe Benton, Valentin De Bortoli, Tom Rainforth, George Deligiannidis, Arnaud Doucet

    Advances in Neural Information Processing Systems, vol. 35 Β· 2022

    BibTeX
    @article{campbell2022continuous,
      title={A continuous time framework for discrete denoising models},
      author={Campbell, Andrew and Benton, Joe and De Bortoli, Valentin and Rainforth, Tom and Deligiannidis, George and Doucet, Arnaud},
      journal={Advances in Neural Information Processing Systems},
      volume={35},
      year={2022}
    }

    Journal article

  28. Improved Denoising Diffusion Probabilistic Models

    Alexander Quinn Nichol, Prafulla Dhariwal

    International Conference on Machine Learning, pp. 8162-8171 Β· 2021

    BibTeX
    @inproceedings{nichol2021improved,
      title={Improved Denoising Diffusion Probabilistic Models},
      author={Nichol, Alexander Quinn and Dhariwal, Prafulla},
      booktitle={International Conference on Machine Learning},
      pages={8162--8171},
      year={2021},
      organization={PMLR}
    }

    Conference paper

  29. Classifier-free diffusion guidance

    Jonathan Ho, Tim Salimans

    arXiv preprint arXiv:2207.12598 Β· 2022

    BibTeX
    @article{ho2022classifier,
      title={Classifier-free diffusion guidance},
      author={Ho, Jonathan and Salimans, Tim},
      journal={arXiv preprint arXiv:2207.12598},
      year={2022}
    }

    Journal article