fix(ddim): validate eta is in [0, 1] in DDIMPipeline#13367
fix(ddim): validate eta is in [0, 1] in DDIMPipeline#13367yiyixuxu merged 4 commits intohuggingface:mainfrom
Conversation
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 huggingface#13362 Signed-off-by: NIK-TIGER-BILL <nik.tiger.bill@github.com>
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
thanks for the PR, can you change it to a warning? |
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 <nik.tiger.bill@github.com>
|
Thanks for the feedback, @yiyixuxu! Changed to a |
| image_shape = (batch_size, self.unet.config.in_channels, *self.unet.config.sample_size) | ||
|
|
||
| if not 0.0 <= eta <= 1.0: | ||
| warnings.warn( |
| image_shape = (batch_size, self.unet.config.in_channels, *self.unet.config.sample_size) | ||
|
|
||
| if not 0.0 <= eta <= 1.0: | ||
| warnings.warn( |
There was a problem hiding this comment.
can we change it to use logger.warning? to be consistent with all other pipelines
There was a problem hiding this comment.
Good call! Updated in the latest commit — switched from warnings.warn() to logger.warning() to match the convention used in all other diffusers pipelines. Also removed the now-unused import warnings.
…tion 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 <nik.tiger.bill@github.com>
* fix(ddim): validate eta is in [0, 1] in DDIMPipeline.__call__ 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 huggingface#13362 Signed-off-by: NIK-TIGER-BILL <nik.tiger.bill@github.com> * fix(ddim): downgrade eta out-of-range from error to warning 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 <nik.tiger.bill@github.com> * 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 <nik.tiger.bill@github.com> --------- Signed-off-by: NIK-TIGER-BILL <nik.tiger.bill@github.com> Co-authored-by: NIK-TIGER-BILL <nik.tiger.bill@github.com> Co-authored-by: YiYi Xu <yixu310@gmail.com>
What does this PR do?
Adds input validation for the
etaparameter inDDIMPipeline.__call__.Fixes #13362
Context
The DDIM paper defines η (eta) as a value that lies strictly in [0, 1]:
The docstring already documents this constraint:
However, no runtime check existed, so out-of-range values (negative or > 1) were silently accepted and could produce undefined/unintended sampling behaviour.
Change
Add a
ValueErrorguard immediately after the image-shape computation, before the denoising loop:Before submitting
Who can review?
@pcuenca @DN6