Discrete Diffusion and Discrete Flow Matching

You cannot add Gaussian noise to a word. So a diffusion language model erases words into [MASK] and learns to fill the holes. It can write a 12-word sentence in 4 passes, where a left-to-right model needs 12.

Pick a writer and how many passes, then press Write. Watch which words appear in each pass. Then we build, piece by piece, the jumps, the rate matrix, the masking path, the classifier and the sampler behind it.

You need what a probability is and a little Python. Lectures 1 to 4 help but are not required. We build the rest from zero.

Based on Lecture 5 of MIT 6.S184: Introduction to Flow Matching and Diffusion Models (IAP 2026), taught by Peter Holderrieth and Ron Shprints. Slides: Lecture 5 PDF. Course notes: Holderrieth and Erives, An Introduction to Flow Matching and Diffusion Models. It follows Lecture 4, Architectures and Latent Spaces.

Write one sentence two ways

4

Illustrative toy. The denoiser's confidence for each word is made up, and the diffusion writer reveals its most confident words first. A real pass runs a full transformer over all 12 positions. Chapter 8 shows the cost, and what goes wrong with too few passes.

Chapter 0

You Cannot Add Noise to a Word

See why the noise of Lectures 1 to 4 breaks on text, and what replaces it

Take one grey pixel with brightness 0.62. Add a little Gaussian noise and you get 0.70: a slightly lighter grey. Small noise makes a small change. Every flow and diffusion model so far stands on that fact.

Now take the word "cat". A computer stores it as a token: an integer index into a fixed list of words. Say "cat" is token 2.

Add noise and you get 3.4. There is no token 3.4. Round it and you get token 3, which might be "off". The numbers 2 and 3 are labels, not positions, so being close as numbers means nothing.

Add the same noise to a pixel and a word

Top: a pixel's brightness on a line. Bottom: eight words in token order. Drag the noise and press New noise.

0.30

Illustrative toy. The word order is arbitrary, as in a real tokenizer. The word's noise is scaled by 4 because token ids span a wider range than a brightness.

The slides say it plainly: there is no SDE and no ODE on a discrete space. What survives is the recipe behind flow matching. Build a path from noise to data, then learn to run it backwards. The tool that carries it to text is the continuous-time Markov chain (CTMC). A CTMC sits on one state and jumps to another at random moments.

Think of a frog on lily pads. It cannot drift halfway between pads. It sits, then hops. We choose how often it hops in each direction. Generation becomes: set the hop rates so that a frog that starts on "noise" lands on a real sentence.

The failure, as symptom, measurement and fix

The symptom: a model that adds Gaussian noise to token ids makes nonsense, even at small noise. To measure it, add noise of 0.1 and count how often the rounded token changes meaning. The fix is not smaller noise. It is a different kind of corruption, one that never invents a word between words.

The road

  1. The discrete state space: sequences of tokens, and the extra [MASK] token.
  2. Jumps instead of drift: the CTMC and its Euler step.
  3. The rate matrix: why each column sums to zero.
  4. The masking path: fade a sentence into masks.
  5. The marginalization trick: the rate needs one unknown, a guess of the clean word.
  6. Training is classification: the discrete flow matching loss.
  7. The sampler: un-mask in parallel, step by step.
  8. Showcase: too few passes break sentences, and the trade with left-to-right models.
  9. The field guide: terms, numbers, code, links and credit.
Why can the diffusion machine of Lectures 1 to 4 not run on text directly?

Chapter 1

The Discrete State Space

Count every possible sentence and see why no model can list them

A continuous sample was a point with d real numbers. A text sample is a row of d slots, each holding one token. Two numbers set the size of the world. The vocabulary is the fixed list of allowed tokens; call its size V. The sequence length is the number of slots; call it d.

A sentence is x = (x1, ..., xd), and each xj is one token. The set of every possible sentence is the state space, S. How big is it?

Say it aloud

The size of S equals V to the power d.

