PyTorch 2.0 🤗 Diffusers supports the latest optimizations from PyTorch 2.0 which include: A memory-efficient attention implementation, scaled dot product attention, without requiring any extra dependencies such as xFormers. torch.compile, a just-in-time (JIT) compiler to provide an extra performance boost when individual models are compiled. Both of these optimizations require PyTorch 2.0 or later and 🤗 Diffusers > 0.13.0.   Copied pip install --upgrade torch diffusers  Scaled dot product attention torch.nn.functional.scaled_dot_product_attention (SDPA) is an optimized and memory-efficient attention (similar to xFormers) that automatically enables several other optimizations depending on the model inputs and GPU type. SDPA is enabled by default if you’re using PyTorch 2.0 and the latest version of 🤗 Diffusers, so you don’t need to add anything to your code. However, if you want to explicitly enable it, you can set a DiffusionPipeline to use AttnProcessor2_0:   Copied   import torch