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

Ensure samplers seed the global RNG even when add_noise is disabled #2841

Closed

Conversation

blepping
Copy link
Contributor

currently no global RNG seed gets set at all with the built in samplers (advanced KSampler, SamplerCustom) if add_noise is not enabled. this means anything using the global RNG (i.e. euler_a) will find the RNG in an undefined state. it becomes impossible to reproduce generations.

this simple pull just ensures torch.manual_seed() gets called even in the non-add_noise code path.

visual demonstration:

current behavior

image

with this pull

image


unfortunately, a lot of other custom nodes copy the current ComfyUI code with this issue and will need to be changed individually.

closes #2833 (i hope)

@blepping
Copy link
Contributor Author

blepping commented Mar 1, 2024

@comfyanonymous can you please take a look at this? having the seed ignored when add_noise is turned off is pretty unintuitive from a user viewpoint (also inconsistent since some samplers will set a seed themselves like SDE). it's also inconvenient not to be able to have reproducible generations.

there is only one possible case i can think of where this might affect existing generations, and that's something that interrupts sampling and then resumes it (with add_noise turned off). however, this only works if absolutely nothing else touches the RNG in between. also other stuff like the upcoming execution inversion changes may change the order nodes run and break workflows relying on that behavior even if they work now but i'm pretty sure that's even more of an edge case than sampling with add_noise turned off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No seed gets set in custom/advanced samplers when add_noise is disabled
1 participant