From e68f9272e8d17565b6bc56f657a5940913082d54 Mon Sep 17 00:00:00 2001 From: Disty0 Date: Fri, 13 Jun 2025 13:05:46 +0300 Subject: [PATCH] Disable custom atten processors for non SD 1.5 / SDXL models --- CHANGELOG.md | 3 ++- modules/sd_models.py | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea24e138b..abe785428 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Set CPU backend to use FP32 by default - Relax Python version checks for Zluda - Make VAE options not require model reload + - Add warning about incompatible attention processors - **Torch** - Set default to `torch==2.7.1` @@ -32,7 +33,7 @@ - **Fixes** - Meissonic with multiple generators - - Kandinsky V2.2 invalid attention processor + - Invalid attention processors - PixArt Sigma Small and Large loading - TAESD previews with PixArt and Lumina 2 - VAE Tiling with non-default tile sizes diff --git a/modules/sd_models.py b/modules/sd_models.py index 7cf4f4993..0bea615ff 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -920,8 +920,13 @@ def set_diffusers_attention(pipe, quiet:bool=False): # if hasattr(pipe, 'pipe'): # set_diffusers_attention(pipe.pipe) - if 'ControlNet' in pipe.__class__.__name__: # do not replace attention in ControlNet pipelines + if 'ControlNet' in pipe.__class__.__name__ or not (pipe.__class__.__name__.startswith("StableDiffusion") and hasattr(pipe, "unet")): + if shared.opts.cross_attention_optimization not in {"Scaled-Dot-Product", "Disabled"}: + shared.log.warning(f"Attention: {shared.opts.cross_attention_optimization} is not compatible with {pipe.__class__.__name__}") + else: + pipe.current_attn_name = shared.opts.cross_attention_optimization return + shared.log.quiet(quiet, f'Setting model: attention="{shared.opts.cross_attention_optimization}"') if shared.opts.cross_attention_optimization == "Disabled": pass # do nothing