Skip to main content
Stable Diffusion XL (SDXL) is a higher-resolution successor to SD 1.x/2.x. It introduces a dual text encoder pipeline, a larger UNet, and a native resolution of 1024 × 1024. sd-scripts provides dedicated scripts for both LoRA training and full fine-tuning.

Architecture

SDXL uses the same latent diffusion pipeline as SD 1.x/2.x but with several key upgrades:
  • UNet — significantly larger than SD 1.x; operates at higher resolutions.
  • Dual text encoders
    • Text Encoder 1: OpenCLIP ViT-G/14 (1280-dimensional embeddings).
    • Text Encoder 2: CLIP ViT-L/14 (768-dimensional embeddings).
    • Both encoders run in parallel; their outputs are concatenated before being fed to the UNet.
  • VAE — improved compared to SD 1.x, but can be numerically unstable in float16. Use --no_half_vae when training with fp16.

Key differences from SD 1.x

Available training methods

LoRA training

Use sdxl_train_network.py with --network_module=networks.lora:
--cache_text_encoder_outputs disables LoRA training on the text encoders. If you want to train text encoder LoRA modules, remove this flag and omit --network_train_unet_only.
When using --mixed_precision="fp16", always add --no_half_vae. SDXL’s VAE produces NaNs in float16, which corrupts training.

Fine-tuning

sdxl_train.py supports both native fine-tuning and DreamBooth-style training:
For fine-tuning on a 24 GB GPU, train the UNet only (--network_train_unet_only), enable gradient checkpointing, cache text encoder outputs and latents, and use the Adafactor optimizer.

VRAM requirements

Key parameters