ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

Fix nondeterministic results when add_noise==disable

Open pamparamm opened this issue 1 year ago • 5 comments

Images generated by KSampler (Advanced) and SamplerCustom nodes are nondeterministic when add_noise is set to False. Seems like we need to call torch.manual_seed(seed) before sampling in order to get deterministic results.

You can reproduce this problem by generating multiple times the same image with a fixed seed on ancestral sampler without adding initial noise.

This PR fixes that issue by moving all torch.zeros calls inside prepare_noise function right after setting torch seed.

pamparamm avatar Aug 21 '24 05:08 pamparamm

Related to https://github.com/comfyanonymous/ComfyUI/pull/2841

diaopal avatar Aug 21 '24 22:08 diaopal

hope you have better luck than i did!

blepping avatar Aug 22 '24 01:08 blepping

(Automated Bot Message) CI Tests are running, you can view the results at https://ci.comfy.org/?branch=4518%2Fmerge

github-actions[bot] avatar Sep 16 '24 15:09 github-actions[bot]

how is this bug still a thing after being reported almost a year ago, multiple people submitting pulls trying to fix the problem. still nothing. i don't get it.

it's also a really annoying bug. one of ComfyUI's biggest strengths is being able to iterate and this kills that.

blepping avatar Oct 20 '24 18:10 blepping

image

hopefully this is still going to happen.

blepping avatar Nov 05 '24 19:11 blepping