Stable Diffusion 3

SD3 draws an image in a handful of steps where curved diffusion paths need dozens, because it moves along a straight line from noise to data. Going from 50 steps to 5 costs its 8B model only 2.71% of CLIP score.

Pick a step budget and press Walk both paths. Watch the curved path drift off its target while the straight one lands. Then we build, piece by piece, the flow, the two-stream transformer, the three text encoders and the training recipe behind it.

You need diffusion models, transformers and latent representations (a small code for an image). We build the rest from zero.

Based on Esser, Kulal, Blattmann, Entezari, et al. (Stability AI), 2024, “Scaling Rectified Flow Transformers for High-Resolution Image Synthesis”. Read the paper.

Walk from data to noise

Toy geometry, not the paper’s model: the curved path is the quarter circle that variance-preserving schedules trace, the straight path is the rectified-flow line, and each step is a plain Euler step that follows the direction at the start of the step. Real samplers are smarter than plain Euler. The 2.71% CLIP-score loss from 50 to 5 steps is the paper’s number for its 8B model.

Chapter 0

The Problem

See the three stubborn problems of text-to-image diffusion that SD3 sets out to fix

By early 2024, diffusion models dominated image generation. SDXL, DALL-E 3 and Midjourney could produce stunning images from text. But three stubborn problems remained.

  1. Slow sampling. Standard diffusion models like DDPM define curved paths from noise to data. These curved trajectories need many neural network evaluations (often 50 or more) to follow accurately. Each evaluation is a full forward pass through a billion-parameter model, and that is expensive.
  2. Weak text understanding. U-Net models feed text through cross-attention, which treats it as a static conditioning signal. The text representation never gets to “talk back” to the image representation. The result is poor typography, missed objects and wrong spatial arrangements.
  3. Unclear scaling. In language models, doubling the parameters predictably improves the loss. Diffusion models with U-Net backbones had no clean scaling laws. You could not predict whether a bigger model would actually help.

The hero at the top of this page shows the first problem. Both plots take the same number of steps. One path is curved and the other is straight. Only one of them lands on its target.

The goal: Build a text-to-image system with (1) straight-line trajectories that need fewer sampling steps, (2) an architecture where text and image representations deeply interact, and (3) predictable scaling behavior. SD3 delivers all three by combining rectified flow with a novel Multimodal DiT (MMDiT) architecture.

The road

Each part of the instrument at the top has a chapter that explains it. The chapters follow the three problems in order, then widen out to the evidence.

  1. Rectified flow: the straight path, its constant velocity, and the loss that learns it.
  2. The MMDiT architecture: two streams, one joint attention, with every tensor shape.
  3. Text conditioning: three frozen encoders and why each one is needed.
  4. Training: logit-normal timesteps, the resolution shift and what is frozen.
  5. Scaling laws: loss falls smoothly with depth, and big models need fewer steps.
  6. Results: GenEval, human preference and what degrades when you remove a part.
  7. Comparison with SDXL and DALL-E 3: what changed, side by side.
  8. The autoencoder: the 16-channel latent that sets the ceiling on image quality.
  9. Connections: DiT, DDPM, flow matching, Flux and latent diffusion.
Why do standard DDPM-style diffusion models require many sampling steps?

Chapter 1

Rectified Flow

Draw the data-to-noise path as a straight line, and learn the one constant velocity that walks it

All diffusion-style models share one core idea: define a forward process that turns data into noise, then learn to reverse it. The question is what path the forward process takes.

The forward process

Take a data sample x0 and noise ε ~ N(0, I). Define the noisy sample at time t like this:

zt
The noisy sample at time t. It is the thing the network sees.
(1 − t)
How much clean data is left. It falls from 1 to 0 as t goes from 0 to 1.
x0
The clean data sample, here the image latent.
t
How much noise is mixed in. It rises from 0 to 1.
ε
A draw of Gaussian noise, the same shape as the data.

At t = 0, z0 = x0, which is pure data. At t = 1, z1 = ε, which is pure noise. For any t in between, zt is a linear interpolation between data and noise. This is the defining property of rectified flow: the path from data to noise is a straight line.

x0 = 1, ε = −1, t = 0.25 → zt = 0.75 × 1 + 0.25 × (−1) = 0.5 (one pixel, one quarter of the way to noise)

Why straight lines matter

Compare this with DDPM, which uses a variance-preserving schedule: zt = αt x0 + σt ε. Here αt and σt follow specific curved schedules. The DDPM path from data to noise is curved, because the signal and the noise do not mix linearly.

Why does this matter? At inference time you follow these paths backwards. A curved path needs many small steps to trace accurately, like driving on a winding mountain road. A straight path can in theory be crossed in a single step, like a highway.

The key insight: Rectified flows connect data and noise along straight lines. The velocity along these lines is constant: v = ε − x0. A neural network learns to predict this velocity. Because the trajectory is straight, even a crude Euler solver with few steps stays close to the true path. Fewer steps means faster sampling.

Try it yourself. Switch between the two paths, then drag the step count. Each step moves in the direction the path points at the start of the step.

Trace a path with few steps

Left: the path from data (bottom right) to noise (top left), with your steps drawn on it. Right: how far the last step misses the noise end, for every step count. Choose a path, then drag the steps.

5

Toy geometry: the horizontal axis is the data part of zt and the vertical axis is the noise part. Straight: (1 − t, t). Curved: (cos πt/2, sin πt/2), the variance-preserving circle. The miss is the distance from the last Euler point to the true noise end, as a share of the path radius. It is computed live in your browser.

On the straight path the miss is exactly zero for any step count, even one. On the curved path each step follows the direction at its start, and the curve turns away underneath it. The errors pile up and the walk spirals outward.

The training objective

The network vΘ learns the velocity field by minimizing the conditional flow matching loss:

LCFM
The conditional flow matching loss. Lower is better.
Et, x0, ε
The average over random timesteps, data samples and noise draws.
vΘ(zt, t)
The network’s guess of the velocity, given the noisy sample and the time.
ε − x0
The true velocity: the constant direction from data to noise.

The target velocity ε − x0 is constant for a given (x0, ε) pair. It does not depend on t. This makes the learning problem simpler than DDPM’s time-dependent noise prediction.

target v = −1 − 1 = −2; the network says −1.6 → loss = (−1.6 − (−2))2 = 0.16 (same pixel as above)

What is the velocity target that the rectified flow network learns to predict?

Chapter 2

The MMDiT Architecture

Follow one image and one prompt through two streams that meet in a single joint attention

Earlier text-to-image models (Stable Diffusion 1 and 2, SDXL) use a U-Net backbone with cross-attention. The image features attend to the text features, but the text features are frozen. They never see what the image is doing. This is a one-way street.

SD3 replaces the U-Net with a Multimodal Diffusion Transformer (MMDiT). It treats text and image as two parallel streams that interact through joint attention.

Two streams, one attention

The MMDiT block has two independent pathways:

  1. Image stream: processes patch embeddings of the noisy latent zt.
  2. Text stream: processes token embeddings from the text encoders.

Each stream has its own LayerNorm, its own linear projections for Q, K and V, and its own MLP. For the attention step, the two sequences are concatenated and attention is computed jointly. Every image patch can attend to every text token, and every text token can attend to every image patch.

Why this matters: In cross-attention (SDXL), text tokens are read-only: the image attends to text, but the text never updates based on the image. In MMDiT’s joint attention, both modalities evolve together. The text representation can adapt to what the image looks like at each denoising step. This two-way flow is why SD3 excels at typography, spatial reasoning and compositional prompts.

Step through one block below. The image stream is blue and the text stream is purple. Watch where they meet.

Follow one MMDiT block

Two parallel streams with separate weights for the norm, the Q/K/V projections and the MLP. They merge only for the joint attention, then split back. Drag the stage to light the block up step by step.

7

