mlgenerate.comVisual Generative ML
All Models/image/DiT Latent Diffusion

Diffusion Transformer (DiT in Latent Space)

Diffusion2023 · UC Berkeley / NYU (Peebles & Xie)

ViT patchified latent score-matching with AdaLN-Zero conditioning

Execution Paradigm:Latent DiT Score Denoising & VAE Surface Decoding
Full-Patch Parallel Iterative Denoising

Intuition & Key Idea

ELI5 Guide

Why this model was invented and how it transforms generation

The 30-Second Core Idea

"Replaces old complex convolutional U-Nets with pure, scalable Transformer blocks operating directly on compressed image patches."

Real-World Metaphor

Replacing a specialized mechanical film camera with a modern modular digital sensor that scales smoothly as you add more compute power.

Key Superpowers & Values
Scaling LawScales Like LLMs
Predictable Scaling

Higher FLOPs consistently yields lower Fréchet Inception Distance (FID).

ConditioningZero Overhead
adaLN-Zero Modulation

Modulates layer norm scales and shifts directly from timestep and prompt.

EfficiencyLatent Space
8x Compressed Latents

Operates in VAE latent space (32x32 patches) rather than raw pixels.

Industry BackboneStandard SOTA
Sora, SD3, Flux

The universal foundational architecture for modern video and image generation.

1. Sample Gaussian Latent Noise Prior z_T

Draw initial latent noise z_T from standard normal distribution matching the 8x downsampled resolution (e.g. 4 × 64 × 64 for a 512×512 image).

Key Insight:

Operating in 8x latent space saves 64x compute compared to high-resolution pixel space diffusion.

Interactive Stage (INFERENCE)Initial 64x64 latent noise is drawn from standard normal prior.
DDPM Reverse Denoising SamplingNoise Factor: 100%

Starting from random Gaussian white noise, the neural network predicts and subtracts the noise component over iterative steps.

Simulated 8×8 Latent Patch (x_t)
Signal √ᾱ_t: 0%Noise √(1 - ᾱ_t): 100%
State Equation & Score Function
x_{t-1} = μ_θ(x_t, t) + σ_t · z
Loss: L_simple = ||ε - ε_θ(x_t, t)||^2
Forward Pass:O(K) Iterative Steps
Network Architecture:U-Net or Diffusion Transformer (DiT)
Hardware & Weights InspectorStep 1: Sample Gaussian Latent Noise Prior z_T
Execution Bottleneck
Memory-Bandwidth Bound
Memory-bandwidth bound
Arithmetic Intensity
0.1 FLOPs/Byte (RNG generation)
Ratio of math operations (FLOPs) to memory traffic (Bytes)
Dominant GPU Kernel
CURAND Gaussian Generator
Optimized CUDA / Triton kernel launched

GPU Memory Hierarchy & HBM Traffic for this Step

HBM ↔ SRAM on-chip

Initial noise written to GPU VRAM buffer

Hardware Insight: Pre-allocating latent buffers avoids dynamic memory allocation overhead during sampling.

Active Tensor Dimensions & Memory Shapes

z_T[B, 4, 64, 64]
Initial latent noise canvas
sample_dit_latent.py
1
def sample_dit_latent(dit, vae, prompt, steps=30, cfg_scale=5.0):
2
z = torch.randn(1, 4, 64, 64) # 64x downsampled latent space
3
for t in reversed(range(steps)):
4
# Parallel CFG forward pass across conditional and unconditional branches
5
eps_cond, eps_uncond = dit.forward_cfg(z, t, prompt)
6
eps = eps_uncond + cfg_scale * (eps_cond - eps_uncond)
7
z = scheduler.step(eps, t, z) # Denoise 1 step
8
# Final single-pass VAE decoding to RGB pixel manifold
9
return vae.decode(z / 0.18215) # [1, 3, 512, 512]
Click code line to jump to corresponding stepPyTorch Reference
Why This Architecture Matters

Proved that visual diffusion scales with compute like LLMs (more FLOPs directly yields lower FID). Became the foundational architecture behind Sora, Stable Diffusion 3, Flux.1, and modern video generation.

Runtime Complexity & Bottlenecks

Training Objective:Latent Noise Prediction MSE: 𝔼_{t, z_0, ε}[ ||ε - DiT_θ(z_t, t, c)||^2 ]

Inference Bottleneck:O(K) transformer forward passes over fixed patch tokens (e.g. 20–50 steps)