Stability-AI/generative-models · error · ValueError
unknown sampler {params.sampler}!
Error message
unknown sampler {params.sampler}! What it means
get_sampler_config builds the sampler object by branching on SamplingParams.sampler (euler, ddim, dpm_solver2, etc.). When none of the branches match it falls through to this ValueError at the end of the function. It is called by text_to_image, image_to_image and refiner, so any inference entry point with a bad sampler name hits it.
Source
Thrown at sgm/inference/api.py:363
verbose=True,
)
if params.sampler == Sampler.DPMPP2M:
return DPMPP2MSampler(
num_steps=params.steps,
discretization_config=discretization_config,
guider_config=guider_config,
verbose=True,
)
if params.sampler == Sampler.LINEAR_MULTISTEP:
return LinearMultistepSampler(
num_steps=params.steps,
discretization_config=discretization_config,
guider_config=guider_config,
order=params.order,
verbose=True,
)
raise ValueError(f"unknown sampler {params.sampler}!")
View on GitHub (pinned to e8cd657656)
Solutions
- Use one of the supported values of SamplingParams.sampler as defined in sgm/inference/api.py (e.g. "euler", "ddim", "dpm_solver2").
- Check the branch conditions in get_sampler_config for exact accepted strings and match case/underscores.
- If a new sampler is required, add a branch in get_sampler_config constructing its Sampler object.
Example fix
// before params = SamplingParams(sampler="k_euler", discretization="ddpm") // after params = SamplingParams(sampler="euler", discretization="ddpm")
Defensive patterns
Strategy: validation
Validate before calling
VALID_SAMPLERS = {"euler", "euler_ancestral", "dpmpp_2m_sde", "dpmpp_sde", "ddim", "uni_pc"} # per sgm/inference/api.py
assert params.sampler in VALID_SAMPLERS, f"{params.sampler!r} not supported" Type guard
SamplerId = Literal["euler", "euler_ancestral", "dpmpp_2m_sde", "dpmpp_sde", "ddim", "uni_pc"]
def is_valid_sampler(x: str) -> bool:
return x in get_args(SamplerId) Try / catch
try:
out = text_to_image(params=params)
except ValueError as e:
if "unknown sampler" in str(e):
params.sampler = "euler" # safe default
out = text_to_image(params=params) Prevention
- Do not copy sampler names from A1111/ComfyUI; use this library's exact naming.
- Type-annotate SamplingParams.sampler with a Literal/enum of supported values.
When it happens
Trigger: Calling text_to_image(SamplingParams(sampler="dpm++2m")) or any sampler string not in the if/elif chain of get_sampler_config — e.g. unsupported names borrowed from other libraries ("k_euler", "uni_pc") or typos.
Common situations: Porting sampler names from A1111/ComfyUI/comfy workflows where sampler naming differs; typos like "dpm_solver_2" vs "dpm_solver2"; building sampler strings dynamically from config files with stale names.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- unknown discretization {params.discretization}
- Model {model_id} not supported
- Sampler and loss function need to be set for training.
- unsupported dimensions: {dims}
- unknown merge strategy {self.merge_strategy}
AI-assisted analysis of Stability-AI/generative-models@e8cd657656 (2026-08-29).
Data as JSON: /api/errors/5ce5edcef3b875a9.
Report an issue: GitHub.