AUTOMATIC1111 Sampling Methods: Complete Guide to DPM++, Euler, LCM, and More

AUTOMATIC1111’s Stable Diffusion Web UI bundles over 20 distinct sampling methods across three algorithmic families—K-Diffusion stochastic solvers, fixed-timesteps deterministic samplers, and Latent Consistency Models—each offering unique trade-offs between generation speed, step efficiency, and output quality.

The sampling method you select in AUTOMATIC1111’s Stable Diffusion Web UI determines how the underlying model denoises latent representations during image generation. These samplers are numerical differential equation solvers implemented across dedicated Python modules, with the central registry in modules/sd_samplers.py aggregating all available sampling methods in AUTOMATIC1111 into the dropdown menu visible in the interface.

The Three Families of Sampling Methods

K-Diffusion Samplers (modules/sd_samplers_kdiffusion.py)

The modules/sd_samplers_kdiffusion.py file implements stochastic differential equation (SDE) solvers built on the k-diffusion library. This family includes DPM++ 2M, DPM++ SDE, DPM++ 2M SDE, DPM++ 2M SDE Heun, DPM++ 2S a, DPM++ 3M SDE, Euler a, Euler, LMS, Heun, DPM2, DPM2 a, DPM fast, DPM adaptive, and Restart.

  • Euler and Euler a are first-order solvers; the "a" denotes ancestral sampling that injects stochastic noise at each step.
  • DPM++ variants combine predictor-corrector steps with optional Brownian noise to improve sampling quality.
  • Restart re-initializes the diffusion process after a specified number of steps, useful for specific artistic effects.

Timesteps-Based Samplers (modules/sd_samplers_timesteps.py)

Defined in modules/sd_samplers_timesteps.py, these samplers use the original CompVis implementation with fixed timestep schedules. Available methods include DDIM, DDIM CFG++, PLMS, and UniPC.

  • DDIM provides deterministic, non-stochastic sampling that trades output diversity for computational speed.
  • DDIM CFG++ integrates classifier-free guidance directly within the DDIM step rather than applying it externally.
  • PLMS (Pseudo-Linear Multistep) employs multistep predictors for higher accuracy without excessive compute.
  • UniPC functions as a unified predictor-corrector optimized for very low step counts (10-20 steps).

LCM Samplers (modules/sd_samplers_lcm.py)

The modules/sd_samplers_lcm.py file implements Latent Consistency Models, specifically the LCM sampler. This consistency-model approach skips most of the diffusion schedule using a learned consistency function (LCMCompVisDenoiser and sample_lcm), enabling high-quality generation in as few as 4-8 steps.

How AUTOMATIC1111 Registers Sampling Methods

The central registry in modules/sd_samplers.py imports all three families and concatenates their SamplerData objects into the all_samplers list (lines 11-15). The set_samplers() function filters visible options based on the hide_samplers user preference (lines 47-56), while visible_sampler_names() populates the UI dropdown defined in modules/ui.py (line 330).

When generating images, create_sampler(name, model) (lines 33-44) instantiates the selected sampler by looking up its constructor in the registry. All sampler objects implement the common interface methods sample and sample_img2img, ensuring consistent behavior across the different AUTOMATIC1111 sampling methods.

Practical Code Examples

Selecting a Sampler Programmatically

To instantiate a sampler in a custom script or extension:

from modules import sd_samplers, shared

# Assume shared.sd_model is already loaded

sampler_name = "Euler a"
sampler = sd_samplers.create_sampler(sampler_name, shared.sd_model)

# sampler implements sample(p, x, conditioning, unconditioning, ...)

# where p is a modules.processing.StableDiffusionProcessing instance

Implementing Custom Sampling Logic

For advanced use cases requiring direct latent manipulation:

import torch
from modules import sd_samplers, shared, processing

p = processing.StableDiffusionProcessingTxt2Img()
p.prompt = "a futuristic cityscape at sunset"
p.steps = 30
p.cfg_scale = 7.0
p.sampler_name = "DPM++ 2M SDE"

sampler = sd_samplers.create_sampler(p.sampler_name, shared.sd_model)
latent = torch.randn((1, 4, p.height // 8, p.width // 8), device=shared.sd_model.device)

samples = sampler.sample(p, latent, p.get_conditioning(), p.get_uncond_conditioning())

Adding a Custom Sampler to the UI

To extend the available sampling methods in AUTOMATIC1111, create a new file and register a SamplerData entry:


# In modules/sd_samplers_mynew.py

from modules import sd_samplers_common

def my_new_sampler(model, x, sigmas, **kwargs):
    # Custom denoising logic here

    return x

samplers_mynew = [("MyNew", my_new_sampler, ["mynew"], {})]

samplers_data_mynew = [
    sd_samplers_common.SamplerData(
        label, lambda model, funcname=funcname: sd_samplers_common.GenericSampler(funcname, model),
        aliases, options)
    for label, funcname, aliases, options in samplers_mynew
]

# Register with the global list

import modules.sd_samplers as base
base.all_samplers.extend(samplers_data_mynew)
base.set_samplers()

After reloading the Web UI, "MyNew" appears in the Sampling method dropdown.

Summary

  • AUTOMATIC1111 sampling methods are organized into three families: K-Diffusion (sd_samplers_kdiffusion.py), Timesteps-based (sd_samplers_timesteps.py), and LCM (sd_samplers_lcm.py).
  • K-Diffusion provides stochastic SDE solvers like Euler a and DPM++ variants, ideal for quality-focused generation requiring 20-50 steps.
  • Timesteps-based samplers offer deterministic alternatives like DDIM and fast-convergence options like UniPC for 10-20 step workflows.
  • LCM enables ultra-fast generation (4-8 steps) through consistency modeling, though it requires compatible model checkpoints.
  • The registry in modules/sd_samplers.py manages visibility through set_samplers() and instantiation via create_sampler(name, model).

Frequently Asked Questions

What is the difference between Euler and Euler a in AUTOMATIC1111?

Euler is a deterministic first-order solver that follows a fixed trajectory through latent space, producing identical outputs for the same seed and parameters. Euler a (ancestral) introduces stochastic noise at each sampling step, creating varied outputs even with identical seeds and CFG scales, often resulting in more creative or surprising details.

Which sampling method is fastest in AUTOMATIC1111?

LCM (Latent Consistency Model) is the fastest, requiring only 4-8 steps for high-quality results when using LCM-compatible checkpoints. Among universal samplers, Euler and DDIM offer the best speed-to-quality ratios at 20-30 steps, while UniPC excels at ultra-low step counts (10-15) with minimal quality loss.

When should I use DPM++ 2M SDE versus DDIM?

Use DPM++ 2M SDE when you need high-quality, detailed outputs and can afford 30-50 steps; its stochastic nature and second-order multistep approach produce richer textures and better fine details. Use DDIM for deterministic, faster generation (20-30 steps) when you need reproducible results or are working with img2img tasks requiring strict consistency between input and output.

How do I hide specific sampling methods from the Web UI?

Modify the hide_samplers list in your config.json or settings file. The set_samplers() function in modules/sd_samplers.py (lines 47-56) filters the all_samplers registry against this exclusion list before visible_sampler_names() populates the dropdown in modules/ui.py. Restart the Web UI after modifying the configuration.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →