TL;DR
Diffusion models that generate images have almost always used a convolutional U-Net as their backbone. This paper replaces that U-Net with a standard transformer that works on patches of a compressed image, and studies how quality changes with size. The main finding is that quality tracks the transformer's forward-pass compute, measured in Gflops, more closely than it tracks parameter count.
The largest model, DiT-XL/2, reaches an FID-50K of 2.27 on class-conditional ImageNet at 256 by 256 with classifier-free guidance, the best of the diffusion models the authors compared against.
Where you'll see it: in diffusion models that use a transformer backbone in place of a U-Net, and in the choice to report forward-pass Gflops rather than parameter counts when comparing generative architectures.
The problem
By 2022 transformers had replaced most other architectures in language and in vision recognition. Image generation was an exception. Autoregressive image models used transformers, but the leading diffusion models all used a convolutional U-Net, inherited from the original DDPM work by Ho and colleagues. The U-Net has strong built-in assumptions about images: local connectivity, multi-scale downsampling and skip connections between matching resolutions.
Nobody had shown that a diffusion model could match the U-Net with a plain transformer, and nobody had measured how a transformer diffusion model scales. Without that, it was unclear whether the transformer's flexibility would pay off, or whether the U-Net's built-in structure was doing work that a transformer could not replace. The paper asks both questions.
Key idea
The paper makes three choices and then measures.
First, it works in a latent space. A pretrained autoencoder from Stable Diffusion compresses each 256 by 256 image into a 32 by 32 by 4 grid, so the diffusion model runs on a much smaller object than the pixels. This follows the latent diffusion recipe, and it is what makes the rest affordable.
Second, it cuts that latent grid into patches, turns each patch into a token, and runs a transformer over the token sequence, as a Vision Transformer does for classification. The patch size is a single number, and it controls how many tokens the transformer sees.
Third, it gives the transformer the diffusion timestep and the class label through a conditioning block called adaLN-Zero. The block sets the scale and shift of each layer norm from those two inputs, and it initialises a gate so that every block starts as the identity. The gate is what keeps a deep stack of blocks trainable from the first step.
The measurement is the key idea of the paper. The authors count the forward-pass Gflops of each model, vary depth, width and token count, and plot image quality against that count. The paper reports that the points lie close to a single trend, and presents this as evidence that diffusion transformers scale.
flowchart LR Z["Noised latent z_t, 32 by 32 by 4"] --> P["Patchify: p by p patches to T tokens"] P --> E["Add sine-cosine positional embedding"] E --> B["N DiT blocks with adaLN-Zero conditioning"] C["Timestep t and class c"] --> B B --> F["Final layer norm and linear decoder"] F --> O["Unpatchify to predicted noise and covariance"]
The method
Diffusion background
The paper uses the Gaussian diffusion setup of DDPM. A clean latent is corrupted by a fixed forward process with noise schedule , so that
Here is the timestep, is a constant that shrinks as grows, and is standard Gaussian noise. The network sees , and the label , and must predict the noise and a diagonal covariance for the reverse step. The network is trained with the variational objective of DDPM, extended to a learned covariance as in ADM. The paper uses the diffusion hyperparameters of ADM: a linear variance schedule over 1000 steps from to , and ADM's parameterisation of the covariance.
The classifier-free guidance used in the strongest results is described in Classifier-Free Guidance. It is applied only at sampling time, and the paper reports results with and without it.
Patchify and tokens
Patchify is a linear layer applied to each patch of the latent, mapping it to a vector of size . For a latent of side the number of tokens is
The paper then adds fixed sine-cosine positional embeddings, as in ViT. Halving the patch size multiplies by four, and because attention cost grows with and the MLP cost with , the transformer's Gflops grow at least fourfold. Changing has almost no effect on the parameter count, because the patch-embedding layer is the only part that depends on .
The DiT block and adaLN-Zero
Each block is a standard pre-norm transformer block: a multi-head self-attention layer and an MLP, each with a residual connection and a layer norm. The paper compares four ways to inject the timestep and label:
- In-context: append embeddings of and as two extra tokens, the way a class token is used in ViT.
- Cross-attention: add a cross-attention layer that attends to the two conditioning tokens.
- adaLN: replace each layer norm's learned scale and shift with values regressed from the sum of the and embeddings. This is the same idea as adaptive normalisation in GANs and U-Net diffusion models, and it adds very few Gflops.
- adaLN-Zero: the adaLN block with one extra output. For each block, the network regresses a scale that multiplies the output of each sub-layer just before it is added back to the residual stream. The MLP that produces these values is initialised to output zero, so every block starts as the identity function.
Writing one block with for layer norm without learned affine parameters, and the regressed scale and shift, and the regressed gate, the adaLN-Zero update is
The gates and are zero at initialisation, so and the block does nothing until training moves them. The authors borrow this idea from ResNets, where zero-initialising the last normalisation scale in each residual branch speeds up large-scale training.
Output and the design space
After the last block a final layer norm, which is adaptive when adaLN is used, and a linear layer map each token to a block of numbers, where is the number of latent channels. The blocks are rearranged into the spatial layout to give the predicted noise and covariance. The full design space is patch size, block type and model size. The sizes are named S, B, L and XL, and the table below gives their shapes and their Gflops at a 32 by 32 latent with patch size 4.
| Model | Layers | Hidden size | Heads | Gflops (p = 4) |
|---|---|---|---|---|
| DiT-S | 12 | 384 | 6 | 1.4 |
| DiT-B | 12 | 768 | 12 | 5.6 |
| DiT-L | 24 | 1024 | 16 | 19.7 |
| DiT-XL | 28 | 1152 | 16 | 29.1 |
The authors train twelve models, all combinations of the four sizes with patch sizes 8, 4 and 2. A model is named by its size and patch size, so DiT-XL/2 is the XL configuration with patch size 2.
Training setup
Everything is trained on ImageNet at 256 by 256, and a second model at 512 by 512, with class labels. The optimiser is AdamW, a constant learning rate of , no weight decay and a batch size of 256. The only data augmentation is horizontal flipping. The authors report that they needed neither learning-rate warm-up nor extra regularisation, which is unusual for ViT-style models. The VAE and its weights are frozen. Evaluation uses FID on 50,000 samples, computed with ADM's TensorFlow suite, with 250 sampling steps.
Results
The paper reports several kinds of result. The most important is the relation between compute and quality.
Scaling. At 400K training steps, FID falls steadily as Gflops rise. Making the model deeper and wider helps at every patch size, and making the patch smaller helps at every model size. The paper's table of 12 models gives, for example, DiT-S/8 at 153.60 FID, DiT-B/2 at 43.47 and DiT-XL/2 at 19.47, all without guidance and at 400K steps.
Conditioning. Holding DiT-XL/2 at 400K steps, the four block designs score as follows, with Gflops in brackets. In-context is 35.24 (119.4), cross-attention 26.14 (137.6), adaLN 25.21 (118.6) and adaLN-Zero 19.47 (118.6). The paper states that adaLN-Zero outperforms cross-attention and in-context conditioning at all stages of training. The cross-attention block is the most expensive of the four.
Parameters versus compute. The paper gives two models with similar parameter counts. Changing only the patch size from 4 to 2 quadruples the tokens and the Gflops, and it improves quality a lot. So parameter count alone does not predict quality, and the paper concludes that compute should be the axis used to compare generative transformers.
Sampling compute. Diffusion models can spend more compute at sampling time by taking more steps. The authors compare DiT-L/2 with 1000 sampling steps, costing 80.7 Tflops per image, against DiT-XL/2 with 128 steps, costing 15.2 Tflops. The XL model is about five times cheaper to sample and still has the better FID-10K, 23.7 against 25.9. The conclusion is that extra sampling steps do not make up for a smaller model.
ImageNet 256 by 256. The main table compares class-conditional models on FID-50K. DiT-XL/2 was trained for 7M steps.
| Model | FID (lower is better) | IS (higher is better) |
|---|---|---|
| ADM | 10.94 | 100.98 |
| LDM-4 | 10.56 | 103.49 |
| DiT-XL/2, no guidance | 9.62 | 121.50 |
| LDM-4-G, guidance 1.50 | 3.60 | 247.67 |
| StyleGAN-XL (a GAN) | 2.30 | 265.12 |
| DiT-XL/2-G, guidance 1.25 | 3.22 | 201.77 |
| DiT-XL/2-G, guidance 1.50 | 2.27 | 278.24 |
With guidance 1.50, DiT-XL/2 lowers the best previous diffusion FID in the table from 3.60 to 2.27, and it is slightly below the 2.30 of the GAN StyleGAN-XL. Without guidance it beats ADM (10.94) and LDM-4 (10.56), but not the GAN BigGAN-deep (6.95) or the ADM-U variant (7.49). The reader should keep the guided and unguided rows apart when comparing numbers.
ImageNet 512 by 512. The paper trains DiT-XL/2 at 512 for 3M steps with the same settings. The patch size is 2, so the 64 by 64 by 4 latent gives 1024 tokens and 524.6 Gflops per forward pass. The paper reports that this model again beats all prior diffusion models at 512, improving the previous best FID of 3.85 (ADM) to 3.04, while using 524.6 Gflops against ADM's 1983. Without guidance, the appendix table records an FID of 13.78 at 1.3M steps and 11.93 at 3M steps.
Why it mattered
The paper showed that the U-Net was not needed for high-quality diffusion models. A plain transformer, with a conditioning block that is easy to add, matched or beat the best U-Net-based latent diffusion models on the standard benchmark. That made the transformer a credible default for diffusion backbones.
It also gave later work a concrete recipe: a latent autoencoder, a transformer over patches, and a conditioning block whose gate starts at zero. The paper's plots of quality against Gflops, and its comparison of sampling steps with model size, are a useful way to compare generative architectures, whatever one thinks of the specific numbers.
Its limitations are real. The experiments are class-conditional on ImageNet, not text-conditional. The compute measure is forward-pass Gflops, which is a proxy for wall-clock cost and ignores memory and attention implementation details. The scaling claim rests on a small number of model sizes and patch sizes, so the trend should be read as evidence, not a law.
Reading guide
Read the paper in this order and use these prerequisites for each section.
- Introduction and Related Work. Needs DDPM for the U-Net baseline, ViT for the idea of patches as tokens, and Latent Diffusion Model for why the model works in latent space.
- Section 3.1, Preliminaries. Needs Diffusion Model for the forward and reverse processes, Variational Autoencoder for the latent autoencoder and its KL-regularised code, and Classifier-Free Guidance for the guided results. Read the reparameterisation slowly; every later formula uses it.
- Section 3.2, Design space. Needs Vision Transformer (ViT) and Positional Encoding for patchify and the sine-cosine embedding, Transformer for the block, Layer Normalization and Residual Connection for adaLN and adaLN-Zero. The adaLN-Zero argument makes sense only once residual connections are understood as identity-at-initialisation blocks.
- Section 4, Experimental setup. Needs Adam Optimizer for AdamW and the constant learning rate. Nothing else is new.
- Section 5, Experiments. Needs Neural Scaling Laws to see why the authors plot FID against compute and expect a straight-line trend on log axes.
- Section 5.2 and the appendices. Read the sampling-compute comparison after the scaling plots. The appendix tables give the exact settings for every model.
Check yourself
QuestionThe paper says halving the patch size quadruples the number of tokens. Why does that follow from the formula for T, and what does it do to the parameter count?Show answer
With latent side and patch size , the number of tokens is . Halving divides the denominator by two and so multiplies by four. The parameter count hardly changes, because the only layer that depends on is the linear patch embedding, whose size is times the channel count times ; the transformer blocks do not depend on at all. So the extra cost is in compute, not in parameters.
QuestionAt 400K steps, DiT-XL/2 with adaLN-Zero scores 19.47 FID and with in-context conditioning it scores 35.24. Both use about 119 Gflops. What does this comparison show, and what does it not show?Show answer
It shows that, at matched compute, the way the timestep and label are injected can change FID by a large margin, here about 16 points. It does not show that adaLN-Zero is always best, because the comparison is at a single model size and training length. The paper's claim is narrower: adaLN-Zero beats cross-attention and in-context conditioning at every stage of training it measured, and it adds almost no Gflops over plain adaLN.
QuestionA team has a fixed budget of compute for sampling. Using the paper's comparison, why would a smaller model with many sampling steps not be a better choice than a larger model with few steps?Show answer
The paper compares DiT-L/2 at 1000 steps, which costs 80.7 Tflops per image, with DiT-XL/2 at 128 steps, which costs 15.2 Tflops. The XL model is cheaper and has the better FID-10K (23.7 against 25.9). The lesson is that sampling steps cannot replace missing model compute: beyond a point the small model's quality is limited by its size, however many steps it takes.
QuestionThe paper reports DiT-XL/2 without guidance at FID 9.62 and with guidance 1.50 at FID 2.27. Why do these two numbers need to be read together, and which one should a comparison with ADM or LDM use?Show answer
The no-guidance number is the fairer measure of the architecture alone, since it is not helped by a sampling trick. The guided number shows the best quality the model reaches with classifier-free guidance. The paper's headline, 2.27 beating the previous best of 3.60 for LDM-4-G, compares guided against guided. A comparison of backbones should use the no-guidance figure. There DiT-XL/2 at 9.62 beats ADM and LDM-4 but not BigGAN-deep at 6.95, so the no-guidance result is a good result rather than a clear win.
Sources
- Peebles and Xie, Scalable Diffusion Models with Transformers (2022): https://arxiv.org/abs/2212.09748
- Ho, Jain and Abbeel, Denoising Diffusion Probabilistic Models (2020): https://arxiv.org/abs/2006.11239
- Rombach et al., High-Resolution Image Synthesis with Latent Diffusion Models (2022): https://arxiv.org/abs/2112.10752
- Dosovitskiy et al., An Image is Worth 16x16 Words (2020): https://arxiv.org/abs/2010.11929