From 38a2f2f19d4e783901c94fbe7a33a7bc4e2270ba Mon Sep 17 00:00:00 2001 From: Ricardo-M-L Date: Fri, 3 Apr 2026 13:40:52 +0800 Subject: [PATCH] fix: use proper exception objects instead of bare raise/assert strings - attention_processor.py: `raise "string"` causes TypeError at runtime. Changed 3 occurrences to `raise RuntimeError("...")`. - pipeline_stable_diffusion_3_controlnet_inpainting.py: `assert ValueError("...")` always passes (ValueError object is truthy). Changed to `raise ValueError("...")`. --- src/diffusers/models/attention_processor.py | 6 +++--- .../pipeline_stable_diffusion_3_controlnet_inpainting.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/diffusers/models/attention_processor.py b/src/diffusers/models/attention_processor.py index f83a1753dac5..e2fdde0c058f 100755 --- a/src/diffusers/models/attention_processor.py +++ b/src/diffusers/models/attention_processor.py @@ -325,11 +325,11 @@ def set_use_xla_flash_attention( """ if use_xla_flash_attention: if not is_torch_xla_available: - raise "torch_xla is not available" + raise RuntimeError("torch_xla is not available") elif is_torch_xla_version("<", "2.3"): - raise "flash attention pallas kernel is supported from torch_xla version 2.3" + raise RuntimeError("flash attention pallas kernel is supported from torch_xla version 2.3") elif is_spmd() and is_torch_xla_version("<", "2.4"): - raise "flash attention pallas kernel using SPMD is supported from torch_xla version 2.4" + raise RuntimeError("flash attention pallas kernel using SPMD is supported from torch_xla version 2.4") else: if is_flux: processor = XLAFluxFlashAttnProcessor2_0(partition_spec) diff --git a/src/diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet_inpainting.py b/src/diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet_inpainting.py index 96f53b16cbe8..36cd0a854090 100644 --- a/src/diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet_inpainting.py +++ b/src/diffusers/pipelines/controlnet_sd3/pipeline_stable_diffusion_3_controlnet_inpainting.py @@ -1262,7 +1262,7 @@ def __call__( control_image = control_images else: - assert ValueError("Controlnet not found. Please check the controlnet model.") + raise ValueError("Controlnet not found. Please check the controlnet model.") if controlnet_pooled_projections is None: controlnet_pooled_projections = torch.zeros_like(pooled_prompt_embeds)