r/StableDiffusion • • Aug 29 '22

Question What is the difference between each sampling method?

GUItard has many sampling methods to choose from: DDIM, PLMS, k_lms, k_dpm_2_a, k_dpm_2, k_euler_a, k_euler, and k_heun. What is the difference between each of these? All the info I can get from the GUI and install instructions is that k_lms is the default k-diffusion sampler, k_euler_a and k_dpm_2_a produce vastly different, more intricate results from the same prompt, and k_euler_a can generate high quality results from low steps. But what is the actual difference between each method, and why would I pick any one over the others?

69 Upvotes

23 comments sorted by

View all comments

Show parent comment

7

u/CupcakeSecure4094 Mar 11 '23

The samplers are essentially different ways to turn random noise into an image. If you imagine the process in reverse it may be easier to grasp. Imagine you want to add random noise pixels to an image, you might think of a few different methods to randomize the process. In reverse there different methods to turn the noise into an image and some are able to do this very quickly but overshoot (known as overcooking) and some use much higher precision and take longer (more steps). Most samplers more or less end up with the same sort of image with some minor variations.

However the intricate mathematical processes of how they function requires reading the scientific papers, they are nothing more than complex algorithms which attempt to converge on something that looks more and more like the prompt tokens. The simplest form of algorithm for this is changing different blocks of pixels, each by some set amount and measuring which block had the largest effect at making the image look more like a prompt. Then replicating that type of change. This can speed up the process but can be prone to overcooking or going "weird". At the end of the day every sampling method is just tweaking pixels for the system to them rank the result as looking more or less like the prompt.

My recommendation is to use the x,y,z script feature to build some sample grids with incremental changes to steps, cfg and sampler selection, to get a feel for the type for art you produce, just like a classical artist might get the feel for paints and brushes - there is no definitive answer on samplers (that I know of), they are a mix of accuracy, efficiency, stability in solving differential equations depending on the image, just figure out when it converges for your specific prompt and try not to go past it.

1

u/Pupper-Gump Mar 19 '23

So basically, they all produce the same image with small variations and the ones that change it less draw it faster?

1

u/Quirky-Indication670 Mar 19 '23

Any first papers to recommend?

(thank you for the explaination)