6.6 Flow matching
1. Learn
Section titled “1. Learn”- MIT 6.S184 lecture notes: Flow Matching and Diffusion Modelsthe sections on conditional and marginal probability paths, vector fields, and the flow matching loss
- MIT 6.S184 course sitelecture 2–3 videos and the flow-matching lab
- Lipman et al., Flow Matching for Generative Modelingsections 2–4: continuous normalizing flows, flow matching, conditional flow matching and the optimal transport path
2. Bridge
Section titled “2. Bridge”Skip the noise process. 6.5 defined a noising process and learned to reverse it. Flow matching asks for an ODE dx/dt = ut(x) that carries N(0, I) at t = 0 to the data at t = 1 (the reverse of 6.5’s DDPM convention, where x0 is data and t runs toward noise; 6.4 and the rest of Part 6 use this one), and builds it from simple pieces (Lipman et al. 2022, sections 2–4). For one data point x1, the straight path xt = t x1 + (1 − t) ε goes from noise to that point with constant velocity x1 − ε. That is a conditional path; there is one per data point.
From conditional to marginal. Many such lines pass through any point x at time t. Their average velocity, ut(x) = E[x1 − ε | xt = x], is the marginal velocity field, and following it moves the whole noise distribution onto the whole data distribution at every t (Holderrieth and Erives 2025, the sections on conditional and marginal probability paths). Rectified flow reached the same objective from the transport side (Liu, Gong and Liu 2022).
Learning it. We cannot compute that average for real data, but we do not need to. Regress the conditional velocity: draw t, ε and a data point, and minimise ‖vθ(xt, t) − (x1 − ε)‖². A squared loss is minimised by the conditional mean, so vθ learns ut (Lipman et al.’s Theorem 2, section 3): the same move as denoising score matching in 6.5. In fact for this path the score is (t ut(x) − x) / (1 − t), so the two models carry the same information. Sampling is 6.4’s Euler method, and because the paths are close to straight, few steps are needed.
Checking it. For a Gaussian mixture, ut has a closed form; the widget and tests use it, and the notebook then trains the same loss on MNIST with a small U-Net, as in the 6.S184 lab.
3. Explore
Section titled “3. Explore”Flow matching: edit exercises/stubs/m6_6_flow_matching.py on your own machine. This task needs PyTorch, which the in-page runner does not have.
pip install torch # CPU build is enough for the tests
mlc check 6.6Then run the lab. Open notebooks/6.6-flow-matching.ipynb (a GPU helps, but a CPU finishes in about 15 minutes) and paste in your 6.6 file. It trains on the three-blob mixture and compares the learned velocity with the exact one, samples with Euler and Heun at 2 to 100 steps, then trains a small U-Net on MNIST with the same loss and checks the samples with a classifier.
5. Check
Section titled “5. Check”- not yet: All tests pass (0/?)
- not yet: Checkpoint quiz ≥ 80%
Learner log: time spent and points of confusion
Every confusion you note becomes a fix before the module is marked stable. Export it from the progress page and attach it to an issue.