Drawn from the block described in the paper: separate weights per stream, concatenation only inside attention, and shared modulation from the timestep and the pooled text embedding. Token counts are for a 1024×1024 image (see the shapes below).

Modulation via timestep

Both streams are modulated by the diffusion timestep t and a pooled text embedding y (from CLIP). These modulation parameters (α, β, γ) scale and shift the hidden states. This is identical to DiT’s adaptive layer norm (adaLN). Each stream gets its own set of modulation parameters, so the same timestep signal can affect text and image processing differently.

Scaling the model

One parameter controls model size: the depth d, the number of MMDiT blocks. The hidden dimension is 64d, the MLP expands to 4 × 64d, and there are d attention heads. This gives a clean scaling axis: d = 15 is about 500M parameters, d = 24 is about 2B, and d = 38 is about 8B.

The full forward pass with shapes (1024×1024 generation, d = 38)

Noise zt
128 × 128 × 16 latent (from the 16-channel VAE)
↓
Patchify (2×2)
128×128×16 → 64×64 = 4096 image tokens, each of dim 16×4 = 64 → projected to hidden dim 64×38 = 2432
↓
Text context
~410 text tokens, each projected to dim 2432 → text stream
↓
38 × MMDiT Block
Joint attention: concat [4096 image; ~410 text] = ~4506 total tokens for attention. Each block: LN + QKV (separate weights per stream) → joint attention → split → residual → LN + MLP (4×2432 = 9728 hidden) → residual. 38 attention heads.
↓
Unpatchify
4096 tokens × 2432 → linear to 64 → reshape to 128×128×16 → velocity prediction vθ
↓
Euler step
zt−Δt = zt − Δt · vθ(zt, t) → repeat for N steps
↓
VAE Decoder
128×128×16 → 1024×1024×3 RGB image
Engineering decisions: Why joint attention instead of cross-attention? Cross-attention keeps text frozen: text tokens never update based on what the image looks like. In compositional prompts (“red ball LEFT of blue cube”), the model must link spatial image regions to specific text tokens. That needs two-way flow. Joint attention gives it, at the cost of a longer sequence (~4506 tokens instead of 4096), which adds about 10% to the attention cost. The payoff is much better compositional accuracy (GenEval 0.74 against SDXL’s 0.55).

QK-Normalization

When you finetune at high resolution, the attention logits can grow without bound. The largest attention values explode and cause entropy collapse: all attention weight lands on one token. SD3 applies RMSNorm to Q and K before computing attention. This stabilizes training and allows efficient bf16 mixed precision, even at 1024×1024.

What is the key difference between MMDiT’s joint attention and the cross-attention used in SDXL?

Chapter 3

Text Conditioning

Meet the three frozen encoders and see why SD3 needs all of them to read a prompt

SD3 does not rely on a single text encoder. It uses three pretrained text models. Each captures a different aspect of the prompt.

CLIP-L/14

OpenAI’s CLIP with a ViT-L/14 image encoder. It produces a 77-token sequence embedding and a pooled 768-dim vector. It is good at visual-semantic alignment: it knows what words “look like”, because it was trained on image-text pairs.

CLIP-G/14

A larger CLIP variant (ViT-bigG/14). It also produces 77 tokens and a pooled vector. The larger model captures more nuanced visual concepts.

T5-XXL

Google’s 4.7B-parameter text-to-text transformer. CLIP learns from image-text pairs, but T5 is a pure language model. It understands complex sentence structure, negation, spatial relationships and counting: exactly the things CLIP struggles with.

How they combine

The two CLIP models provide the pooled text embedding y (concatenated, then projected). It drives the timestep modulation in every MMDiT block. The sequence outputs of all three encoders are concatenated into the context sequence c (77 + 77 tokens from CLIP, plus the T5 tokens). It forms the text stream in MMDiT’s joint attention.

Exact data flow with shapes

