The Annotated Diffusion Model
Denoising Diffusion Probabilistic Models (Ho et al., 2020) work by pairing a fixed forward process that gradually adds Gaussian noise to an image under a variance schedule with a learned reverse process that denoises step by step from pure noise. A closed-form property lets x_t be sampled directly from x_0, and a reparametrization of the mean turns training into a simple MSE loss on predicting the added noise at a randomly sampled timestep. The walkthrough derives this objective and then implements the model step by step in PyTorch: a U-Net with residual connections, sinusoidal timestep embeddings and weight-standardized ResNet blocks with group normalization, following Phil Wang's implementation.
Related posts
- PRX Part 3 — Training a Text-to-Image Model in 24h!
Hugging Face hardMasterA 24-hour, ~$1500 speedrun on 32 H200s combines the most effective diffusion training tricks into a single text-to-image recipe. The recipe uses x-prediction in pixel space with patch size 32 and no VAE, LPIPS and DINOv2 perceptual losses applied to pooled full images at all noise levels, TREAD token routing with dense-vs-routed self-guidance, REPA alignment to DINOv3 at block 8 on non-routed tokens only, and Muon for 2D parameters with Adam for everything else. Training ran 100k steps at 512px followed by 20k steps at 1024px on about 8.7M synthetic images. The resulting model follows prompts well, and its remaining artifacts look like undertraining rather than flaws in the recipe. Code and configs are open-sourced in the PRX repository.
- How Diffusion Controller unifies and simplifies AI image generation
Google Research hardMasterDiffusion Controller reframes diffusion denoising as a continuous control problem, unifying inference-time guidance and fine-tuning methods such as LoRA, reward-weighted regression and policy gradients under one framework. A lightweight trainable side network attached to a frozen backbone adds small corrections to the base model's score using the intermediate reverse mean, so it also works with gray-box, access-restricted models. On a Stable Diffusion v1.4 backbone across SFT, reward-weighted loss and PPO regimes, the gray-box controller beat LoRA on HPS-v2 win rates while touching fewer layers. The white-box variants reached about a 90% win rate over the baseline, and a single inference-time guidance-strength parameter dials alignment up or down.
- Finetune Stable Diffusion Models with DDPO via TRL
Hugging Face hardMasterDenoising Diffusion Policy Optimization (DDPO) fine-tunes diffusion models with reinforcement learning by treating the full denoising process as a multistep MDP. Because each step's policy is an isotropic Gaussian, it can use exact per-step likelihoods, unlike reward-weighted regression, which stacks approximations, and it then applies PPO with customized trajectory collection. TRL's new DDPOTrainer lets you fine-tune Stable Diffusion against a CLIP-based aesthetic reward model, needs at least an A100, and ships recommended single-GPU hyperparameters. LoRA training is stable and generalizes across prompts even with a small prompt set; full fine-tuning can give more intricate images but needs a low learning rate (~1e-5) and careful tuning.
- VQ-Diffusion
Hugging Face hardMasterVQ-Diffusion is a conditional latent diffusion model whose noising and denoising run over a discrete VQ-VAE codebook rather than Gaussian noise. Each token can stay, be uniformly resampled, or become permanently masked, and a CLIP-conditioned encoder-decoder transformer predicts the full distribution of un-noised latents in one pass. Compared with autoregressive image transformers, it avoids raster-order directional bias and error accumulation, and its inference cost scales with diffusion steps rather than latent pixels, roughly a 10x big-O gain on 32x32 ITHQ latents and up to 15x faster in practice. The model can be run in a few lines with the Diffusers VQDiffusionPipeline.
- Towards demystifying the creativity of diffusion models
Google Research hardMasterDiffusion models generalize beyond their training data because neural networks learn a smoothed version of the score function rather than the exact empirical one, which would only reproduce training samples. Regularization, whether explicit weight decay or the implicit bias of gradient training, softens the sharp transitions between training points, creating an interpolation zone where denoised samples settle between known data. A 1-D experiment with two-layer ReLU networks trained by AdamW shows this directly. In higher dimensions the smoothing acts mainly along directions tangential to the data manifold, so samples still converge onto the manifold while spreading between training points, which balances quality and novelty. The work is from an ICLR 2026 paper, and code is released.