From 29f9259d3b4998d1724bffa0cd530471502fffe2 Mon Sep 17 00:00:00 2001 From: Ricardo-M-L Date: Wed, 22 Apr 2026 10:28:17 +0800 Subject: [PATCH] Fix torch_dtype warning showing wrong value in from_single_file The warning message intended to show the invalid torch_dtype value passed by the user, but the variable was already reassigned to torch.float32 before the warning was logged. Move the reassignment after the warning so the message correctly displays the original invalid value. --- src/diffusers/loaders/single_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/diffusers/loaders/single_file.py b/src/diffusers/loaders/single_file.py index 0b0d52d4a412..5267fa4d448c 100644 --- a/src/diffusers/loaders/single_file.py +++ b/src/diffusers/loaders/single_file.py @@ -366,10 +366,10 @@ def from_single_file(cls, pretrained_model_link_or_path, **kwargs) -> Self: is_legacy_loading = False if torch_dtype is not None and not isinstance(torch_dtype, torch.dtype): - torch_dtype = torch.float32 logger.warning( f"Passed `torch_dtype` {torch_dtype} is not a `torch.dtype`. Defaulting to `torch.float32`." ) + torch_dtype = torch.float32 # We shouldn't allow configuring individual models components through a Pipeline creation method # These model kwargs should be deprecated