|S|
the size of S the number of different sentences that can exist.
V
V the vocabulary size: 3 in our toy, about 50,000 for a real language model.
d
to the power d multiply V by itself once per slot; d is the sequence length.
In plain words

Slot 1 can hold any of V tokens. So can slot 2, and every slot up to d. The choices multiply, so the count is V multiplied by itself d times.

With numbers

Toy alphabet A, B, C, so V = 3, and d = 4: 3 × 3 × 3 × 3 = 81 sentences, such as ABCA. With V = 50,000 and d = 1,024, the count is a number with 4,812 digits.

Count what a model would have to store

Each bar shows how many digits a number has. Pick a vocabulary, then drag the length.

4

Exact counts. "Factorized" is the d × V output that Chapter 3 introduces; it is what a transformer produces per pass.

The data distribution, pdata, gives each of those sentences a probability. Grammatical sentences get a lot; keyboard mash gets almost none. We never see pdata. We see a corpus of samples from it.

One new token: [MASK]

We add one extra token, [MASK], which means "this slot was erased". A half-erased sentence looks like A [MASK] C [MASK]. With the mask, the toy has 44 = 256 states. This one token is the noise of a masked diffusion model.

The failure, as symptom, measurement and fix

The symptom: any method that stores one number per whole sentence runs out of memory at once. Measure it with the bar above: the digits of Vd. The fix is to make the model output a few numbers per slot, never per sentence. Chapter 3 builds that.

With vocabulary size V and length d, how many sentences exist, and why does it matter?

Chapter 2

Jumps Instead of Drift

Watch a continuous-time Markov chain hop between states and take one Euler step

An ODE path is a smooth curve. A CTMC path is a staircase: flat while the process sits on a state, then a sudden jump. "Continuous time" means a jump can happen at any moment, not on a clock tick. "Markov" means the next jump depends only on the current state, not on the history.

Make the frog hop

The staircase is one random path over time 0 to 1. Raise the rate and press New path. Between jumps, nothing moves.

3.0

Simulated exactly: the wait before a jump is drawn from an exponential distribution with the total leaving rate. The frog picks either other pad with equal chance.

The flow map of Lecture 1 had no formula, so we stepped the vector field. Here too we need a local rule. The rate from state x to state y at time t is the number of jumps from x to y per unit of time. Call it Qt(y | x). Over a short time h, the chance of a jump is rate times time.

Say it aloud

p of y given x, from t to t plus h, is about delta y-equals-x, plus h times Q-t of y given x.

pt+h|t(y | x)
p of y given x, from t to t plus h the chance to be at y after the step, if you start at x.
≈
is about exact as h shrinks to zero; close for small h.
δy=x
delta y-equals-x 1 if y is the same state as x, else 0. It is the "no jump" part.
h
h the step length in time, for example 0.1.
Qt(y | x)
Q-t of y given x the rate of jumps from x to y, in jumps per unit of time.
In plain words

For each other state y, the chance to jump there in the step is h times its rate Q-t of y given x. Whatever chance is left is the chance to stay at x. Draw the next state from these chances.

With numbers

With made-up numbers: the frog sits on A. The rate to B is 2, the rate to C is 1, and h = 0.1. Jump to B: 0.1 × 2 = 0.2. Jump to C: 0.1 × 1 = 0.1. Stay on A: 1 − 0.3 = 0.7.

That single line is the discrete Euler step. It plays the part of x + h · ut(x) from Lecture 1. Every sampler in this lesson is a loop of it.

The failure, as symptom, measurement and fix

The symptom: the sampler crashes with a negative probability. Measure the stay chance, 1 minus h times the total leaving rate. With rates 2 and 1 and h = 0.5, it is 1 − 1.5 = −0.5. The fix: keep h below 1 divided by the total leaving rate, here below 1/3.

The rate from A to B is 4 and from A to C is 1. With h = 0.05, what is the chance to stay on A?

Chapter 3

The Rate Matrix: a Vector Field for Jumps