Text prompt
“A golden retriever on a red couch” → tokenize
↓
CLIP-L/14
77 tokens × 768 dim + pooled vector 768-dim. ~124M params, frozen.
↓
CLIP-G/14
77 tokens × 1280 dim + pooled vector 1280-dim. ~1.8B params, frozen.
↓
T5-XXL
Up to 256 tokens × 4096 dim. 4.7B params, frozen.
↓
Pooled embedding y
Concat CLIP-L pool (768) + CLIP-G pool (1280) → project to 2048 dim → timestep modulation for all MMDiT blocks
↓
Context sequence c
Concat: CLIP-L (77×768) + CLIP-G (77×1280) + T5 (up to 256×4096) → each padded or projected to match the MMDiT hidden dim → ~410 text tokens form the text stream
Why three encoders? CLIP encoders are excellent at visual-semantic grounding (“what does a cat look like?”) but weak at language understanding (“the red ball is to the left of the blue cube”). T5 is the opposite: strong language understanding, but no visual grounding. Together they cover both. The paper shows that removing T5 significantly degrades performance on compositional prompts, while removing CLIP hurts visual quality.
What degrades when you drop encoders: Removing T5-XXL drops GenEval from 0.74 to about 0.62. The model loses counting, spatial reasoning and complex attribute binding. Removing both CLIPs and keeping T5 hurts visual quality (blurry textures, poor color fidelity). You need the full trio for the best results. At inference, the text encoders add about 6.6B frozen parameters to memory, but they run once per prompt, not once per denoising step.
Improved captions: The training data uses a 50/50 mix of original human-written captions and synthetic captions generated by CogVLM. Human captions tend to be sparse (“a dog”). Synthetic captions describe the full scene (“a golden retriever sitting on a red couch in a sunlit living room”). This mix greatly improves the model’s ability to follow detailed prompts on GenEval benchmarks.
Why does SD3 use T5 in addition to CLIP for text encoding?

Chapter 4

Training

Pick the timesteps that teach the most, shift the noise for big images, and see what stays frozen

Two training innovations separate SD3 from vanilla rectified flow: logit-normal timestep sampling and resolution-dependent shifting.

Logit-normal timestep sampling

In standard rectified flow, timesteps t are sampled uniformly from [0, 1]. But not all timesteps are equally informative. Near t = 0, zt is almost pure data, which is easy to predict. Near t = 1, zt is almost pure noise, and the prediction target is roughly the dataset mean. The hardest and most informative predictions are at intermediate timesteps.

SD3 samples timesteps from a logit-normal distribution:

πln(t; m, s)
How likely training is to pick timestep t. The density integrates to 1.
1 / (s√(2π) t(1−t))
The normalizer. The factor t(1−t) in the bottom stretches the ends of [0, 1], so a bell shape in logit space stays a valid density on [0, 1].
exp(−(logit(t) − m)2 / 2s2)
A bell curve in logit space. m is where it centers and s is how wide it is.

Here logit(t) = log(t / (1−t)). With m = 0 and s = 1, this puts most of the sampling weight on intermediate timesteps while still covering the endpoints with some probability.

m = 0, s = 1: πln(0.5) = 1 / (2.507 × 0.25) = 1.60, but πln(0.05) = 0.11 (uniform sampling gives 1.00 everywhere)

Reshape the timestep sampler

The dashed line is uniform sampling. The teal curve is logit-normal. It biases training toward the most informative intermediate timesteps. Drag m to slide the peak and s to widen or narrow it.

0.0
1.00

The curve is the density in the equation above, computed live and scaled to its own peak. The share of training in the middle is the area under the curve between t = 0.2 and t = 0.8; uniform sampling puts exactly 60% there. The paper’s best variant is rf/lognorm(0, 1), which is m = 0, s = 1.

Resolution-dependent timestep shifting

Higher resolution images have more pixels, so they need more noise to destroy the signal. Think of it this way: a 1024×1024 image has 16 times more pixels than a 256×256 image. Average the noisy pixels as a rough estimate of the clean image. The law of large numbers gives a much better estimate with more pixels. So the same amount of noise is “less noisy” at higher resolution.

SD3 addresses this with a resolution-dependent shift. Take a model pretrained at resolution n and finetuned at resolution m. The timestep mapping is:

tm
The timestep to use at the new, higher resolution.
√(m/n)
The shift, called α. It grows with the resolution jump. It pushes every timestep toward more noise.
tn
The timestep at the original resolution.

The paper finds shifts above 1.5 work best for 1024×1024, and it uses a shift of α = 3.0. The mapping pushes the noise schedule to add more noise at each timestep, which compensates for the higher resolution. (With the 16 times pixel ratio above, √(m/n) would come to 4. The paper’s human study picks 3.0.)

α = 3, tn = 0.5 → tm = 3 × 0.5 / (1 + 2 × 0.5) = 0.75 (the halfway noise level moves to three quarters)

Empirical validation: The paper runs a human preference study over different shift values for 1024² sampling. Shifts above 1.5 are strongly preferred, with diminishing differences among higher values. α = 3.0 is used for all final models.

Frozen vs. trained components

ComponentParametersStatus
CLIP-L/14~124MFrozen (pretrained by OpenAI)
CLIP-G/14~1.8BFrozen (pretrained, OpenCLIP)
T5-XXL encoder4.7BFrozen (pretrained by Google)
VAE (16-ch)~80MPretrained separately, frozen during MMDiT training
MMDiT (d=38)~8BTrained from scratch

The total system is about 14.7B parameters. Of those, only the 8B MMDiT is trained for the diffusion task. The 6.7B in the text encoders and the VAE are pretrained and frozen. They provide the “language” and “pixel” expertise, while MMDiT learns to compose them.

Why rectified flow instead of DDPM?

Three concrete reasons:

Why does the logit-normal distribution improve training over uniform timestep sampling?

Chapter 5

Scaling Laws

Watch validation loss fall smoothly with depth, and see why bigger models survive fewer steps

One of SD3’s most important contributions is showing that MMDiT follows predictable scaling trends, just like language models.

Validation loss scales with compute

The paper trains MMDiT models at depths d = 15, 18, 21, 24, 30 and 38 (roughly 500M to 8B parameters) for 500k steps each on 256² images. The validation loss decreases smoothly and predictably as model size increases. There are no diminishing returns: the curves do not flatten out, which suggests that even larger models would keep improving.

Lower loss = better images

This sounds obvious but is not guaranteed. Many generative models show poor correlation between training loss and sample quality. SD3 shows a strong, monotonic relationship: lower validation loss consistently goes with better CLIP scores, better FID and better human preference ratings.

Why scaling laws matter: If you can predict performance from a compute budget, you can choose a model size before you spend millions on training. This is the same insight that powered GPT-3 and GPT-4, now applied to image generation. The clean scaling axis of MMDiT (change only the depth d) makes this possible. In U-Nets, scaling is ad hoc.

Larger models are more sample-efficient

The 8B model (d = 38) loses only 2.71% CLIP score when you cut from 50 to 5 sampling steps. The 500M model (d = 15) loses 4.30%. Larger models learn straighter trajectories, so they tolerate aggressive step reduction better. Bigger models are not only better but also faster per quality level.

Cut the sampling steps

Each bar is a quality score for one model depth at the step count you choose. Larger models give up less as you cut steps. Drag the steps down toward 5.

50

Illustrative. Only the end points are quoted in the paper’s text: validation loss 0.62 (d=15) and 0.40 (d=38), and the CLIP-score drops from 50 to 5 steps of 4.30% (d=15) and 2.71% (d=38). The middle depths, and the curve between 5 and 50 steps, are smooth interpolations. The score is (1 − loss) × (1 − drop), a toy index for comparing depths, not a published metric.

What property of larger MMDiT models makes them more sample-efficient at inference time?

Chapter 6

Results

Read the GenEval scores, the human votes and the cost of removing each part

