6.4 ODEs and SDEs for generation
1. Learn
Section titled “1. Learn”- MIT 6.S184 lecture notes: Flow Matching and Diffusion Modelssection 2: flow and diffusion models as ODEs and SDEs, vector fields, Brownian motion, and simulating them with Euler and Euler–Maruyama
- MIT 6.S184 course sitelecture 1 video and lab 1 (simulating ODEs and SDEs, Langevin dynamics)
- Song and Ermon, Generative Modeling by Estimating Gradients of the Data Distributionsection 2 (score matching and Langevin dynamics), §3.2.2 (why Langevin struggles with separated modes) and §4.3 (annealed Langevin)
2. Bridge
Section titled “2. Bridge”Generation as simulation. The rest of Part 6 generates data by moving noise along a vector field. Start at x0 ~ N(0, I) and follow dXt = ut(Xt) dt from t = 0 to 1; a network learns u so that X1 looks like data. That is an ordinary differential equation (ODE), and the map from start to end is called a flow. Add a random kick, dXt = ut(Xt) dt + σt dWt, and it is a stochastic differential equation (SDE) (Holderrieth and Erives 2025, section 2).
Simulating. A neural u has no closed-form solution, so we take small steps of size h. Euler’s method moves along the current arrow: x ← x + h ut(x). Its error shrinks in proportion to h; Heun’s method averages the slope at both ends of the step and its error shrinks like h². Euler–Maruyama adds σt √h ε with ε ~ N(0, I) at each step, because Brownian motion W moves a distance of order √h in time h, not h (MIT 6.S184, lab 1).
Two processes to know. The Ornstein–Uhlenbeck process dX = −θX dt + σ dW pulls towards zero while noise pushes out; whatever it starts from, it forgets and settles at N(0, σ²/(2θ)). That is what a diffusion model’s forward process does to data (6.5). Langevin dynamics, dX = ∇log p(X) dt + √2 dW, is the reverse kind: the drift climbs the log-density and the noise keeps it from collapsing onto the peaks, so for small steps and long runs its particles are distributed as p. The gradient ∇log p is called the score (Song and Ermon 2019, section 2).
The catch. Langevin crosses between far-apart modes very rarely, so the mass ends wherever the particles started. Song and Ermon fixed this by sampling from heavily blurred versions of p first and sharpening step by step, which is the idea behind diffusion models (Song and Ermon 2019, §3.2.2 and §4.3).
3. Explore
Section titled “3. Explore”stubs/m6_4_sde.pyLoading starter file…
Prefer your own editor? Edit exercises/stubs/m6_4_sde.py and run mlc check 6.4. The tests are identical; import the results on the progress page.
Then run the lab. Open notebooks/6.4-odes-sdes.ipynb (a CPU is enough) and paste in your 6.4 file. It measures the order of Euler and Heun, checks Euler–Maruyama on Brownian motion and the OU process, and samples a three-blob mixture with plain and with annealed Langevin dynamics.
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.