Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nondeterministic results when add_noise==disable #4518

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pamparamm
Copy link
Contributor

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.

@diaopal
Copy link

diaopal commented Aug 21, 2024

Related to #2841

@blepping
Copy link
Contributor

hope you have better luck than i did!

@mcmonkey4eva mcmonkey4eva added the Bug Something is confirmed to not be working properly. label Aug 22, 2024
@mcmonkey4eva mcmonkey4eva added the Good PR This PR looks good to go, it needs comfy's final review. label Sep 9, 2024
@mcmonkey4eva mcmonkey4eva added Run-CI-Test This is an administrative label to tell the CI to run full automatic testing on this PR now. and removed Run-CI-Test This is an administrative label to tell the CI to run full automatic testing on this PR now. labels Sep 16, 2024
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is confirmed to not be working properly. Good PR This PR looks good to go, it needs comfy's final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants