From 6eeb3378ae9de96ea509227cbce4bf8336c2c729 Mon Sep 17 00:00:00 2001 From: Mr-Neutr0n <64578610+Mr-Neutr0n@users.noreply.github.com> Date: Sun, 8 Feb 2026 18:26:36 +0530 Subject: [PATCH] fix(pipeline): Preserve dtype in from_pipe() instead of defaulting to float32 The from_pipe() method was defaulting to torch.float32 for torch_dtype, causing pipelines created from float16 pipelines to be converted to float32. This doubled memory usage and slowed inference. Now defaults to pipeline.dtype to preserve the source pipeline's dtype. Fixes #12754 --- src/diffusers/pipelines/pipeline_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/diffusers/pipelines/pipeline_utils.py b/src/diffusers/pipelines/pipeline_utils.py index b96305c74131..4013e05baf32 100644 --- a/src/diffusers/pipelines/pipeline_utils.py +++ b/src/diffusers/pipelines/pipeline_utils.py @@ -2082,7 +2082,8 @@ def from_pipe(cls, pipeline, **kwargs): """ original_config = dict(pipeline.config) - torch_dtype = kwargs.pop("torch_dtype", torch.float32) + # Preserve the source pipeline's dtype by default instead of converting to float32 + torch_dtype = kwargs.pop("torch_dtype", pipeline.dtype) # derive the pipeline class to instantiate custom_pipeline = kwargs.pop("custom_pipeline", None)