SD3’s 8B model reaches state-of-the-art performance on several benchmarks. It beats both open-source and closed-source alternatives.

GenEval benchmark

GenEval tests compositional text-to-image generation. Can the model render the right number of objects, in the right colors, in the right positions? SD3 (d = 38, 1024², DPO-aligned) scores 0.74 overall. DALL-E 3 scores 0.67 and SDXL scores 0.55.

The breakdown is striking:

Compare the GenEval scores

Overall GenEval scores measure compositional text-to-image generation. Pick a skill to see SD3 against DALL-E 3 and SDXL on it.

All values are the paper’s GenEval scores as quoted in this chapter (SD3 is the 8B model with DPO). Bars start at zero and a higher bar is better.

Human preference evaluation

In head-to-head human evaluations on PartiPrompts, SD3 wins against SDXL Turbo, SDXL, Pixart-α and DALL-E 3 on visual quality, prompt following and typography. The typography advantage is particularly large. It is a direct benefit of MMDiT’s joint attention, which lets the model “see” text tokens while it generates image patches.

What degrades and when

Concrete inference numbers (8B model, 1024×1024): Text encoding runs once: CLIP-L (~0.1s) + CLIP-G (~0.3s) + T5-XXL (~0.8s) = ~1.2s. Then 50 Euler steps, each needing one MMDiT forward pass through 4506 tokens with 38 layers = ~28 Gflops per step × 50 = ~1400 Gflops. Classifier-free guidance doubles this to ~2800 Gflops. Total inference: ~8 to 12 seconds on a single A100 GPU. VAE decode: ~0.2s. Total wall-clock: ~10 to 14 seconds per image.
Typography breakthrough: SD3 is the first open-source model to render text reliably in images. Earlier models struggled because text tokens and image patches lived in separate worlds (cross-attention). MMDiT’s joint attention lets the model link character-level text information to specific spatial patches, which enables coherent letter rendering.
On the GenEval benchmark, which capability shows the largest improvement of SD3 over DALL-E 3?

Chapter 7

Comparison with SDXL & DALL-E 3

Set SD3 beside its two rivals and see why each design choice matters

Seeing what changed from SDXL to SD3 shows why each design choice matters.

SDXL vs SD3: Architecture

SDXL
U-Net backbone • Cross-attention to text (one-way) • CLIP-L + CLIP-G • 4-channel latent • ε-prediction • DDPM schedule
↓
SD3
MMDiT backbone • Joint attention (two-way) • CLIP-L + CLIP-G + T5-XXL • 16-channel latent • v-prediction (velocity) • Rectified flow

DALL-E 3 vs SD3

DALL-E 3 (OpenAI) uses a U-Net with cross-attention and a two-stage approach. A prior model generates CLIP embeddings from text, then a diffusion model generates images from those embeddings. SD3 removes this two-stage pipeline entirely. The text encoders feed straight into MMDiT.

DALL-E 3’s key innovation was training on highly descriptive synthetic captions. SD3 adopts this idea (50/50 original and CogVLM synthetic captions) and also advances the architecture and the noise formulation.

Step efficiency comparison

This is where rectified flow shines. SD3’s performance degrades gracefully with fewer steps, while DDPM-based models collapse. At 5 steps, rectified flow formulations still produce coherent images. Traditional formulations produce blurry messes.

Path length comparison: The paper measures the total path length of learned trajectories. SD3’s 8B model reaches a path length of 185.96, compared with 191.13 for the 500M model. Lower path length means a straighter trajectory and fewer steps needed. The path length decreases with model size, which confirms that larger models learn more efficient transport paths.

Complete training and inference budget

MetricSD3-2B (d=24)SD3-8B (d=38)
MMDiT params~2B~8B
Total system params~8.7B~14.7B
Training resolution256², then 1024² finetune256², then 1024² finetune
Training steps500K+500K+
VRAM for inference (bf16)~18 GB~30 GB
Steps for good quality28-50 Euler20-50 Euler
Inference time (A100)~5-7s~10-14s

