Step-by-Step Diffusion: An Elementary Tutorial

Preetum Nakkiran, Arwen Bradley, Hattie Zhou, Madhu Advani

TL;DR

This tutorial provides a mathematically grounded yet accessible "first course" on diffusion models and flow matching. By stripping away the usual requirements of stochastic differential equations (SDEs) and variational inference, the authors demonstrate that the core of modern generative AI—like Stable Diffusion—can be understood through basic probability, linear algebra, and simple regression.

What Problem Does This Paper Address?

Diffusion models have revolutionized generative AI, but they are notoriously difficult to learn. Most introductory materials rely on heavy mathematical machinery: Variational Autoencoders (VAEs), Evidence Lower Bounds (ELBOs), or complex Langevin dynamics. This creates a high barrier to entry for students and engineers who want to understand why these models work rather than just how to implement them.

The authors address this pedagogical gap by deriving the two most popular sampling methods—DDPM (stochastic) and DDIM (deterministic)—using elementary calculus and "gas dynamics" analogies. They also bridge the gap to Flow Matching, a newer framework that generalizes diffusion into a more flexible system of "velocity fields."

Methods

The paper structures the learning path into three distinct algorithmic frameworks:

  1. Gaussian Diffusion (DDPM-like): The authors define a "forward process" that slowly adds Gaussian noise to data. The "aha" moment is Fact 1: for a small enough noise step, the reverse process is also nearly Gaussian. This allows the complex task of "generating data" to be solved as a simple regression problem (denoising).
  2. Deterministic Sampling (DDIM-like): Instead of sampling from a distribution at each step, this method treats the process as a transport map. The authors use a "gas" analogy: imagine data points as particles in a gas; if you know the velocity field of the gas, you can move the particles from a noisy state back to a clean state deterministically.
  3. Flow Matching: This is presented as a generalization of DDIM. It moves away from the rigid "adding noise" framework to a broader goal: learning a vector field that pushes an easy-to-sample "base" distribution (like a ring or a blob of noise) toward the target data distribution.

Datasets

As a tutorial, the paper focuses on illustrative toy datasets rather than massive benchmarks:

  • 1D Multi-modal Distributions: Used to visualize how diffusion "flattens" complex data into a Gaussian.
  • 2D Spiral Dataset: Used to demonstrate the trajectories of different samplers and the phenomenon of memorization vs. generalization.
  • Annular (Ring) Distribution: Used in the Flow Matching section to show how models can transport one arbitrary shape into another.

Key Insights and Ideas

  • The Regression Shortcut: The most profound insight is that we don't need to learn the entire complex distribution of data. We only need to learn the mean of the reverse step, which is a standard supervised learning (regression) task.
  • DDIM as a "Gas": By treating the sampling process as a velocity field, the authors prove that DDIM is a valid transport map. They show that a weighted average of individual "point-to-point" velocities correctly moves an entire distribution.
  • Linear Flows are "Slower": The paper explains that while DDIM trajectories are curved, "Linear Flows" (or Rectified Flows) use straight-line paths. Interestingly, DDIM is mathematically equivalent to a time-reparameterized linear flow, but linear flows are often more stable in practice because they are "slower" when the noise is small.
  • Generalization vs. Memorization: Through the spiral experiments, the authors show that with too few samples (e.g., N=10), a diffusion model simply "memorizes" the training points, causing all sampling trajectories to collapse into those specific points.

Key Results

  • Error Quantification: The paper provides a heuristic proof (and a formal appendix proof) that the Gaussian approximation used in DDPM has a KL-divergence error of $O(\sigma^4)$ per step. Since the number of steps scales as $1/\sigma^2$, the total error remains controlled as the step size shrinks.
  • Algorithmic Equivalence: The authors demonstrate that DDPM, DDIM, and Flow Matching are not competing theories but points on a continuum. Figure 11 in the paper provides a "commutative diagram" showing how these methods relate across discrete/continuous and stochastic/deterministic axes.

Limitations and Future Work

  • The "Black Box" of Training Error: The authors acknowledge that while we understand the error introduced by sampling (discretization error), it is still not fully understood how training errors in the neural network translate into the final distribution error of the generative model.
  • Scope: To keep the tutorial "elementary," the authors omit advanced topics like Guidance (how to tell a model to generate a specific thing, like "a dog") and Discrete Diffusion (diffusion for text or categorical data).
  • Theoretical Gaps: The paper notes that the learning-theoretic aspects of diffusion—how models learn properties of a distribution from finite samples—remain an active and open area of research.

Summary updated

BibTeX
@article{nakkiran2025step,
  author = {Preetum Nakkiran and Arwen Bradley and Hattie Zhou and Madhu Advani},
  title = {{Step-by-Step Diffusion: An Elementary Tutorial}},
  journal = {Found. Trends Comput. Graph. Vis.},
  year = {2025},
  doi = {10.1561/0600000114},
}

Loading related content...

Figure