Set the diagonal so probability is kept, and shrink the matrix to one slot at a time

Put every rate in a table: one column per state you leave, one row per state you land on. This is the rate matrix, or generator: the discrete vector field. Rates off the diagonal are zero or more. One rule sets the diagonal.

Say it aloud

Q-t of x given x equals minus the sum, over every y not equal to x, of Q-t of y given x.

Qt(x | x)
Q-t of x given x the diagonal entry for x: bookkeeping, not a jump.
−
minus the diagonal is negative: it takes away what leaves.
Σy≠x
the sum over every y not equal to x add one term for each other state.
Qt(y | x)
Q-t of y given x the rate of jumps from x to y; zero or more.
In plain words

Add up every rate of leaving x. Write minus that total on the diagonal. Then the column for x sums to zero, and the Euler step's chances sum to 1.

With numbers

Rates from A: 2 to B, 1 to C. So Q-t of A given A = −3, and with h = 0.1 the stay chance is 0.7. Then 0.7 + 0.2 + 0.1 = 1.0.

Why does this keep the total at 1? Call the probability of state y at time t pt(y). It changes by what flows in minus what flows out.

Say it aloud

d by d-t of p-t of y equals the sum over x of Q-t of y given x times p-t of x.

d/dt
d by d-t how fast a quantity changes per unit of time.
pt(y)
p-t of y the probability of being in state y at time t.
Σx
the sum over x one term for every state, including y itself.
Qt(y | x)
Q-t of y given x the rate from x to y; for x = y it is the negative diagonal.
pt(x)
p-t of x the probability of being in x.
In plain words

For each state x, multiply its mass p-t of x by its rate into y and add. The term for x = y is negative and takes away what leaves y. This is the Kolmogorov forward equation, the discrete version of the continuity equation.

With numbers

All mass on A, rates 2 to B and 1 to C. The changes are −3 for A, +2 for B, +1 for C. They add to 0, so the total stays 1. After h = 0.1 the masses are 0.7, 0.2, 0.1.

Set the rates, then forget the diagonal

Bars show the chances after one step from A. Drag the rates and h. Then turn off the diagonal and watch the total.

2.0
1.0
0.10

Exact arithmetic of one Euler step. Rates are made up.

One slot at a time

A full rate matrix has one entry per pair of sentences: 81 × 81 = 6,561 for the toy, and far beyond memory for text. So real models are factorized: a jump may change only one slot. Two sentences are neighbours if they differ in at most one slot. AB and AC are neighbours; AB and CC are not.

The model then outputs one rate per slot and per token: d × V numbers, 12 for the toy. In a short step, two slots rarely change together (the chance shrinks like h squared). So the sampler treats slots as independent. Chapter 8 shows the price.

Now code it and break the diagonal.

The failure, as symptom, measurement and fix

The symptom: the total drifts away from 1 over many steps. Measure the column sums of Q; each must be 0. The fix is the diagonal rule above.

Why must the entries for each leaving state sum to zero?

Chapter 4

The Masking Path: Fade a Sentence Into Masks

Build the forward path that turns a clean sentence into all masks, token by token

A diffusion model needs a path between noise and data. For text the simplest path erases tokens. At time 0 every slot is [MASK]. At time 1 every slot shows its clean token. In between, each slot shows its clean token or a mask.

A scheduler sets how much survives. Call the chance that a slot shows its clean token at time t κt ("kappa-t"). It rises from κ0 = 0 to κ1 = 1. Call the clean sentence z, and its token in slot j zj.

Say it aloud

p-t of x-j given z-j equals kappa-t times delta z-j of x-j, plus one minus kappa-t times delta MASK of x-j.

pt(xj | zj)
p-t of x-j given z-j the chance that slot j shows token x-j at time t, if the clean token is z-j.
κt
kappa-t the survival chance at time t, from 0 to 1.
δzj(xj)
delta z-j of x-j 1 if the slot shows its clean token, else 0.
1 − κt
one minus kappa-t the chance that the slot is masked.
δ[M](xj)
delta MASK of x-j 1 if the slot shows [MASK], else 0.
In plain words