The text encoders dominate the VRAM need at inference: T5-XXL alone needs about 9.4 GB in bf16. For memory-constrained deployment, you can drop T5 (with the compositional quality loss noted above) to save nearly 10 GB, or quantize it to int8 (~4.7 GB).

What is the fundamental architectural difference between SDXL and SD3?

Chapter 8

The Autoencoder

Compress an image into a 16-channel latent, and see why that code caps the quality of every picture

Like its predecessors, SD3 works in a compressed latent space, not in pixel space. A pretrained autoencoder maps images to and from this latent representation.

Why latent diffusion?

A 1024×1024 RGB image has about 3.1M values. Running a transformer with attention over 3.1M tokens is not feasible. The autoencoder compresses the image by a factor of 8 in each spatial dimension: 1024×1024×3 → 128×128×16, about 97% fewer values. The diffusion model works in this compact space. Then the decoder reconstructs the final image.

16-channel latent space

This is a key upgrade from SDXL (4 channels) and earlier Stable Diffusion versions. More channels give a richer latent and higher reconstruction quality. The paper shows this step by step:

4 channels
FID 2.41 • SSIM 0.75 • PSNR 25.12
↓
8 channels
FID 1.56 • SSIM 0.79 • PSNR 26.40
↓
16 channels
FID 1.06 • SSIM 0.86 • PSNR 28.62

The 16-channel autoencoder cuts reconstruction FID by 56% compared with 4 channels. This matters because the autoencoder’s reconstruction quality is an upper bound on final image quality. The diffusion model can never generate images better than the autoencoder can reconstruct.

Patching

The 128×128×16 latent is further divided into 2×2 patches. That gives 64×64 = 4096 tokens, each of dimension 16×4 = 64. These tokens form the image sequence in MMDiT. This patch size matches DiT’s design and keeps the sequence length manageable for attention.

The latent resolution stack: 1024×1024 pixels → 128×128×16 latent (autoencoder, 8× downsample) → 64×64 patches of dim 64 (2×2 patching) → 4096 tokens in MMDiT. The model never “sees” pixels. It only works with these 4096 abstract tokens.

VAE training (separate stage)

The 16-channel autoencoder is trained independently, before any diffusion training begins. It uses a combination of:

Once trained, the VAE is frozen for all later diffusion training. This two-stage approach comes from the original Latent Diffusion paper (Rombach et al., 2022). The VAE has about 80M parameters, which is small next to the 8B MMDiT it supports.

Why the VAE is a bottleneck: The autoencoder’s reconstruction quality is an absolute ceiling on final image quality. However perfect the MMDiT becomes, it cannot generate details the VAE cannot reconstruct. This is why going from 4 to 16 channels matters so much: it lifts the ceiling. Fine details like thin lines, small text and fabric textures, which a 4-channel latent loses for good, are now preserved.

Why does SD3 use 16 latent channels instead of the 4 channels used by SDXL?

Chapter 9

Connections

Place SD3 among the ideas it grew from, and take the whole lesson away in one page

SD3 sits at the crossing of several research threads. Knowing them shows where SD3 came from and where the field is going.

DiT (Peebles & Xie, 2023)

MMDiT descends directly from DiT. DiT first showed that a transformer backbone can replace the U-Net in a diffusion model, and that it scales. DiT used class-conditional generation with adaLN modulation. MMDiT extends this to text-to-image by adding the text stream and joint attention. DiT with concatenated text and image tokens is in fact a special case of MMDiT with shared weights.

DDPM & Diffusion Models (Ho et al., 2020)

DDPM set up the modern diffusion framework: define a forward noising process, then train a network to reverse it. SD3’s rectified flow chooses a different forward process (straight lines instead of curved variance-preserving paths) but keeps the same basic idea: learn to undo the noise.

Flow Matching (Lipman et al., 2023)

