S=VS space of all possible sequences of length S over the vocabulary
x=x1…xS sequence of S tokens, where each token xi takes values in V
ev one-hot vector in R∣V∣ for token v∈V
m mask token
x=i sub-sequence of x at all positions except i
Δk for k∈N, Δk={π∈R+k:∑ℓ=1kπℓ=1} is the probability simplex
Cat categorical distribution: x∼Cat(p) means P(x=v)=pv, for a probability vector p∈Δ∣V∣
Convention: t=0: clean data; t=1: noisy data.
p0 clean data (target) distribution; the forward process corrupts it toward the mask distribution δm…m at the final time
pt marginal distribution at time t; the probability path between the clean data distribution p0 and the mask distribution
βt noise schedule: probability that a token is corrupted (masked) at step t
αt=∏i=1t(1−βi) cumulative schedule, equal to the probability that a token is still clean (has survived) at step t
Dθ,t(xt)∈Δ∣V∣ learned denoiser: predicts the distribution over the clean token x0 given the noisy sequence xt
Q˙t forward rate matrix (generator of the continuous-time forward process)
R˙θ,t learned reverse rate matrix (generator of the continuous-time reverse process)
In recent years, diffusion models have emerged as the state-of-the-art frameworks for continuous data generation, enabling the synthesis of high-quality data, such as images, audio and video [7, 8].
Their strong generation performance, training stability and flexibility motivated their extension to discrete data, including texts, graphs, or molecule sequences [2, 5, 6].
This blog post is a pedagogical introduction to the adaptation of diffusion models for discrete data.
As continuous-space diffusion models have been developed into two major branches, namely the variational [10, 11] and the score-based ones [9, 12], we present discrete diffusion through these two formalisms.
We first introduce variational discrete diffusion; the reader already familiar with this technique can jump directly to the score-based perspective.
Finally, in the last section, we first show how these two different viewpoints are in fact equivalent from both the training and sampling perspectives, then show the equivalence of discrete diffusion and discrete flow matching.
In this blog post, we deal with discrete data: the space on which the probability distributions are defined is S:=VS, namely the space of sequences of length S∈N over a given vocabulary V.
A sequence x in S is denoted as x=x1…xS, the xi‘s being called tokens.
In the vocabulary, we add a special token: the mask token, denoted as m.
The reader interested to have a more complete introduction on discrete data modelling is referred to the blog post on discrete flow matching.
Variational discrete diffusion
Continuous-space diffusion models learn to generate data, e.g. images, by reversing a forward process that gradually corrupts data into pure noise through the addition of Gaussian noise.
In discrete diffusion, an analogous approach generates sequences by reversing a masking process that progressively replaces tokens with a mask token.
Figure 1: Analogy between continuous- and discrete-space diffusion.
Left: the forward process corrupts a clean image by iteratively adding Gaussian noise, so the image gradually becomes pure noise. Given the current noisy image, the reverse model predicts the clean image that could have generated it, and uses this prediction to take one denoising step.
Right: the forward process masks tokens in a sentence, until the sequence is fully masked. Given a current partially masked sentence, the reverse model predicts a probability distribution over the clean sentences that could have generated it, and uses this prediction to unmask some tokens.
Forward process
We first consider the forward process: it starts from a clean sequence x0, and progressively replaces each token by the mask token, transforming the sequence into xT=mm...m.
Because each token is masked independently, the forward process factorizes over tokens, and we restrict to the case of a single token transitioning from x0i to m in the following.
In continuous Denoising Diffusion Probabilistic Models (DDPM), we start by defining a noising process over T steps, where each step slightly corrupts the signal by adding Gaussian noise:
xt=1−βtxt−1+βtε,ε∼N(0,I)
where βt∈[0,1] controls the amount of noise injected at step t∈{1,…,T}.
In discrete space diffusion, at each step, a token either survives unchanged with probability 1−βt, or is irreversibly replaced by the mask token m with probability βt:
xt={xt−1,m,with probability 1−βtwith probability βt
From Eq. (?), we can infer the law of xt given its starting value x0, without simulating the full chain:
q(xt=x0∣x0)=i=1∏t(1−βi)=:αt
and we can interpret αt as the probability that a token has survived up to step t, i.e. xt is still x0 and was not replaced by m.
Proof
q(xt=x0∣x0)==q(xt=x0∣xt−1=x0) by the Markov propertyq(xt=x0∣xt−1=x0,x0)q(xt−1=x0∣x0)=(1−βt)q(xt−1=x0∣x0)=i=1∏t(1−βi)by recursion
As expected, the schedule αt decreases in t: as the step index t increases, the probability of a token remaining unmasked decreases.
You can observe this trend in Figure 1 when selecting “Show N trajectories”.
It turns out that we can then compute the transition probabilities between any two steps s<t as follows:
xt∣xs={xs,m,with probability αsαtwith probability 1−αsαtProof
By the Markov property q(xt∣xs,x0)=q(xt∣xs), the marginal q(xt∣x0) factorizes through any intermediate step s:
q(xt∣x0)=xs∑q(xt∣xs)q(xs∣x0)
Using q(xs∣x0)=αsI(xs=x0)+(1−αs)I(xs=m), the sum simplifies to:
Since masking is irreversible, q(xt∣xs=m)=I(xt=m).
Writing q(xt∣xs=x0)=aI(xt=x0)+(1−a)I(xt=m), for xt=x0, Eq. (?) becomes: αt=αs⋅a, so a=αsαt
Therefore, for an unmasked token xs=m (since the probabilities sum to 1):
Figure 2: Forward process with T steps as in Eq. (?). At step t, an unmasked token gets masked with probability βt; after masking, this probability is 1. The trajectories are stochastic: changing the seed changes the step at which x0 transitions to m.
The “Show N trajectories” button switches to an aggregate view that samples N independent trajectories with the same transition rule; at step t, the plotted proportion of still-unmasked trajectories approaches the schedule αt as T and N grow.
In summary, the forward process masks each token independently and irreversibly: a token remains unmasked until time t with probability αt, and once it reaches the mask state m, it stays masked.
The user-defined schedule αt therefore controls how quickly clean data is transformed into pure mask noise.
We now turn to reversing this process, in order to generate data from noise.
Reverse process
Generating data requires a reverse process that progressively unmasks tokens to produce samples from the discrete data distribution, i.e. generating samples xs from xt for s<t until s=0.
However, the transition kernel q(xs∣xt) is intractable.
To overcome this difficulty, we express q(xs∣xt) by marginalizing the conditional reverse transition q(xs∣xt,x0) over all possible x0.
We conclude using that xs is either at state x0 or at state m with probabilities that sum to 1.
The reverse process conditioned on x0, namely sampling reccursively from q(xs∣xt,x0) as described in Eq. (?), can also be simulated in Figure 2 by clicking the reverse button.
When a token is already unmasked, the reverse process simply keeps it fixed.
Training
We learn the reverse process by training a neural network whose generated trajectories align with those of the forward process.
In Variational Diffusion, this is done by minimizing the KL divergence between the distribution induced by the (known) forward process q(x0:T) and the one induced by the learned backward process pθ(x0:T):
Since H(q)=−Eq(x0)[logq(x0)] does not depend on θ, minimizing
the KL is exactly equivalent to maximizing Eq(x0)[ELBOθ(x0)].
As written, Eq. (?) couples all T steps along a whole trajectory x1:T. The following theorem shows that we can simplify this global objective into a sum of local objectives, one for each step.
Theorem 3 (Discrete diffusion ELBO).
The ELBO for a discrete diffusion process is given by [1, 2, 10]:
where the first KL term is a constant independent of θ, since pθ(xT)=pT is a fixed base distribution.
The sum of KL terms corresponds to a forward trajectory where x0,x1,…,xT is sampled from the noising process, and at each step the learned reverse transition pθ(xt−1∣xt) is trained to match the reverse transition conditioned on the initial clean token x0: q(xt−1∣xt,x0).
To sample from the data, we therefore need to learn the transitions pθ(xt−1∣xt).
However, the discrete diffusion models of [1, 2] prefer to follow the key innovation of DDPM [11] instead: predict the clean signal x0 and rebuild the reverse step using q(xt−1∣xt,x0).
Here, we use Eq. (?), which combines this term with the denoiser P(X0=v∣Xt=xt) to weight each possible clean token.
Since this denoiser is itself intractable, we approximate it by a learned denoiser Dθ,t(xt)∈Δ∣V∣..
This definition naturally extends to each position i if we consider sequences: [Dθ,ti(xt)]v≈P(X0i=v∣Xt=xt).
The following proposition rewrites the ELBO term entirely in terms of this denoiser.
Proposition 4 (Masked diffusion training loss).
In the specific case of Masked Diffusion, we can express the loss in terms of the denoiser output Dθ,t(xt)=(Dθ,t1(xt),…,Dθ,tS(xt))∈Δ∣V∣S, where t∼Unif{1,…,T}:
A drawback of the discrete-time construction presented in this section is that the loss Eq. (?) only evaluates the denoiser Dθ,t at the T grid times t∈{1,…,T}, so it learns to undo the noise at the levels α1,…,αT and no others. Refining the schedule αt at sampling time places new levels between the trained ones, where the denoiser must be evaluated at a noise level it never saw. Avoiding this mismatch ties us to the fixed grid α1,…,αT. To remove this constraint, [3] introduced the continuous-time limit of these models (later simplified for masked diffusion by [13]): training over t∼U(0,1) exposes the denoiser to every noise level, so the number of steps and the schedule become choices made after training rather than before.
In order to provide a continuous-time version of the loss Eq. (?), we first need define a continuous-time analogue of the survival schedule αt=i=1∏t(1−βi), and give an intuition for its form.
Introduce a continuous masking-rate function β:[0,1]→R+. We normalize the discrete steps 0,1,…,T to the continuous grid 0,1/T,…,1 and define the step size Δt=1/T. The corresponding masking probability at grid point i/T is
βi:=β(i/T)Δt=T1β(Ti).
For a continuous time t∈[0,1], write n=⌊Tt⌋. The discrete survival probability becomes
This motivates the continuous-time survival schedule
αt=exp(−∫0tβ(s)ds).
We deduce the following properties on αt from the derivation above:
α0=1: at time t=0, all tokens are unmasked.
α1=0: at time t=1, all tokens are masked.
αt is decreasing in t: as the step index increases, the probability of a token remaining unmasked decreases.
Now we want to express the continuous-time limit of denoiser loss Eq. (?). We normalize the timsteps in [0,1] and therefore define the grid τn=n/T, Δt=1/T, with αn=ατn and τn−1=τn−Δt.
To wrap up, we end this section with a table summarizing the important steps in variational masked discrete diffusion, put in parallel with their equivalent for continuous space diffusion (DDPM).
Table 3: Continuous-space diffusion and masked discrete diffusion side by side.
Continuous-space diffusion
Masked discrete diffusion
1. Final distribution after noising
xT∼N(0,I)
xT∼δm…m
2. Local view of the forward process
Markov chain with T steps, t∈{1,…,T}, and variance/noise schedule βt.
In this section, we study the score-based perspective on discrete diffusion.
The main idea is to learn a transport guided by the score functionst(xt) to reverse the diffusion process.
This quantity points toward more likely samples at noise level t, guiding the generation process back toward the data distribution.
In continuous-space diffusion models, the generation process, i.e. the backward process, is defined by the reverse SDE (see Figure 1, bottom); critically, the reverse SDE involves the score, namely ∇xlogpt(xt), where pt is the distribution of the variables xt defined by the forward process.
We follow the same approach in discrete space.
Since there is no SDE involved here, we work with the first-order expansion of q(xt+Δt∣xt) as Δt→0, which plays the role of dxt in the forward SDE, i.e. describing the evolution of xt during the corruption process.
Then we reverse the process to obtain p(xt−Δt∣xt) and identify the concrete scorest(xt)y, the discrete analogue of ∇xlogpt(xt) (the score function of the continuous process).
Finally, we learn a neural network to predict the concrete score and use it to generate new discrete data.
Figure 4: Analogy between continuous-space and discrete-space score-based diffusion. In continuous space, Euler sampling with five steps discretizes the continuous-time SDE: in the forward direction, the drift and Gaussian increments add noise to the sample; in the reverse direction, the learned score changes the drift so that noise is removed. In discrete space, the same idea becomes an Euler sampler built from the local continuous-time transition rates: the forward rates move probability mass toward noisier categorical states, while the learned reverse rates move probability mass back toward cleaner states.
Forward process
In continuous-space score-based diffusion, we model the forward process as the solution of the SDE dxt=ft(xt)dt+gtdWt, where we fix the drift ft and the diffusion coefficient gt, and Wt is a Wiener process.
We follow a similar approach in discrete space: we model the forward process as a continuous-time Markov chain (CTMC), which can be written as
where we choose the forward rate matrix Q˙t∈R∣V∣×∣V∣.
In the above equation and in what follows, [Q˙t(xt)]y denotes the entry of Q˙t at row xt and column y.
For continuous-space diffusion models, the forward SDE means that over an infinitesimal time dt, a particle at xt moves by a deterministic drift ft(xt)dt plus an independent Gaussian increment of standard deviation gtdt. Here, [Q˙t(xt)]y is the instantaneous rate at which a particle at state xt jumps to state y: over a small interval Δt, the probability of such a jump is [Q˙t(xt)]yΔt to first order.
Then, we need to specify the forward rate matrix Q˙t that governs the masking process.
A simple choice is to set the rate of transition from any unmasked token to the mask state:
where σ(t)>0 is the instantaneous masking rate, em is the one-hot vector for the mask token.
The last column of Q˙t indicates that the rates for jumping to m are equal to σ(t) for any token xt∈V∖{m}, and the last row indicates that the rate for jumping from m to any other state is 0 (the mask is an absorbing state).
Continuous-space diffusion models benefits from simulation-free forward processes, which mean we can directly sample xt given x0 without having to simulate the process step by step, simply using the closed-form expression q(xt∣x0)=N(xt;αtx0,(1−αt)I), where αt=exp(−∫0tβ(s)ds) is the cumulative noise schedule.
The same thing is possible in discrete space, we can define the transition matrix from time 0 to time t, denoted Qˉt∣0, such that q(xt∣x0)=Cat(xt;Qˉt∣0⊤x0).
Denoting αt=exp(−∫0tσ(s)ds) the cumulative masking schedule, we have that Qˉt∣0 takes the following form:
In the continuous-time limit, each local transition is Qˉt+Δt∣t=I+Q˙tΔt+o(Δt), so this product becomes the exponential of the accumulated local rates. Let A=1em⊤−I. Since Q˙t=σ(t)A has a fixed matrix direction for all t, this integration reduces to an ordinary matrix exponential:
Figure 5: Euler simulation of the forward process Eq. (?), with absorbing generator Eq. (?). At time t, an unmasked token gets masked with probability σ(t)Δt=−αtα˙tΔt, where Δt=1/T; after masking, this probability is 1. The trajectories are stochastic: changing the seed changes the step at which x0 transitions to m.
The “Show N trajectories” button switches to an aggregate view that samples N independent trajectories with the same transition rule; as T and N grow, the plotted fraction still unmasked approaches the schedule αt.
Reverse process
In the previous section, we have described the forward process of score-based discrete diffusion models. To generate new data samples, we need to reverse the forward process.
Similarly to continuous-space diffusion, where the reverse process is obtained by reversing the forward SDE, in discrete space, the reverse process is obtained by reversing the forward Markov chain, and is also a continuous-time Markov chain.
Proposition 5 (Reverse process).
Interestingly, the reverse process is also a continuous-time Markov chain, and its transition probabilities can be expressed as:
By identifying this result with the definition of the reverse local transition p(xt−Δt=y∣xt)=Δt[R˙t(xt)]y+o(Δt), we conclude for y=xt.
For y=xt, we use the fact that probabilities sum to one, so the rows of a valid transition rate matrix must sum to zero, leading to [R˙t(xt)]xt=−∑y′=xt[R˙t(xt)]y′.
In continuous-space diffusion, the score function ∇xlogpt(xt) governs the reverse SDE, i.e. the generative process.
In the discrete space, the analog to the score function is the concrete scorest(xt)y, defined as the ratio of marginal probabilities between a candidate destination state and the current state:
st(xt)y=q(Xt=xt)q(Xt=y)(y=xt).
Recalling Eq. (?), the concrete score is precisely the quantity that converts the (known) forward rate Q˙t into the reverse rate R˙t:
st(xt)y=[Q˙t(xt)]y[R˙t(xt)]y.
Then the reverse process can be simulated using the concrete score as follows:
where ⊙ denotes the elementwise product. The forward rate Q˙t is known because it is a design choice of the noising process.
However, the concrete score st(xt)y (or equivalently the reverse rate R˙t) depends on the noisy-data marginals q(Xt=⋅) which are unknown and untractable.
This is why, in practice, we learn a neural approximation of it, denoted by sθ,t(xt)y.
See the reverse process conditioned on x0, where the unknown st(xt) is replaced by the known st(xt∣x0) in Figure 5 by clicking the reverse button.
Training
In the forward and reverse process sections, we showed how these processes can be simulated with respectively the forward rate Q˙tEq. (?) and the reverse rate R˙tEq. (?), and that the unknown quantity connecting them is the concrete score st(xt)yEq. (?).
However, this last is untractable and therefore we need to rewrite it before approximating it with a neural network sθ,t. To do so, we apply the marginalisation trick, meaning we express the concrete score st(xt)y as a conditional expectation of the conditional concrete score st(xt∣x0)y over x0:
By weighting each term by the forward rate [Q˙t(xt)]y (which leaves the minimizer unchanged), we can derived a new loss function to train the concrete score approximation sθ,t:
To wrap up, we end this section with a table summarizing the important steps in score-based diffusion, put in parallel with their equivalent for continuous-space diffusion.
Table 6: Continuous-space and masked discrete score-based diffusion side by side.
In the previous sections, we introduced two discrete diffusion perspectives for transporting an initial distribution to a target discrete distribution: the variational formulation and the score-based formulation.
In all this section, we assume the fully corrupted distribution is δm…m
We will show with this assumption that these two viewpoints are equivalent, and then we connect them to discrete flow matching.
Equivalence between the two discrete diffusion perspectives
In this section, we demonstrate that variational inference and score matching viewpoints for discrete diffusion are equivalent. We first show that their sampling schemes coincide, and then that their training objectives are equivalent.
Sampling: We first connect the two views of discrete diffusion at the sampling level. The key idea is that the reverse rate R˙t for score-based discrete diffusion can be written in terms of the denoiser Dti(x)v=P(X0i=v∣Xt=x):
Comparing with the continuous-time reverse-rate definition:
P(Xt−hi=v∣Xt=x)=I(v=xi)+hR˙ti(x)v+o(h),
and using xi=m gives Eq. (?). If xi=m, the token is already unmasked and the reverse masked process leaves it fixed, so the rate is zero; this gives the prefactor I(xi=m).
It remains to connect Eq. (?) and Eq. (?). Starting from Eq. (?), taking s=t−h and letting h→0, for a masked token xti=m:
using αt−h−αt=−hα˙t+o(h) in the second line and Eq. (?) in the third line.
If xti=m, both sampling processes keep the token fixed, i.e., once denoised, a token cannot be masked again or change token value.
Training Objectives: Now we turn to the corresponding training objectives. The variational perspective gives the ELBO loss Eq. (?) (which can be rewritten as Eq. (?) for Masked Diffusion), while the score-based perspective gives the concrete score matching loss Eq. (?).
We now show that these two objectives are in fact the same: taking the continuous-time limit of the ELBO produces, after a change of variable, exactly the concrete score matching loss Eq. (?).
Starting from the variational loss Eq. (?), in the continuous-time limit T→∞, each discrete transition q(xs∣xt) is replaced by an instantaneous rate R˙t(xt). This motivates introducing the conditional reverse rate R˙t(xt∣x0), defined by the first-order Taylor expansion:
where rt=−α˙t/(1−αt) is the instantaneous unmasking rate, and the entry rt in the last row appears at the column index corresponding to x0. Intuitively, this rate captures the instantaneous tendency of a masked token to revert to the clean token x0.
Construction of R˙t(xt∣x0)
To derive R˙t(xt∣x0), we write the reverse transition probabilities q(xs∣xt,x0) for arbitrary s<t using a matrix Rs∣tx0, and then write the first-order Taylor expansion as Δt=t−s→0 of this matrix.
Using Eq. (?), the reverse transition q(xs∣xt,x0) can be written as a categorical distribution governed by a reverse matrix Rs∣tx0:
where the entry 1−αtαs−αt in the last row appears at the column corresponding to x0, and can be compactly written as Rs∣tx0=I+1−αtαs−αtem(ex0−em)⊤.
Taking the first-order Taylor expansion (noting that αt−Δt−αt≈−α˙tΔt):
The first term is independent of θ, so we focus on the KL terms inside the sum. Let Δt=1/T, t=j/T, and s=(j−1)/T. Using Eq. (?) and the learned analogue of Eq. (?), the j-th KL [KL(q(x(j−1)/T∣xj/T,x0),pθ(x(j−1)/T∣xj/T))] expands over the vocabulary as:
KL=Δty=xt∑([R˙θ,t(xt)]y−[R˙t(xt∣x0)]ylog[R˙θ,t(xt)]y+ independent of θ[R˙t(xt∣x0)]ylog[R˙t(xt∣x0)]y−[R˙t(xt∣x0)]y)+o(Δt).
Writing tt=j/T and Δt=1/T, the ELBO Eq. (?) is therefore (grouping the θ-independent above and KL(q(x1∣x0),pT) into a constant C):
where C collects the terms independent of θ. Taking T→∞ turns the sum into a Riemann integral over t, whose integrand is exactly the loss Eq. (?).
It remains to express Eq. (?) in terms of the concrete score.
Writing the reverse rates as [R˙t(xt)]y=[Q˙t(xt)]yst(xt)y (see Eq. (?)), we recover, up to a θ-independent constant, the concrete score matching loss Eq. (?) established in the score-based perspective. The two viewpoints therefore minimize the same objective.
Equivalence derivation
Applying Bayes’ theorem to xt→xs conditioned on x0 gives:
Lt(θ)=Ex0∼p0xt∼q(⋅∣x0)[y=xt∑([Q˙t(xt)]ysθ,t(xt)y−[Q˙t(xt)]ypt(xt∣x0)pt(y∣x0)log[Q˙t(xt)]y−[Q˙t(xt)]ypt(xt∣x0)pt(y∣x0)logsθ,t(xt)y)].=Ex0∼p0xt∼q(⋅∣x0)[y=xt∑[Q˙t(xt)]y(sθ,t(xt)y−pt(xt∣x0)pt(y∣x0)logsθ,t(xt)y)]+Cindependent of θEx0∼p0xt∼q(⋅∣x0)[y=xt∑−[Q˙t(xt)]ypt(xt∣x0)pt(y∣x0)log[Q˙t(xt)]y].
This is exactly the loss Eq. (?) of the concrete score matching proposition.
Equivalence with discrete flow matching
We now connect discrete diffusion to discrete flow matching. In discrete flow matching, a velocity field ut defines the Euler sampling scheme:
xt+h∼Cat(ext+hut(xt)).
We show that this sampling rule is equivalent to sampling in discrete diffusion (Eq. (?)).
Sampling: To align these two sampling equations directly, we must first account for the main discrepancy between the frameworks: their time conventions. In discrete diffusion, t=0 corresponds to clean data, and t=1 corresponds to the fully masked state. Discrete flow matching uses the exact opposite convention.
Suppose we know the discrete diffusion reverse rate R˙t. We define the flow matching velocity by the time reversal:
ut′FM=R˙1−t′
Then, sampling from discrete diffusion using Eq. (?) is equivalent to sampling from the flow matching Euler scheme Eq. (?): for every t′∈[0,1], the distribution pt′FM of samples obtained by simulating flow matching from 0 to t′ is the same as the distribution p1−t′DD obtained by simulating the discrete diffusion reverse CTMC from 1 to 1−t′, i.e. pt′FM=p1−t′DD.
Proof
We start from the infinitesimal reverse-time transition of the discrete diffusion process Eq. (?).
We first perform the variable change t′=1−t in Eq. (?). We have t=1−t′, so xt=x1−t′ and xt−Δt=x1−t′−Δt. The rate evaluates at R˙1−t′, giving:
Recall the definition of a probability velocity: a velocity field ut′ generates a process xt′FM if and only if p(xt′+ΔtFM=y∣xt′FM=x)=I(y=xt′FM)+Δt[ut′(xt′FM)]y+o(Δt).
Identifying the first-order terms in Eq. (?) with the probability-velocity definition directly gives:
[ut′FM(x)]y=[R˙1−t′(x)]y
and therefore ut′FM=R˙1−t′.
Training Objectives: Now we show how their training objectives line up. The variational diffusion perspective gives the Masked Diffusion objective Eq. (?). In discrete flow matching, the velocity can be parameterized through a denoiser Pθ,t(X1i=x1i∣Xt=x), trained with the cross-entropy objective:
To directly compare the two training losses, we first note that the denoiser used by discrete flow matching and the denoiser used by variational diffusion in Eq. (?) are exactly the same object. Applying the time reversal tFM=1−tDD and identifying the clean data x1=x0, we get:
Proposition 8 (Masked diffusion/CDM loss equivalence).
Under the time reversal tFM=1−tDD, the Masked Diffusion training loss LMDM(t) from Eq. (?) is directly comparable to the denoising loss LCDM(t) from Eq. (?). At fixed flow-matching time t:
LMDM(t)≈1−t1LCDM(t).
Derivation
Under the time reversal above, the weight in Eq. (?) satisfies −α˙tDD/(1−αtDD)=1/tDD=1/(1−tFM). Therefore the Masked Diffusion loss Eq. (?) becomes the weighted masked cross-entropy:
For unmasked positions i, a well trained denoiser should just copy the current token xti=x1i it sees, therefore Pθ,t(X1i=x1i∣xt)=1, and the second term vanishes, giving:
Both expressions share the same conditional expectation. Eliminating it yields Eq. (?).
Disclaimer In general, learning a velocity field u (or equivalently a reverse rate R˙) with Eq. (?) is not equivalent to learning a denoiser with Eq. (?) for arbitrary source distributions or paths, for instance under uniform diffusion.
References
Argmax Flows and Multinomial Diffusion: Learning Categorical Distributions[PDF]
Emiel Hoogeboom, Didrik Nielsen, Priyank Jaini, Patrick Forre, Max Welling. NeurIPS 2021.
Structured Denoising Diffusion Models in Discrete State-Spaces[PDF]
Jacob Austin, Daniel D. Johnson, Jonathan Ho, Daniel Tarlow, Rianne van den Berg. NeurIPS 2021.
A Continuous Time Framework for Discrete Denoising Models[PDF]
Andrew Campbell, Joe Benton, Tom Rainforth, George Deligiannidis, Arnaud Doucet. NeurIPS 2022.
Discrete Diffusion Modeling by Estimating the Ratios of the Data Distribution[PDF]
Aaron Lou, Chenlin Meng, Stefano Ermon. ICML 2024.
Generative Flows on Discrete State-Spaces: Enabling Multimodal Flows with Applications to Protein Co-Design[PDF]
Andrew Campbell, Jason Yim, Regina Barzilay, Tom Rainforth, Tommi Jaakkola. ICML 2024.
DiGress: Discrete Denoising diffusion for graph generation[PDF]
Clement Vignac, Igor Krawczuk, Antoine Siraudin, Bohan Wang, Volkan Cevher, Pascal Frossard. ICLR 2023.
Scaling Rectified Flow Transformers for High-Resolution Image Synthesis[PDF]
Patrick Esser, Sumith Kulal, Andreas Blattmann, Rahim Entezari, Jonas Müller, Harry Saini, Yam Levi, Dominik Lorenz, Axel Sauer, Frederic Boesel, Dustin Podell, Tim Dockhorn, Zion English, Kyle Lacey, Alex Goodwin, Yannik Marek, Robin Rombach. ICML 2024.
Stable Video Diffusion: Scaling Latent Video Diffusion Models to Large Datasets[PDF]
Andreas Blattmann, Tim Dockhorn, Sumith Kulal, Daniel Mendelevitch, Maciej Kilian, Dominik Lorenz, Yam Levi, Zion English, Vikram Voleti, Adam Letts, Varun Jampani, Robin Rombach. Arxiv 2023.
Generative Modeling by Estimating Gradients of the
Data Distribution[PDF]
Yang Song, Stefano Ermon, NeurIPS 2019.
Deep Unsupervised Learning using Nonequilibrium Thermodynamics[PDF]
Jascha Sohl-Dickstein, Eric Weiss, Niru Maheswaranathan, Surya Ganguli. PMLR 2015.
Score-Based Generative Modeling through Stochastic Differential Equations[PDF]
Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon, Ben Poole. ICLR 2021.
Simplified and Generalized Masked Diffusion for Discrete Data[PDF]
Jiaxin Shi, Kehang Han, Zhe Wang, Arnaud Doucet, Michalis K. Titsias. NeurIPS 2024.
Here KL denotes the generalized KL divergence between two positive vectors a,b∈R+d, KL(a,b)=∑j=1dajlog(aj/bj)−aj+bj.
Up to a constant C independent of θ, Eq. (?) is
KL(R˙t(xt∣x0),R˙θ,t(xt)).
We note q(xs∣xt,x0) the conditional law
q(Xs=⋅∣Xt=xt,X0=x0).
For simplicity, we consider [Dθ,t(xt)]m=0.
Passing from the single-token derivation to the full sequence uses two assumptions:
The forward transition factorizes token-wise:
q(Xt=xt∣Xs=xs)=∏i=1Sq(Xti=xti∣Xsi=xsi).
The denoiser factorizes position per position:
P(X0=x0∣Xt=xt)=∏i=1SP(X0i=x0i∣Xt=xt).
Each per-position prediction still use the whole current sequence xt as context.