Project P07
A diffusion model from scratch
How can an image diffusion model be built, trained, accelerated, and rigorously evaluated on an 8 GB GPU, and which design decisions actually explain its quality?
- stages
- 9
- duration
- 15 h 20 min
- concepts
- 20
- available in English
- 9 / 9
- completed by you
0 of 9
Where it fits
Overview
A generative-model project that starts with 2D diffusion with a known analytic score and reaches latent diffusion with a DiT. First build the evaluation pipeline, covering FID, KID, precision, recall, and their uncertainty. Then train a custom U-Net as a DDPM on CIFAR-10, implement deterministic and higher-order samplers, study the EDM formulation through ablations, apply classifier-free guidance, implement flow matching with rectification, perform latent diffusion over a pretrained autoencoder, and finish with few-step distillation and a memorization audit.
Why it matters
Diffusion and flow matching underpin image, video, and audio generation as well as robot policies such as Diffusion Policy, which you will use for imitation learning. Implementing the methods under a limited compute budget makes you determine how much quality comes from the parameterization, noise, sampler, or guidance, and evaluate it with metrics whose variance is known.
Stages 9
- 012D diffusion with a known scoreBuild and inspect a complete 2D diffusion system, using the exact score of a Gaussian mixture to diagnose the network, samplers and generated samples.
- 02Generative evaluation and the U-NetBuild a reproducible CIFAR-10 generative evaluation pipeline, analyze FID and KID, and implement and profile a time-conditioned diffusion U-Net.
- 03Training a DDPM on CIFAR-10Train and evaluate a CIFAR-10 diffusion model with reproducible schedules, ancestral sampling, EMA checkpoints and resumable runs.
- 04Fast samplers: DDIM, Heun and higher-order solversCompare DDIM, Euler, Heun and a second-order exponential solver by numerical error, network evaluations and FID, then invert and interpolate with DDIM.
- 05The EDM formulation and design ablationsRewrite diffusion training with EDM preconditioning and compare DDPM, v and EDM at equal compute to attribute improvements experimentally.
- 06Conditioning and classifier-free guidanceCondition diffusion on class, implement classifier-free guidance, and sweep its scale to measure the fidelity–diversity tradeoff.
- 07Flow matching and rectified flowLearn flow matching and reflow, measure trajectory straightness, and compare generation quality at equal compute.
- 08Latent diffusion with a DiTBuild a latent diffusion pipeline with a frozen VAE and a diffusion transformer trained by flow matching.
- 09Few-step generation and memorization auditDistill a diffusion teacher into few evaluations and audit generated images for memorization.
Final deliverable
Your own end-to-end generator
A conditional latent model trained on your own freely licensed image dataset, with a few-step sampler, guidance, an FID report under a fixed protocol, and a memorization audit.
Check what you already know
- Derive the forward-process marginal and the relationship between predicting noise and estimating the score
- Compute FID reproducibly and estimate how its bias and variance depend on sample size
- Train a DDPM with EMA and diagnose quality throughout training
- Implement DDIM and a Heun sampler for the probability-flow ODE
- Implement classifier-free guidance and explain the trade-off between fidelity and diversity
- Train a conditional flow-matching model and relate it to diffusion