Rectified flow is a special case of the flow matching framework. Flow matching gives the theory: you can train velocity fields by matching conditional vector fields along chosen probability paths. Rectified flow simply picks the straight-line path zt = (1−t)x0 + tε. SD3’s contribution is to show that this works at scale with the right timestep sampling.

Flux (Black Forest Labs, 2024)

Several SD3 authors later founded Black Forest Labs and created Flux. Flux builds on the same MMDiT foundation but adds a hybrid design: early layers use MMDiT-style joint attention, while later layers use single-stream attention, where text and image tokens are fully merged. Flux also drops the T5 encoder’s share of the pooled embedding and simplifies the modulation mechanism.

Latent Diffusion (Rombach et al., 2022)

SD3 inherits the core LDM idea: train the diffusion model in a compressed latent space, not in pixel space. The key upgrades are moving from 4 to 16 latent channels and using a transformer backbone instead of a U-Net.

What each upgrade contributed

TransitionWhat changedWhat it improved
DDPM → LDMPixel space → latent space9x compute reduction, same quality
LDM → DiTU-Net → transformer backboneClean scaling laws, SOTA FID
DiT → SD3Class-cond → text-cond (MMDiT), DDPM → rectified flow, 4ch → 16ch VAEText generation, 4x fewer steps, sharper images
SD3 → FluxDual-stream → hybrid single/dual, simplified modulationFurther efficiency gains, production deployment
The evolution: DDPM (2020) → LDM/SD1 (2022, latent space + U-Net) → DiT (2023, transformer backbone) → SD3 (2024, MMDiT + rectified flow + 16ch latent) → Flux (2024, hybrid single/multi-stream). Each step replaced one component and kept the others. Each step brought clear, measurable gains.

The whole paper on one page

SD3 makes three bets. Walk a straight line from noise to data, so a few Euler steps are enough. Let text and image tokens attend to each other in both directions inside one transformer. Scale only the depth, so the loss follows a clean curve. Training details (logit-normal timesteps, a resolution shift, a 16-channel VAE, three frozen text encoders and mixed captions) make the three bets pay off.

NumberValueWhere
GenEval overall (SD3 8B + DPO)0.74 (DALL-E 3 0.67, SDXL 0.55)Chapter 6
CLIP-score loss, 50 → 5 steps2.71% (8B), 4.30% (500M)Chapter 5
Tokens in joint attention (1024²)4096 image + ~410 text = ~4506Chapter 2
Reconstruction FID, 4 → 16 channels2.41 → 1.06Chapter 8
Timestep shift usedα = 3.0Chapter 4
Parameters (MMDiT / whole system)~8B / ~14.7BChapter 4

The core of it fits in a few lines. This is a sketch of the idea, not the released code.

# training: one step
t   = logit_normal(m=0, s=1)               # not uniform
t   = shift(t, alpha=3.0)                  # 1024x1024 noise shift
eps = randn_like(x0)                       # x0: 128x128x16 latent
z_t = (1 - t) * x0 + t * eps               # the straight path
v   = mmdit(z_t, t, c, y)                  # c: ~410 text tokens, y: pooled
loss = ((v - (eps - x0)) ** 2).mean()      # conditional flow matching

# sampling: N Euler steps from noise
z = randn(128, 128, 16)                    # t = 1
for t, t_next in schedule(N):              # 1 -> 0, shifted
    z = z - (t - t_next) * mmdit(z, t, c, y)
image = vae_decode(z)                      # 1024x1024x3

Read on in the sources: DiT, DDPM, flow matching, latent diffusion and the SD3 paper.

The takeaway: A straight path, a transformer where text and image talk both ways, and a clean scaling axis. Change the path, the backbone and the latent together, and image generation gets faster, more exact and predictable.
How does MMDiT relate to the original DiT architecture?

Now teach it back: open Present or Teach from the dock at the top and explain the straight path in your own words. Then go back to the two paths at the top and walk them again.

Based on “Scaling Rectified Flow Transformers for High-Resolution Image Synthesis” by Esser et al. (2024)
Read the paper · Back to Veanors