Division by zero in rescale_noise_cfg can produce NaNs during inference
维护者通常 1 天内回复
@Akash504-ai 已经在做这个了。
开始于 2026年4月6日。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 68/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
调研方向
在 Diffusers 源代码中定位 rescale_noise_cfg 入口点,并使用方差为零的 noise_cfg 运行提供的 PyTorch 复现代码。跟踪现有的 std_cfg 处理方式,并为这一边界情况添加覆盖。完成标准是:方差为零的路径在推理过程中不再产生 NaN 或无穷值。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
Bug: Division by zero in rescale_noise_cfg can produce NaNs
Description
The function rescale_noise_cfg performs a division by std_cfg without any numerical stability guard:
noise_pred_rescaled = noise_cfg * (std_text / std_cfg)
If std_cfg becomes zero, this leads to NaN or inf values, which can silently corrupt the diffusion process and produce invalid outputs.
This can happen in edge cases where noise_cfg has zero variance.
Reproduction
import torch
noise_cfg = torch.zeros(1, 4, 64, 64) # std = 0
noise_pred_text = torch.randn_like(noise_cfg)
std_text = noise_pred_text.std(dim=list(range(1, noise_pred_text.ndim)), keepdim=True)
std_cfg = noise_cfg.std(dim=list(range(1, noise_cfg.ndim)), keepdim=True)
result = noise_cfg * (std_text / std_cfg)
print(result)
Logs
System Info
- Diffusers: main
- PyTorch: any
- OS: any
Who can help?
No response
- 主要语言
- Python
- 星标
- 34.7k
- 派生
- 7.4k
- 平均合并
- 4 天 6 小时
- 30 天内合并 PR
- 55
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
huggingface/diffusers 的其他 Issue
-
`ModelMixin.from_pretrained` on a sharded checkpoint fails under `HF_HUB_OFFLINE=1` even when fully cached (`_get_checkpoint_shard_files` still calls `model_info`)可能已有人在做 @Subodh-17 于 2 天前认领。 未关闭bug models
难度 2/5 1-3 小时 新手友好度 70/100
huggingface/diffusers#14952 · 1 条评论 ·
维护者通常 1 天内回复
-
UniPCMultistepScheduler fails in torch.linalg.solve under a float64 default dtype: the unit entry of rks takes the default dtype可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
huggingface/diffusers#14888 ·
维护者通常 1 天内回复
-
WanAnimatePipeline.get_i2v_mask() defaults device to "cuda", which raises on non-CUDA accelerators (NPU/XPU/MPS)可能已有人在做 @li-lizhe 于 11 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
huggingface/diffusers#14881 ·
维护者通常 1 天内回复
-
IndexError when preprocessing an empty image or video list可能已有人在做 @MohammadHijjawi97 于 16 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 74/100
huggingface/diffusers#14864 ·
维护者通常 1 天内回复
-
Windows: check_ai.py fails decoding UTF-8 guides with the default locale可能已有人在做 @tanvir-ux 于 15 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
huggingface/diffusers#14837 ·
维护者通常 1 天内回复
查看 huggingface/diffusers 的全部 Issue
相似的 Issue
-
first
难度 2/5 1-3 小时 新手友好度 72/100
AcademySoftwareFoundation/rmtc#54 · 1 条评论 ·
-
feature/cohorts feature/feature-flags team/feature-flags
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
License examples/ as MIT可能已有人在做 @PGrayCS 今天认领。 未关闭documentation enhancement example good first issue
难度 2/5 1-3 小时 新手友好度 84/100
speedyk-005/yasbd-lib#383 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
interactions-py/interactions.py#1827 ·
-
Managed start can fail when OpenVMM reads its control capability before NVX writes it可能已有人在做 @ppenna 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复