Accelerate inference of text-to-image diffusion models Diffusion models are known to be slower than their counter parts, GANs, because of the iterative and sequential reverse diffusion process. Recent works try to address limitation with: progressive timestep distillation (such as LCM LoRA) model compression (such as SSD-1B) reusing adjacent features of the denoiser (such as DeepCache) In this tutorial, we focus on leveraging the power of PyTorch 2 to accelerate the inference latency of text-to-image diffusion pipeline, instead. We will use Stable Diffusion XL (SDXL) as a case study, but the techniques we will discuss should extend to other text-to-image diffusion pipelines.  Setup Make sure you’re on the latest version of diffusers:   Copied pip install -U diffusers Then upgrade the other required libraries too:   Copied pip install -U transformers accelerate peft To benefit from the fastest kernels, use PyTorch nightly. You can find the installation instructions here. To report the numbers shown below, we used an 80GB 400W A100 with its clock rate set to the maximum. This tutorial doesn’t present the benchmarking code and focuses on how to perform the optimizations, instead. For the full benchmarking code, refer to: https://github.com/huggingface/diffusion-fast.  Baseline Let’s start with a baseline. Disable the use of a reduced precision and scaled_dot_product_attention:   Copied from diffusers import StableDiffusionXLPipeline