Small Vision Transformers: Flow Matching against DDPM on the Same DiT
Same DiT, data and 200 epochs: flow matching gets FID-10k 20.2 with 32 model calls. DDPM needs 256 calls to reach 19.9. Euler and Heun samplers compared.
On this page
In the last post, a 9.8 M parameter DiT learned to draw CIFAR-10 images with DDPM. I judged those samples by eye. This time I measure them, and I train the same model a second way: flow matching.
The question is simple. If I keep the network, the data, the optimizer and the number of epochs the same, and change only what the model learns to predict, what changes?
Two ways to learn the same job¶
Both methods teach the DiT to turn noise into an image. They differ in the path between the two and in what the model predicts along it.
- DDPM (Ho et al., 2020) adds Gaussian noise at one of 1,000 discrete timesteps, with a linear noise schedule. The model predicts the noise. I sample with deterministic DDIM (Song et al., 2021).
- Flow matching (Lipman et al., 2023; Liu et al., 2023) mixes image and noise on a straight line: x_t = (1 − t) · image + t · noise, with t from 0 (image) to 1 (noise). The model predicts the velocity, which is the direction along that line: noise − image. Sampling then solves an ordinary differential equation (ODE) from t = 1 back to t = 0.
For flow matching, the training times come from a logit-normal distribution (Esser et al., 2024). That puts more training on the middle noise levels, where the job is hardest. So this compares two recipes, not only two targets: the path, the target and the time sampling all change together.
Everything else is the same as in the last post: patch size 2, width 256, depth 8, 4 heads, AdamW at 3e-4, batch 128, 200 epochs, EMA decay 0.9999, and classifier-free guidance of scale 2.
How I count the cost¶
A sampler is cheap or expensive depending on how many times it runs the network. I count that as NFE, the number of function evaluations per image.
A guided step runs the network twice: once with the class label and once without it. So one DDIM step with guidance costs 2 NFE. For the Heun solver, each step costs two guided calls (4 NFE), except the last step, which is a plain Euler step. I compare methods only at equal NFE, never at equal step counts.
The quality metric is FID-10k: the Fréchet Inception Distance between 10,000 class-balanced samples and the 50,000 training images. Lower is better. FID from 10,000 samples is biased upward compared with the usual 50,000, so these numbers are fine for comparing runs here, but not for comparing with papers.
The training cost is the same¶
| DDPM | Flow matching | |
|---|---|---|
| Parameters | 9,805,836 | 9,805,836 |
| Training time (200 epochs) | 86.5 min | 86.2 min |
| Time per epoch | 25.9 s | 25.9 s |
| Peak VRAM | 3,595 MiB | 3,595 MiB |
Both ran on one RTX 3080 Ti. The two losses are not comparable: one is an error on noise and the other an error on velocity.
FID against model calls¶

| NFE | DDPM (DDIM) | Flow matching (Euler) |
|---|---|---|
| 2 | 360.9 | 310.0 |
| 4 | 357.1 | 83.3 |
| 8 | 83.4 | 38.9 |
| 16 | 44.3 | 25.7 |
| 32 | 30.1 | 20.2 |
| 64 | 25.0 | 16.5 |
| 128 | 22.1 | 14.7 |
| 256 | 19.9 | 14.0 |
Flow matching wins at every NFE. The gap is largest with few calls: at 8 calls, it’s 38.9 against 83.4. The clearest way I can put it: flow matching with 32 calls (20.2) is about as good as DDPM with 256 calls (19.9). That’s 8 times fewer network calls for the same FID.
With only 1 or 2 DDIM steps (2 or 4 NFE), DDPM gives noise. Flow matching with one Euler step gives a blurred average image, which is what one straight step from noise should give.
The usual explanation is the path. Flow matching trains on straight lines from noise to image, so a big Euler step along the predicted direction lands close to where it should. I didn’t test that claim directly here; the numbers are only consistent with it.
Euler or Heun?¶
Heun’s method is a second-order ODE solver. It takes an Euler step, looks at the velocity at the end of it, and then averages the two velocities. That costs a second model call per step.
| Heun NFE | Heun FID | Nearest Euler NFE | Euler FID |
|---|---|---|---|
| 6 | 46.7 | 8 | 38.9 |
| 14 | 22.8 | 16 | 25.7 |
| 30 | 18.8 | 32 | 20.2 |
| 62 | 16.5 | 64 | 16.5 |
| 126 | 14.7 | 128 | 14.7 |
| 254 | 14.0 | 256 | 14.0 |
Heun helps between about 14 and 30 calls, and at 14 calls it beats Euler at 16. At 6 calls it’s worse than Euler at 8, and from 62 calls on, the two are the same. If I had to pick one sampler for this model, I’d pick Heun with 4 to 8 steps.
What the samples look like¶
The figure below uses the same noise and labels in every panel. Each row is a class.

The same noise gives the same layout in all four panels, so the two models learned close to the same mapping from noise to image. At 8 calls, the DDPM samples are soft. The flow-matching samples have the same shapes with sharper edges. At 32 calls, both are sharp, and I find it hard to tell them apart by eye.
Limits¶
- I trained each method once, with one seed, so I can’t say how much FID changes from one seed to another.
- I computed FID from 10,000 samples (FID-10k). FID from fewer samples is biased upward, so these values are higher than the FID-50k (50,000 samples) that papers report. Compare them with each other, not with published results.
- The recipes differ in more than the target: the noise path and the training-time distribution change too.
- The guidance scale is fixed at 2 for both. I didn’t tune it per method or per step count.
Run it¶
- Train the flow-matching model. The script resumes from the last checkpoint if it stops.
- Compute FID-10k for the Euler and the Heun solver.
uv run python scripts/train_diffusion.py --method flow_matching
uv run python scripts/evaluate_fid.py --method flow_matching --steps 1 2 4 8 16 32 64 128
uv run python scripts/evaluate_fid.py --method flow_matching --solver heun --steps 1 2 4 8 16 32 64
uv run python scripts/make_blog_figures.py
The code is in the repo.
What I take from this¶
- On the same DiT and the same budget, flow matching beats DDPM at every number of model calls I tried.
- Count model calls, not steps. A guided step is two calls, and a Heun step is two guided calls.
- Heun is worth it for mid-range budgets and gives nothing at large ones.