↑↓ move Enter open ⌘K find from any page 256 of 256 tabs
Loading the recording…

What SDXL changes

SDXL (Podell et al.) keeps the recipe of Stable Diffusion 1.5, a U-Net that denoises VAE latents and reads text through cross-attention, and changes the parts around it. The U-Net is about three times larger, with most of the new parameters in attention at the coarse levels. Two text encoders replace one. The model is told the size and crop of each training image, and trained on many aspect ratios. A separate refiner model can polish the result; this tab records the base model only.

The page counts 2567 M parameters in the U-Net, 84 M in the VAE and 123 M + 695 M in the two text encoders. It draws a red apple on a wooden table at 768 × 768 pixels, a 4 × 96 × 96 latent, with 20 Euler steps, guidance 5 and seed 0. SDXL was trained around 1024 × 1024; the recorder found 768 the smallest size at which the base model draws a clean image, and at 512 × 512 every run came out covered in stripes.

Two text encoders

The Text encoders panel shows both reading the same tokens: CLIP ViT-L/14 (12 layers, 768 wide), the encoder SD 1.5 used, and OpenCLIP ViT-bigG/14 (32 layers, 1280 wide), a much larger CLIP trained with the open OpenCLIP code on LAION-2B. Each gives its second-to-last layer at all 77 positions, and the two are concatenated: numbers per token, the keys and values of every cross-attention. bigG's end token, projected to 1280, is also kept as one pooled vector for the whole prompt, which joins the timestep embedding below.

Classifier-free guidance needs an unconditional prediction. With no negative prompt, SDXL's pipeline does not encode an empty string: it sets the ∅ half's 77 × 2048 token numbers and its pooled vector to zero, and the recording confirms the U-Net's ∅ input is exactly zero. The Guidance panel then mixes .

Size and crop conditioning

Training sets mix image sizes, and training at a fixed size means either discarding small images or upscaling them, so that the model also learns their blur. Square crops of non-square images cut objects off, and earlier Stable Diffusion models reproduce the cut. Podell et al. keep all the images and tell the model what it is looking at, through six numbers: the original height and width, the top-left corner of the crop, and the target height and width.

Each number becomes a 256-value sinusoid , as does; the six are concatenated with the pooled text vector and passed through an MLP into the timestep embedding:

where is the pooled text vector, with inputs and 1280 outputs. Every ResNet block reads the sum . At sampling time the numbers become controls: crop (0, 0) asks for an uncropped, centred picture, and a small original size asks for an image that looks like an upscaled small one. Same seed, four size conditionings runs the same noise and prompt four times, changing only these numbers: original size 768, 256 or 1024, and a crop from (256, 256).

A U-Net that spends its depth at coarse levels

The U-Net panel shows three levels instead of SD 1.5's four: 320, 640 and 1280 channels at 96, 48 and 24 latent pixels, with 0, 2 and 10 transformer layers per block. The finest level has no attention at all. Attention cost grows with the square of the number of tokens, so it is cheap at 24 × 24 = 576 tokens and expensive at 96 × 96 = 9,216; SDXL spends its attention where the tokens are few and each one stands for a large patch of image.

Pick the Transformer block (up level 3, block 1) to step through its 10 layers. Each layer is the SD 1.5 block: self-attention with 20 heads of 64, cross-attention to the 2048-wide text tokens, and a feed-forward layer of 5120, each with a residual; the page shows the attention of layers 1 and 10. The ResNet block (down level 3, block 1, 640 → 1280 channels) shows the embedding bias, which here carries the size conditioning as well as .

The VAE and the Euler sampler

The VAE has SD 1.5's architecture, retrained with a larger batch and an exponential moving average of the weights; its latents are scaled by 0.13025 rather than 0.18215. The VAE panel runs it on a 512 px photo, with mean squared error 0.0093.

The Sampling loop takes 20 Euler steps in -space, as on the SD 1.5 tab: with , the latent is and

The U-Net reads , the scale it was trained on. The timesteps are 951, 901, …, 1, so the run starts at .

Where SDXL came from

Stability AI released SDXL 0.9 and 1.0 in 2023, after Stable Diffusion 1.x and 2.x. Its U-Net is the last large one in the Stable Diffusion line: SDXL-Turbo (the Turbo tab) distils it into one to four steps, and Stable Diffusion 3 and 3.5 (the SD 3.5 tab) replace the U-Net with a transformer that reads text and image tokens in one attention.

Papers

  1. SDXL: Improving Latent Diffusion Models for High-Resolution Image Synthesis Dustin Podell et al. · ICLR 2023 The model this tab records: the larger U-Net, the two text encoders, size and crop conditioning and the refiner.
  2. High-Resolution Image Synthesis with Latent Diffusion Models Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, Björn Ommer · CVPR 2022 Latent diffusion with cross-attention to text, the design SDXL scales up.
  3. Reproducible scaling laws for contrastive language-image learning Mehdi Cherti et al. · CVPR 2023 The OpenCLIP scaling study on LAION data; the second text encoder, ViT-bigG/14, comes from the same open training code and data.
  4. Learning Transferable Visual Models From Natural Language Supervision Alec Radford et al. · ICML 2021 CLIP, whose ViT-L/14 text encoder is the first of the two.
  5. Classifier-Free Diffusion Guidance Jonathan Ho, Tim Salimans · arXiv 2022 The guidance mix of the conditional and unconditional predictions.
  6. Elucidating the Design Space of Diffusion-Based Generative Models Tero Karras, Miika Aittala, Timo Aila, Samuli Laine · NeurIPS 2022 The σ-space formulation behind the Euler sampler SDXL ships with.

See also