Accelerate inference of text-to-image diffusion models Diffusion models are slower than their GAN counterparts because of the iterative and sequential reverse diffusion process. There are several techniques that can address this limitation such as progressive timestep distillation (LCM LoRA), model compression (SSD-1B), and reusing adjacent features of the denoiser (DeepCache). However, you don’t necessarily need to use these techniques to speed up inference. With PyTorch 2 alone, you can accelerate the inference latency of text-to-image diffusion pipelines by up to 3x. This tutorial will show you how to progressively apply the optimizations found in PyTorch 2 to reduce inference latency. You’ll use the Stable Diffusion XL (SDXL) pipeline in this tutorial, but these techniques are applicable to other text-to-image diffusion pipelines too. Make sure you’re using the latest version of Diffusers:   Copied pip install -U diffusers Then upgrade the other required libraries too:   Copied pip install -U transformers accelerate peft Install PyTorch nightly to benefit from the latest and fastest kernels:   Copied pip3 install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu121 The results reported below are from a 80GB 400W A100 with its clock rate set to the maximum.  If you’re interested in the full benchmarking code, take a look at huggingface/diffusion-fast.  Baseline Let’s start with a baseline. Disable reduced precision and the scaled_dot_product_attention (SDPA) function which is automatically used by Diffusers:   Copied from diffusers import StableDiffusionXLPipeline