For each slot j, flip a coin that lands heads with chance kappa-t. Heads: show the clean token z-j. Tails: show [MASK]. Each slot gets its own coin.

With numbers

Linear scheduler, kappa-t = t. A 12-word sentence at t = 0.25: each word survives with chance 0.25, so on average 12 × 0.75 = 9 words are masked. At t = 0.75, 12 × 0.25 = 3 are masked.

Fade eight copies of one sentence

Each row is the same 12-word sentence with its own coins. Drag the time and press Re-mask. Compare the average count with 12 × (1 − κ).

0.50

Illustrative sentence; the coin flips are real random draws.

Compare this with Gaussian noise. A Gaussian path moves mass through space: the cloud drifts and spreads. The masking path moves nothing. It fades out the clean token and fades in the mask. The slides call it teleporting mass, and this path the factorized mixture path. The mask is an absorbing state: once a slot is masked on the way to noise, it stays masked.

The endpoints check out. At t = 1, κ = 1 and every slot shows z. At t = 0, κ = 0 and every slot is a mask, the same start for every sentence. Now build the forward process in code.

The failure, as symptom, measurement and fix

The symptom: the model never learns to write from all masks. Measure the masked fraction at t = 0 over many samples; it must be 1. The fix: make the mask chance 1 − κt, not a constant.

With survival chance κt, how many of d slots are masked on average?

Chapter 5

The Marginalization Trick: Guess the Clean Word

Find the rate that follows the masking path, then replace the unknown answer with a guess

To generate, we need rates that make the CTMC follow the path from all masks to a sentence. Lecture 2's recipe: solve the case where z is known, then average over what is not.

If you knew the answer

Fix z. A masked slot jumps straight to its clean token. A slot that is already right never moves. Call the speed of the scheduler, how fast κ rises, κ̇t ("kappa-dot-t").

Say it aloud

Q-t-z of y-j given x-j equals kappa-dot-t over one minus kappa-t, times delta z-j of y-j minus delta x-j of y-j.

Qzt(yj | xj)
Q-t-z of y-j given x-j the rate at which slot j jumps from token x-j to token y-j, when the answer z is known.
κ̇t / (1 − κt)
kappa-dot-t over one minus kappa-t the speed factor: how fast survival rises, divided by the share still masked.
δzj(yj)
delta z-j of y-j 1 if the target y-j is the clean token, else 0.
δxj(yj)
delta x-j of y-j 1 if the target is the current token; this term is the outflow on the diagonal.
In plain words

If slot j already shows z-j, the bracket is 1 − 1 = 0 and nothing happens. If it shows [MASK], it jumps to z-j at the speed factor.

With numbers

Linear scheduler, so kappa-dot = 1. At t = 0.5 the speed factor is 1 / 0.5 = 2; with h = 0.1 a masked slot un-masks with chance 0.2. At t = 0.9 the factor is 10, so the chance is 1.0: every mask left goes in the last step.

The slides say the rates explode at t = 1. That is how the path ends on a full sentence.

When you do not know the answer

At generation time z is unknown. The trick replaces z with a belief about z, given the half-masked sentence x. Call that belief the posterior, p1|t(zj = v | x): the chance that the clean token in slot j is v.

Say it aloud

Q-t of y-j given x equals kappa-dot over one minus kappa, times p-one-given-t of z-j equals y-j given x, minus delta x-j of y-j.

Qt(yj | x)
Q-t of y-j given x the marginal rate for slot j to become y-j, given the whole sentence x.
κ̇t / (1 − κt)
kappa-dot over one minus kappa the same known speed factor.
p1|t(zj = yj | x)
p-one-given-t of z-j equals y-j given x the posterior: the chance that y-j is the clean token in slot j. This is the only unknown.
δxj(yj)
delta x-j of y-j 1 if y-j is the current token: the outflow term.
In plain words

