From 1b3a4e7c0b6e8967f95f49e64096dbc7cd9322eb Mon Sep 17 00:00:00 2001 From: NIK-TIGER-BILL Date: Mon, 30 Mar 2026 07:14:53 +0000 Subject: [PATCH 1/3] fix(ddim): validate eta is in [0, 1] in DDIMPipeline.__call__ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The DDIM paper defines η (eta) as a value that must lie in [0, 1]: η=0 corresponds to deterministic DDIM, η=1 corresponds to DDPM. The docstring already documented this constraint, but no runtime validation was in place, so users could silently pass out-of-range values (e.g. negative or >1) without any error. Add an explicit ValueError check before the denoising loop so that invalid eta values are caught early with a clear message. Fixes #13362 Signed-off-by: NIK-TIGER-BILL --- src/diffusers/pipelines/ddim/pipeline_ddim.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/diffusers/pipelines/ddim/pipeline_ddim.py b/src/diffusers/pipelines/ddim/pipeline_ddim.py index dc92b34a7565..e588938487ab 100644 --- a/src/diffusers/pipelines/ddim/pipeline_ddim.py +++ b/src/diffusers/pipelines/ddim/pipeline_ddim.py @@ -129,6 +129,12 @@ def __call__( else: image_shape = (batch_size, self.unet.config.in_channels, *self.unet.config.sample_size) + if not 0.0 <= eta <= 1.0: + raise ValueError( + f"`eta` must be between 0 and 1 (inclusive), but received {eta}. " + "A value of 0 corresponds to DDIM and 1 corresponds to DDPM." + ) + if isinstance(generator, list) and len(generator) != batch_size: raise ValueError( f"You have passed a list of generators of length {len(generator)}, but requested an effective batch" From 173e88d8f72e7bb02e9cb81431bcdb9896a13532 Mon Sep 17 00:00:00 2001 From: NIK-TIGER-BILL Date: Tue, 31 Mar 2026 03:05:18 +0000 Subject: [PATCH 2/3] fix(ddim): downgrade eta out-of-range from error to warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per maintainer feedback from @yiyixuxu — the documentation is sufficient; a hard ValueError is too strict. Replace with a UserWarning so callers are informed without breaking existing code that passes eta outside [0, 1]. Signed-off-by: NIK-TIGER-BILL --- src/diffusers/pipelines/ddim/pipeline_ddim.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/diffusers/pipelines/ddim/pipeline_ddim.py b/src/diffusers/pipelines/ddim/pipeline_ddim.py index e588938487ab..b940df142fb0 100644 --- a/src/diffusers/pipelines/ddim/pipeline_ddim.py +++ b/src/diffusers/pipelines/ddim/pipeline_ddim.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import warnings + import torch from ...models import UNet2DModel @@ -130,9 +132,12 @@ def __call__( image_shape = (batch_size, self.unet.config.in_channels, *self.unet.config.sample_size) if not 0.0 <= eta <= 1.0: - raise ValueError( - f"`eta` must be between 0 and 1 (inclusive), but received {eta}. " - "A value of 0 corresponds to DDIM and 1 corresponds to DDPM." + warnings.warn( + f"`eta` should be between 0 and 1 (inclusive), but received {eta}. " + "A value of 0 corresponds to DDIM and 1 corresponds to DDPM. " + "Unexpected results may occur for values outside this range.", + UserWarning, + stacklevel=2, ) if isinstance(generator, list) and len(generator) != batch_size: From 98bb6afa7b516250579248386f6e8ca1ce44333a Mon Sep 17 00:00:00 2001 From: NIK-TIGER-BILL Date: Wed, 1 Apr 2026 23:39:38 +0000 Subject: [PATCH 3/3] fix(ddim): use logger.warning instead of warnings.warn for eta validation Address review request from @yiyixuxu: switch from warnings.warn() to logger.warning() to be consistent with all other diffusers pipelines. The eta validation check itself (0.0 <= eta <= 1.0) is unchanged. Signed-off-by: NIK-TIGER-BILL --- src/diffusers/pipelines/ddim/pipeline_ddim.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/diffusers/pipelines/ddim/pipeline_ddim.py b/src/diffusers/pipelines/ddim/pipeline_ddim.py index b940df142fb0..6634fb1b0e27 100644 --- a/src/diffusers/pipelines/ddim/pipeline_ddim.py +++ b/src/diffusers/pipelines/ddim/pipeline_ddim.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import warnings +import logging import torch @@ -23,6 +23,9 @@ from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput +logger = logging.getLogger(__name__) + + if is_torch_xla_available(): import torch_xla.core.xla_model as xm @@ -132,12 +135,10 @@ def __call__( image_shape = (batch_size, self.unet.config.in_channels, *self.unet.config.sample_size) if not 0.0 <= eta <= 1.0: - warnings.warn( + logger.warning( f"`eta` should be between 0 and 1 (inclusive), but received {eta}. " "A value of 0 corresponds to DDIM and 1 corresponds to DDPM. " - "Unexpected results may occur for values outside this range.", - UserWarning, - stacklevel=2, + "Unexpected results may occur for values outside this range." ) if isinstance(generator, list) and len(generator) != batch_size: