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.
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
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.
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.
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.
Chapter 1
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.
Take a data sample x0 and noise ε ~ N(0, I). Define the noisy sample at time t like this:
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)
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.
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.
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.
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 network vΘ learns the velocity field by minimizing the conditional flow matching loss:
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)
Chapter 2
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.
The MMDiT block has two independent pathways:
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.
Step through one block below. The image stream is blue and the text stream is purple. Watch where they meet.
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.
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).
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.
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.
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.
Chapter 3
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.
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.
A larger CLIP variant (ViT-bigG/14). It also produces 77 tokens and a pooled vector. The larger model captures more nuanced visual concepts.
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.
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.
Chapter 4
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.
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:
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)
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.
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.
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:
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)
| Component | Parameters | Status |
|---|---|---|
| CLIP-L/14 | ~124M | Frozen (pretrained by OpenAI) |
| CLIP-G/14 | ~1.8B | Frozen (pretrained, OpenCLIP) |
| T5-XXL encoder | 4.7B | Frozen (pretrained by Google) |
| VAE (16-ch) | ~80M | Pretrained separately, frozen during MMDiT training |
| MMDiT (d=38) | ~8B | Trained 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.
Three concrete reasons:
Chapter 5
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.
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.
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.
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.
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.
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.
Chapter 6
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 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:
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.
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.
Chapter 7
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.
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.
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.
| Metric | SD3-2B (d=24) | SD3-8B (d=38) |
|---|---|---|
| MMDiT params | ~2B | ~8B |
| Total system params | ~8.7B | ~14.7B |
| Training resolution | 256², then 1024² finetune | 256², then 1024² finetune |
| Training steps | 500K+ | 500K+ |
| VRAM for inference (bf16) | ~18 GB | ~30 GB |
| Steps for good quality | 28-50 Euler | 20-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).
Chapter 8
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.
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.
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:
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.
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 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.
Chapter 9
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.
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 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.
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.
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.
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.
| Transition | What changed | What it improved |
|---|---|---|
| DDPM → LDM | Pixel space → latent space | 9x compute reduction, same quality |
| LDM → DiT | U-Net → transformer backbone | Clean scaling laws, SOTA FID |
| DiT → SD3 | Class-cond → text-cond (MMDiT), DDPM → rectified flow, 4ch → 16ch VAE | Text generation, 4x fewer steps, sharper images |
| SD3 → Flux | Dual-stream → hybrid single/dual, simplified modulation | Further efficiency gains, production deployment |
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.
| Number | Value | Where |
|---|---|---|
| GenEval overall (SD3 8B + DPO) | 0.74 (DALL-E 3 0.67, SDXL 0.55) | Chapter 6 |
| CLIP-score loss, 50 → 5 steps | 2.71% (8B), 4.30% (500M) | Chapter 5 |
| Tokens in joint attention (1024²) | 4096 image + ~410 text = ~4506 | Chapter 2 |
| Reconstruction FID, 4 → 16 channels | 2.41 → 1.06 | Chapter 8 |
| Timestep shift used | α = 3.0 | Chapter 4 |
| Parameters (MMDiT / whole system) | ~8B / ~14.7B | Chapter 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.
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.