Stable Diffusion 3.5 is the improved variant of its predecessor, Stable Diffusion 3. As of today, the models are available on the Hugging Face Hub and can be used with 🧨 Diffusers.
The release comes with two checkpoints:.
In this post, we will focus on how to use Stable Diffusion 3.5 (SD3.5) with Diffusers, covering both inference and training. (Related: Diffusers welcomes Stable Diffusion 3...)
The transformer architecture of SD3.5 (large) is very similar to SD3 (medium), with the following changes:.
Industry observers note that the rest of the details in terms of the text encoders, VAE, and noise scheduler stay exactly the same as in SD3 Medium. For more on SD3, we recommend checking out the original paper. (Related: Industry News: ‘Minecraft Mommy’ goes viral on TikTok f...)
Make sure you install the latest version of diffusers:.
The following snippet will download the 8B parameter version of SD3.5 in torch.bfloat16 precision. This is the format used in the original checkpoint published by Stability AI, and is the recommended way to run inference.
The release also comes with a “timestep-distilled” model that eliminates classifier-free guidance and lets us generate images in fewer steps (typically in 4-8 steps).
According to recent reports, all the examples shown in our SD3 blog post and the official Diffusers documentation should already work with SD3.5. In particular, both of those resources dive deep into optimizing the memory requirements to run inference. Since SD3.5 Large is significantly larger than SD3 Medium, memory optimization becomes crucial to allow inference on consumer interfaces.
Diffusers natively supports working with bitsandbytes quantization, which optimizes memory even more.
First, make sure to install all the libraries necessary:.
Then load the transformer in “NF4” precision:.
And now, we’re ready to run inference:.
Sources indicate that you can control other knobs in the BitsAndBytesConfig. Refer to the documentation for details.
Industry observers note that it is also possible to directly load a model quantized with the same nf4_config as above. This is particularly helpful for machines with low RAM. Refer to this Colab Notebook for an end-to-end example.
Thanks to libraries like bitsandbytes and peft, it is possible to fine-tune large models like SD3.5 Large on consumer GPU cards having 24GBs of VRAM. It is already possible to leverage our existing SD3 training script for training LoRAs. The below training command already works:.
However, to make it work with quantization, we need to tweak a couple of knobs. Below, we provide pointers on how to do that:.
Refer to this example script for a fuller example.
You can load the Stable Diffusion 3.5 Transformer model using the original checkpoint files published by Stability AI with the from_single_file method:.
In a recent development, acknowledgements: Daniel Frank for the background photo used in the thumbnail of this blog post. Thanks to Pedro Cuenca and Tom Aarsen for their reviews on the post draft.