Episode 96 · Engineering Deep Dives

Running the Heat Equation Backwards: Diffusion Models and Flow Matching

Episode 96: Running the Heat Equation Backwards: Diffusion Models and Flow Matching, by Sankalp Thakur

Pipeline integrity engineer Wren Okafor watches a dye pulse smear out in a water line, and her friend Teodor Lindqvist, a machine learning engineer, claims his whole field runs that smearing backwards. Starting from the score (the gradient of log density, which makes the normalising constant vanish), the episode builds Langevin dynamics, Song and Ermon's annealed noise-conditional score networks, and Ho, Jain and Abbeel's DDPM (2020): the variance-preserving forward process, the noise-prediction loss, and its equivalence to denoising score matching. It then covers the score-SDE view (Song et al., ICLR 2021), Anderson's reverse-time SDE, the Fokker–Planck equation (advection plus diffusion, and literally the heat equation in the variance-exploding case), and the deterministic probability-flow ODE. Next come fast samplers (DDIM, DPM-Solver, Karras's EDM), classifier and classifier-free guidance, latent diffusion and Stable Diffusion, and diffusion transformers. The second half moves from noise to transport: continuous normalising flows and the continuity equation, flow matching (Lipman et al.), rectified flow and reflow (Liu et al.), stochastic interpolants (Albergo and Vanden-Eijnden), Monge, Kantorovich and Benamou–Brenier optimal transport and minibatch OT, then consistency models and distillation. It closes with the state of the art, each claim tiered: SD3's rectified-flow MM-DiT, FLUX.1, FLUX.2 and FLUX 3, video models, masked diffusion language models (LLaDA, Mercury, Gemini Diffusion), Diffusion Policy and pi-zero in robotics, RFdiffusion and AlphaFold 3 in protein science, and GenCast in weather. Builds on ep69 (PDEs), ep70 (functional analysis), ep15 (information theory), ep22 (probability) and ep34 (inference economics).

Listen to the show on your preferred podcast platform.

Inside this episode

  1. Cold open: the ink drop in the pipe
  2. The problem: drawing from a distribution you can't write down
  3. The score and why the constant disappears
  4. Langevin dynamics: rolling downhill with a shaker attached
  5. DDPM: the forward process, a slow fade to static
  6. DDPM: the reverse process and the beautifully simple loss
  7. The score-SDE view: let the steps become infinitely small
  8. Fokker–Planck: from particles to the density
  9. The probability-flow ODE: removing the dice
  10. DDIM and the race to fewer steps
  11. Guidance: steering the sample toward a prompt
  12. Latent diffusion and Stable Diffusion
  13. Continuous normalising flows: transport without noise
  14. Flow matching: regress the velocity
  15. Rectified flow: make the paths straight
  16. Stochastic interpolants: the unifying frame
  17. Optimal transport: the shortest way to move the sand
  18. Consistency models and distillation: from fifty steps to one
  19. The state of the art, part one: images and video
  20. The state of the art, part two: diffusion for language
  21. The state of the art, part three: robots, proteins and weather
  22. What it means, and what to watch
← Explore all 96 episodes

Production credits & AI disclosure

Scripts generated with Claude Opus. Synthetic narration generated with Edge TTS. Reviewed, listened to, and approved by Sankalp Thakur.