Train and Sample Like 2026: Logit-Normal Steps, EMA, and Few-Step Flow
Logit-normal timestep sampling, EMA weights and rectified-flow reflow in PyTorch, measured on a tiny DiT, plus where latents and distillation go next.
Logit-normal timestep sampling, EMA weights and rectified-flow reflow in PyTorch, measured on a tiny DiT, plus where latents and distillation go next.
Classifier-free guidance in PyTorch: class labels, label dropout, the guidance formula, adaLN-Zero init, and measured results on a tiny DiT.
Build MMDiT joint attention in PyTorch: condition tokens, double-stream and single-stream blocks like SD3 and FLUX, measured against adaLN on a tiny DiT.
RMSNorm, QK-norm, SwiGLU and 2D RoPE in PyTorch: what each one does, the code, and a measured before/after on a tiny diffusion transformer.
torch.compile, bf16 autocast, GradScaler and SDPA added to a PyTorch trainer, with honest CPU benchmarks: what got faster, what got slower, and why.
Build a diffusion transformer (DiT) in PyTorch from scratch: timestep embedding, adaLN, the TinyDiT model, and a CPU training run on CIFAR-10 with scores.
Flow matching in PyTorch, step by step: the straight noise-to-data line, velocity loss, a 2D toy you can watch learn, and an Euler sampler for images.
PyTorch patch embedding explained: patchify and unpatchify images, a Linear patch embed, learned 2D position embeddings, and an image-in, image-out ViT.
PyTorch attention from scratch: Q, K, V, softmax(QKᵀ/√d), multi-head attention, and the pre-norm transformer block, checked against PyTorch's SDPA.
Build a PyTorch training loop: nn.Module, Linear, GELU, LayerNorm, residual blocks, AdamW, and a reusable Trainer that saves and resumes checkpoints.