A masked slot jumps to each token y-j at the speed factor times the posterior chance of y-j. A slot that shows a real token has posterior 1 on that token, so its rate is zero.

With numbers

In the corpus below, x = [M] cat [M] [M]. Slot 1 has posterior "the" 2/3 and "a" 1/3. At t = 0.5 the factor is 2, so the rates are 1.33 and 0.67. With h = 0.1: "the" 0.133, "a" 0.067, stay masked 0.8.

Mask slots and read the posterior

Tap a slot to cycle it through [MASK] and its two words. The lit sentences are the ones that match. Bars under each masked slot are the posterior; yellow numbers are the rates at time t.

0.50

Illustrative six-sentence corpus, each sentence equally likely. The posterior here is exact: count the matching sentences. A real model learns to estimate it.

So the posterior is the only unknown. It answers a plain question: what word was in each hole? That is a classifier per slot, a softmax over V tokens.

The failure, as symptom, measurement and fix

The symptom: the sampler rewrites words it placed. Measure the posterior at a filled slot; it must be 1. The fix: copy visible tokens through and predict only masked slots.

After the marginalization trick, what is the only part of the rate the network must supply?

Chapter 6

Training Is Classification

Mask a sentence, ask for the hidden words, and score the guesses with cross-entropy

The network takes a half-masked sentence x and the time t. Its output is a table of logits, d rows by V columns: one score per slot per token. A softmax per row turns each row into a posterior. Call the network's posterior pθ1|t, where θ ("theta") is its weights.

Training needs no simulation. Take a clean sentence, mask it at a random time, and ask for the hidden words. The score is the cross-entropy: minus the log of the chance the network gave the true word.

Say it aloud

L of theta equals the average, over z, t and x, of the sum over j of minus log p-theta-one-given-t of z-j given x.

L(θ)
L of theta the discrete flow matching loss for weights theta. Lower is better.
Ez, t, x
the average over z, t and x over clean sentences z from the corpus, random times t, and masked copies x.
Σj
the sum over j one term per slot; visible slots add 0 because their answer is copied.
−log
minus log the natural log, negated: 0 for a sure right guess, large for a confident wrong one. Unit: nats.
pθ1|t(zj | x)
p-theta-one-given-t of z-j given x the chance the network gives the true token z-j in slot j.
In plain words

Pick a sentence z and a time t. Mask it into x. For each masked slot j, read the chance the network gave the true word z-j, take minus its log, and add. Average over many such draws and step the weights downhill.

With numbers

With made-up numbers: two slots are masked. The network gives the true words 0.5 and 0.8. The loss is 0.693 + 0.223 = 0.916 nats.

Score one training example

Top row: the clean sentence. Middle row: the masked copy at time t. Bars: what a perfect denoiser would guess. Press New example, or drag t.

0.30

The same six-sentence toy corpus. The "perfect denoiser" counts matching sentences, so its loss is the smallest any model can reach.

Try [M] cat [M] [M] with the clean sentence "the cat ran off". Each hidden word has posterior 2/3, so even a perfect model pays 3 × 0.405 = 1.22 nats. That floor is the real ambiguity of the corpus, not an error.

Real systems add one detail. MDLM and LLaDA score only the masked slots and multiply each example by the speed factor. With κt = t that factor is 1 divided by the masked share, the "1/t" in LLaDA's paper, whose t is the masked share. The weight turns the loss into a bound on the model's log-likelihood.

python# One discrete flow matching step. z: LongTensor (B, d) of token ids.
t = torch.rand(B, 1)                         # (B, 1) random times
keep = torch.rand(B, d) < kappa(t)              # (B, d) True = survives
x = torch.where(keep, z, MASK)                  # (B, d) half-masked input
logits = net(x, t)                                # (B, d, V) one softmax per slot
ce = F.cross_entropy(logits.transpose(1, 2), z, reduction="none")  # (B, d)
loss = (ce * ~keep).sum(1).mean()                # score masked slots only
loss.backward(); opt.step()

