Skip to content
E
Educatum

Sora's Diffusion Transformer

By Educatum AI teamLast updated: Original walkthrough ↗
Key Intuition

Sora's Diffusion Transformer (DiT) generates video by replacing convolutional U-Nets with a Transformer operating directly on spacetime patches in a compressed latent space. Adaptive layer normalization (adaLN) conditions each block on the diffusion timestep and text prompt embeddings so the model iteratively denoises random Gaussian noise into clean video latents before decoding to pixels.

Reference Diagram & Materials

Sora Diffusion Transformer (DiT): Step-by-Step

Objective: Generate video conditioned on a text prompt and diffusion timestep tt.

[1] Inputs

  • Original video (training target)
  • Text prompt: "sora is sky"
  • Diffusion timestep: t=3t = 3 (noise level index)

[2] Spacetime Patching

  • Divide the video (or compressed video latent) into spacetime patches (e.g., 2×22 \times 2 spatial patches across time).
  • Spacetime patches unify videos of varying resolutions, durations, and aspect ratios into a flat sequence of visual tokens that a Transformer can process natively.

[3] Visual Encoder (Latent Compression)

  • Encode raw pixels/patches into a lower-dimensional latent space (in practice via a pretrained causal 3D VAE; in the toy diagram, via learned linear weights, biases, and ReLU reducing 4→24 \to 2 dimensions).
  • Working in compressed latent space drastically reduces sequence length and compute cost.

[4] Forward Noise Addition (Training)

  • Corrupt the clean latent z0z_0 into a noisy latent ztz_t according to the noise schedule at timestep tt: zt=αˉt z0+1−αˉt ϵ,ϵ∼N(0,I)z_t = \sqrt{\bar{\alpha}_t}\, z_0 + \sqrt{1 - \bar{\alpha}_t}\, \epsilon, \qquad \epsilon \sim \mathcal{N}(0, I)
  • Noise schedule convention: t=0t = 0 corresponds to the clean latent, and larger tt corresponds to MORE noise (approaching pure isotropic Gaussian noise as t→Tt \to T).

[5-7] Conditional Control via Adaptive Layer Norm (adaLN)

  • Encode both the text prompt and the diffusion timestep tt into conditioning vectors.
  • Project those conditioning embeddings into per-channel scale (γ\gamma) and shift (β\beta) parameters (and residual gate parameters in adaLN-Zero).
  • Modulate the normalized latent token representations so every Transformer block knows both what to generate and how noisy the current input ztz_t is.

[8-10] Transformer Block Processing

  • Self-Attention: Compute pairwise attention scores across spacetime tokens to capture spatial and temporal dependencies.
  • Weighted Value Aggregation: Multiply the softmax attention weights by the Value vectors (VV) to aggregate context across patches.
  • Feed-Forward Network (FFN): Transform each token independently to output the predicted noise ϵθ(zt,t,c)\epsilon_\theta(z_t, t, c) (or velocity vθv_\theta, depending on parameterization).

[11] Training Objective

  • Compute the MSE loss between the predicted noise ϵθ(zt,t,c)\epsilon_\theta(z_t, t, c) and the true noise ϵ\epsilon added in step [4], then backpropagate to update the Diffusion Transformer weights (red borders in the diagram).
  • The pretrained visual encoder and decoder weights (blue borders) are kept frozen during DiT training.

[12] Iterative Denoising (Generation)

  • Starting from pure Gaussian noise zT∼N(0,I)z_T \sim \mathcal{N}(0, I) at inference, run reverse sampling steps from t=Tt = T down to t=0t = 0.
  • At each step tt, the DiT predicts the noise component in ztz_t, and the diffusion sampler (e.g., DDPM/DDIM) uses schedule coefficients to compute a slightly less-noisy latent zt−1z_{t-1}—repeating iteratively in latent space until z0z_0 is reached.

[13] Visual Decoder

  • Only once at t=0t = 0, pass the final denoised latent representation z0z_0 through the frozen visual decoder to reconstruct pixel patches.

[14] Reassemble Patches into Video

  • Unpatchify the decoded spatial-temporal patches into the final output video frames.

Diagram

Sora Diffusion Transformer walkthrough diagram

More in GenAI by Hand

Try keywords like RoPE, FlashAttention, DPO, or Blind 75.