comfyanonymous / ComfyUI

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.
https://www.comfy.org/
GNU General Public License v3.0
54.04k stars 5.73k forks source link

When the seed and other parameters are same. The results of multiple drawings are inconsistent. #2520

Open joyoungzhang opened 9 months ago

joyoungzhang commented 9 months ago

When the seed and other parameters are same. The results of multiple drawings are inconsistent. What are the possible reasons?

Thanks!

image image
underclockeddev commented 9 months ago

Are you using an ancestral sampler?

My basic understanding is that ancestral samplers re-add some noise in each step, and due to the randomness of the per-step noise, ancestral samplers are non-deterministic.

joyoungzhang commented 9 months ago

Are you using an ancestral sampler?

My basic understanding is that ancestral samplers re-add some noise in each step, and due to the randomness of the per-step noise, ancestral samplers are non-deterministic.

I am using dpmpp_2m_sde_gpu. When I changed it to dpmpp_2m, the drawing results were consistent every time.

NeedsMoar commented 9 months ago

The SDE in those samplers stands for stochastic, which means they have a well defined distribution but random results. The brownian noise sampler means the results will vary slightly, even though they're not "ancestral" samplers as far as using previous results for prediction of noise in the next result.

sample_dpmpp_sde is "worse" in that it combines ancestral functions and brownian motion sampling. dpm_adaptive and dpm_fast also use ancestral function calls but don't include it in the name. dpm2 is safe as are most other samplers.

There's a chance that even though it's seeded, by design the stack of several RNGs and brownian sampling involved in SDEs makes them non-deterministic, or it might just be a precision issue .

Note that all of the ancestral samplers (labeled or not) use "default_noise_sampler" which doesn't seem to have a seed which is probably the actual cause of their producing somewhat different results between runs. You'll have to look in sampling.py to see what uses what.

You might try the --deterministic command line option to comfy and see if that helps.