The failure, as symptom, measurement and fix

The symptom: training loss is tiny but samples are poor. Measure the loss at small t (mostly masked) and at large t separately. If most examples have few masks, the model rarely practices from scratch. The fix: draw t uniformly and weight by the speed factor.

A perfect denoiser gives each of 2 hidden words a chance of 1/2. What loss does it pay, and why?

Chapter 7

The Sampler: Un-mask in Parallel

Run the Euler step with the learned rate and watch a sentence fill in, out of order

Start with every slot masked. Split time 0 to 1 into n steps, each of length h = 1/n. Each step does three things.

  1. Predict. Run the network once on the current sentence x. Get a posterior for every slot.
  2. Jump. For each masked slot, decide whether it un-masks this step. If it does, draw its token from the posterior.
  3. Commit. Keep the new tokens fixed and move t forward by h.

The jump chance comes from Chapter 5. A masked slot un-masks with chance h times the speed factor. With κt = t, that is h/(1 − t). The masked count at time t is about d × (1 − t), so the expected reveals per step are:

d × (1 − t) × h / (1 − t) = d × h = d / n

With d = 12 and n = 4, that is 3 words per step on average. Every slot is updated from one network pass, at the same time. A left-to-right model makes one pass per word: 12.

Run the sampler step by step

Press Step to run one Euler step. Choose random un-masking (the CTMC rule) or most confident first. The bars count reveals per step against d / n.

4

Illustrative toy denoiser that always knows the right word; only the order and timing are simulated. Confidences are made up.

Real samplers often use the second rule. LLaDA's paper, for example, re-masks its least confident predictions at each step, so the surest words are kept first. Easy words settle early and give context to the hard ones. The order emerges; it is not left to right.

The same loop also edits. Fix some tokens, mask the rest, and let the model fill only the holes. Now write the confident-first sampler yourself.

The failure, as symptom, measurement and fix

The symptom: the sentence never finishes. Measure the masks left after the last step. The fix: make the last step un-mask everything; h/(1 − t) is 1 when t = 1 − h. And in this basic sampler, never re-mask a committed token.

A 64-slot sentence is sampled with n = 16 steps and κt = t. About how many slots un-mask per step?

Chapter 8

Showcase: Fewer Passes, Broken Sentences

Sample thousands of sentences, find the price of parallel un-masking, and weigh it against left to right

Parallel un-masking draws each slot from its own posterior. Each draw is right on its own. But two slots drawn in the same step do not see each other. In our corpus, "sat" always goes with "down" and "ran" with "off". Un-mask both slots at once and you can get "sat off", which no sentence contains.

Sample 2,000 sentences per setting

The curve shows the share of samples that are real corpus sentences, for 1 to 16 passes. Drag the passes and press Sample to see examples.

1

The six-sentence corpus with a perfect denoiser and the random Euler rule. If no corpus sentence matches the visible words, the toy denoiser uses the sentences that match the most. Numbers are fresh random draws.

With 1 pass, all four slots are drawn from their own posteriors at once. Each pair of words is 50/50, so 2 × 2 × 2 × 2 = 16 sentences are equally likely, and only 6 are real: 37.5%. With 2 passes about 70% are real, with 4 about 86%, and with 64 about 99%. More passes give each slot more context. A left-to-right model with the true conditional is right 100% of the time, in 4 passes.

The slides close with an honest list of pros and cons.

Left to right (GPT)Masked diffusion (MDLM)
OrderFixed, left to rightAny order, often confident first
Tokens per passOned / n, your choice
Editing and in-fillNot nativeNative: mask and re-fill
KV cacheYes: past keys and values are reusedNo: each pass re-reads the whole sentence
What it must learnOne order, which fits how text is writtenEvery order, which is harder

The KV cache row matters most for speed. A left-to-right pass processes one new token and reuses the rest. A diffusion pass processes all d slots.

So fewer passes do not mean less compute. With d = 12 and n = 4, diffusion runs 4 full passes of 12 slots: 48 slot-passes. Left to right runs 12 cached passes of one token. Whether diffusion wins depends on the hardware and on how few passes still give good text.

Where the ideas come from

The failure, as symptom, measurement and fix

The symptom: fluent words, broken phrases ("sat off"). Measure the share of outputs that pass a grammar or corpus check as you lower n. The fix: more passes, confident-first un-masking, or semi-autoregressive blocks that fill a short span at a time.

Why does sampling all four slots in one pass give broken sentences such as "the cat sat off"?

Chapter 9

The Field Guide

Keep the terms, the numbers, the code and the links on one page

Text has no directions, so we replace drift with jumps. A rate matrix whose columns sum to zero plays the vector field. The masking path fades a sentence into [MASK]. The marginalization trick shows that the rate needs one unknown, the posterior over each clean word. So training is classification, and sampling un-masks many slots per pass.

TermWhat it isNumber to remember
State space Severy sentence of d tokens from VVd: 81 for V = 3, d = 4
CTMCa process that sits, then jumps at random timesjump chance = rate × h
Rate matrix Qrates of every jump; diagonal = minus the total leavingrates 2, 1, h = 0.1: chances 0.2, 0.1, 0.7
Factorizedone slot changes per jumpd × V outputs: 12 for the toy
Scheduler κtchance a slot shows its clean tokenmasked on average: d × (1 − κt)
Speed factorκ̇ / (1 − κ)2 at t = 0.5, 10 at t = 0.9 for κ = t
Posterior p1|tthe guess of each clean token, the only learned partd × V softmax per pass
DFM losscross-entropy on the masked slotsguesses 0.5, 0.8: 0.916 nats
Samplerpredict, jump, commit, repeat n timesd / n reveals per step

Checklist

The core as code

pythonimport numpy as np

def sample(net, d, n, MASK, rng=np.random.default_rng(0)):
    x = np.full(d, MASK)                         # X_0: every slot masked
    h = 1.0 / n
    for i in range(n):
        t = i * h
        post = net(x, t)                         # (d, V) posterior over clean tokens
        p_jump = h / (1.0 - t)                  # kappa_t = t: speed factor times h
        for j in range(d):                       # every slot from the same pass
            if x[j] == MASK and rng.random() < p_jump:
                x[j] = rng.choice(len(post[j]), p=post[j])   # commit
    return x                                     # X_1: a sentence

Where this sits

The slides end on why the recipe carried over so cleanly. Flow matching is not tied to flows. It works for any Markov process, a result called Generator Matching (Holderrieth et al., 2024). The vector field and the rate matrix are two cases of one object, the generator.

Continuous (Lectures 1 to 4)Discrete (this lesson)
ODE or SDECTMC
Vector field ut(x)Rate matrix Qt(y | x)
Euler: x + h · uJump chance h · Q
Gaussian startAll [MASK] start
Regression lossClassification loss

Keep going

The takeaway. Erase tokens on a schedule, learn to guess the erased tokens, and the guess is the whole rate matrix. Sampling then fills d / n slots per pass, and fewer passes trade coherence for parallel work.
Why does the flow matching recipe carry over from images to text?

Now press Present or Teach. Explain from memory: no noise on words, the zero column sums, the masking path, the classifier and the d / n sampler. Then go back to the hero and write the sentence again, and predict which words come first.

Credit and source

This lesson re-teaches Lecture 5, "Discrete diffusion models and discrete flow matching", of MIT 6.S184 (IAP 2026). Peter Holderrieth and Ron Shprints teach it, with Tommi Jaakkola as sponsor. Course site: diffusion.csail.mit.edu. Slides: the Lecture 5 PDF. Notes: Holderrieth and Erives, An Introduction to Flow Matching and Diffusion Models. The explanations, toy corpus and devices here are our own.

MIT 6.S184 Lecture 5: Discrete Diffusion and Discrete Flow Matching
The course site · Slides PDF · Course notes · Back to Gleams