Denoising Diffusion Probabilistic Models (DDPM)¶
This directory contains comprehensive documentation on Denoising Diffusion Probabilistic Models (DDPM), the foundational discrete-time diffusion model introduced by Ho et al. (2020).
Overview¶
DDPM is a class of generative models that learns to generate data by reversing a gradual noising process. It achieves state-of-the-art results across multiple domains and provides a principled probabilistic framework for generation.
Why Study DDPM?¶
- Foundational model: Understanding DDPM is essential for modern diffusion models
- Theoretical depth: Connects variational inference, score matching, and SDEs
- Practical success: State-of-the-art image generation, protein design, molecular generation
- Training simplicity: Simple MSE loss, no adversarial training
- Interpretability: Clear probabilistic interpretation via ELBO
Documents in This Directory¶
Core Theory¶
- 01_ddpm_foundations.md — Mathematical Foundations ⭐
- Forward and reverse processes
- Closed-form marginals
- Variational lower bound (ELBO)
- Noise prediction parameterization
- Connection to score matching
- Training and sampling algorithms
Practical Implementation¶
- 02_ddpm_training.md — Training Details ⭐ NEW
- Loss function variants (simple vs. weighted ELBO)
- Architecture choices (U-Net, MLP, DiT)
- Time embeddings and conditioning strategies
- Conditional generation methods
- Hyperparameter tuning
-
Training tips and common issues
-
03_ddpm_sampling.md — Sampling Methods ⭐ NEW
- DDPM ancestral sampling (stochastic)
- DDIM deterministic sampling
- Fast sampling via step skipping
- Classifier-free guidance (see detailed guide below)
- Quality vs. speed trade-offs
Extensions and Advanced Topics¶
- Classifier-Free Guidance — Comprehensive Guide ⭐
- Conditional generation without classifiers
- Training procedure (condition dropping)
- Guidance scale and its effects
- Implementation in both DDPM and SDE views
- Variants: dynamic guidance, negative prompting
Coming Soon¶
- 04_ddpm_extensions.md — Extensions and Variants (Planned)
- Improved DDPM (learned variance)
- Latent diffusion models
- Discrete diffusion
- Domain-specific adaptations
Quick Navigation¶
For Beginners¶
Start here: DDPM Foundations
This document provides a complete mathematical introduction from first principles, covering: - The forward noising process - The reverse denoising process - Training via ELBO - The simple noise prediction loss - Sampling algorithms
Then:
1. Read DDPM Training for practical training details
2. Read DDPM Sampling for sampling algorithms
3. Work through the DDPM Basics Notebook: notebooks/diffusion/01_ddpm/01_ddpm_basics.ipynb
For Deep Dive¶
After understanding the foundations: 1. Study the SDE perspective to see DDPM as a discretization 2. Review the continuous limit to understand VP-SDE 3. Explore DDIM update coefficients for exact formulas 4. Read Reverse SDE & Probability Flow ODE for sampling theory
For Implementation¶
- Documentation:
- Training Details — Architectures, loss functions, hyperparameters
-
Sampling Methods — DDPM, DDIM, fast sampling, guidance
-
Notebook:
notebooks/diffusion/01_ddpm/01_ddpm_basics.ipynb - Complete PyTorch implementation
- Gene expression application
- Conditional generation
-
Training and sampling code
-
Source code:
src/genailab/diffusion/ - Production-ready implementations
- Modular components
- Reusable utilities
Key Concepts¶
Forward Process (Data → Noise)¶
Gradually add Gaussian noise over \(T\) steps:
Closed-form: Jump directly to any timestep:
Reverse Process (Noise → Data)¶
Learn to denoise step by step:
Training Objective¶
Simple MSE loss on noise prediction:
Sampling Algorithm¶
1. Start with x_T ~ N(0, I)
2. For t = T, ..., 1:
- Predict noise: ε_θ(x_t, t)
- Compute mean: μ_θ
- Add noise: x_{t-1} = μ_θ + σ_t * z
3. Return x_0
Connections to Other Frameworks¶
Score Matching¶
DDPM implicitly learns the score function:
Predicting noise ≈ predicting score (up to scaling).
Stochastic Differential Equations (SDEs)¶
DDPM is a discretization of the VP-SDE:
See: VP-SDE to DDPM
Variational Autoencoders (VAEs)¶
DDPM can be viewed as a hierarchical VAE with: - Markovian latent structure - Fixed encoder (forward process) - Learned decoder (reverse process)
Learning Path¶
Recommended Order¶
- Foundations (this directory)
- Start with DDPM Foundations
- Understand forward/reverse processes
-
Learn the training objective
-
Practical Training (this directory)
- Read DDPM Training
- Learn architecture choices
-
Understand hyperparameters and conditioning
-
Sampling Methods (this directory)
- Read DDPM Sampling
- Compare DDPM vs. DDIM
-
Learn fast sampling and guidance
-
Implementation (notebooks)
- Work through DDPM Basics:
notebooks/diffusion/01_ddpm/01_ddpm_basics.ipynb - Implement training loop
-
Generate samples
-
Theory (SDE directory)
- Study SDE View
- Understand continuous-time perspective
-
Connect discrete and continuous
-
Advanced Topics
- Latent diffusion models
- Domain-specific applications
- State-of-the-art techniques
Applications¶
Image Generation¶
- Unconditional: Generate diverse images from noise
- Conditional: Text-to-image, class-conditional
- Inpainting: Fill missing regions
- Super-resolution: Upscale low-resolution images
Biological Data¶
- Gene expression: Generate cell states (see
notebooks/diffusion/01_ddpm/01_ddpm_basics.ipynb) - Protein design: Generate protein sequences and structures
- Drug response: Predict perturbation effects (scPPDM)
- Single-cell data: Generate realistic cell populations
Other Domains¶
- Audio: Speech synthesis, music generation
- Video: Frame prediction, video synthesis
- Molecular: Drug design, molecular generation
- 3D: Point clouds, meshes, NeRF
Comparison with Other Generative Models¶
| Model | Training | Sampling | Quality | Diversity | Likelihood |
|---|---|---|---|---|---|
| DDPM | Stable | Slow | Excellent | High | Approximate |
| GAN | Unstable | Fast | Excellent | Medium | No |
| VAE | Stable | Fast | Good | High | Exact |
| Flow | Stable | Fast | Good | High | Exact |
DDPM advantages:
- Training stability (no adversarial training)
- High sample quality
- Flexible conditioning
- Theoretical foundations
DDPM disadvantages:
- Slow sampling (1000 steps)
- Approximate likelihood
- High computational cost
Historical Context¶
Timeline¶
- 2015: Sohl-Dickstein et al. introduce diffusion models (ICML)
- 2019: Song & Ermon connect to score matching (NeurIPS)
- 2020: Ho et al. introduce DDPM (NeurIPS) — breakthrough results
- 2021: Nichol & Dhariwal improve DDPM (ICML)
- 2021: Song et al. introduce SDE framework (ICLR 2021)
- 2021: Dhariwal & Nichol beat GANs (NeurIPS)
- 2022: Rombach et al. introduce Latent Diffusion (CVPR)
- 2022: Ramesh et al. introduce DALL-E 2 (arXiv)
Key Papers¶
- Sohl-Dickstein et al. (2015): Deep Unsupervised Learning using Nonequilibrium Thermodynamics
- Ho et al. (2020): Denoising Diffusion Probabilistic Models
- Song et al. (2021): Score-Based Generative Modeling through SDEs
- Nichol & Dhariwal (2021): Improved Denoising Diffusion Probabilistic Models
- Dhariwal & Nichol (2021): Diffusion Models Beat GANs on Image Synthesis
Related Documentation¶
In This Repository¶
- SDE Formulation: docs/SDE/
- Continuous-time perspective
- Fokker-Planck equation
- Score matching connections
-
Diffusion Models: docs/diffusion/
- Historical Development — How DDPM, score-based, and flow-based models unified
- Classifier-Free Guidance — Conditional generation
- Brownian Motion Tutorial
-
General diffusion theory
-
Notebooks:
notebooks/diffusion/ - DDPM basics implementation
- SDE formulation with code
- Advanced topics
External Resources¶
- Original papers: See references in 01_ddpm_foundations.md
- Tutorials:
- Lilian Weng's blog
- Yang Song's blog
- Code:
- Official DDPM repo
- Hugging Face Diffusers
Contributing¶
This documentation is part of the genai-lab project. To contribute:
- Follow the tutorial/blog style established in existing documents
- Use proper LaTeX notation (
$$...$$for blocks,$...$for inline) - Include intuition alongside mathematics
- Add examples and visualizations where helpful
- Link to related documents
Summary¶
DDPM is a foundational generative model that: - Learns to reverse a gradual noising process - Trains via simple MSE loss on noise prediction - Achieves state-of-the-art sample quality - Connects to score matching and SDEs - Provides a principled probabilistic framework
Start with: DDPM Foundations for a complete mathematical introduction.