Comfy-Org/ComfyUI · error · NotImplementedError
There is no ddim discretization method called "{ddim_discr_m
Error message
There is no ddim discretization method called "{ddim_discr_method}" What it means
Raised by make_ddim_timesteps when ddim_discr_method is neither 'uniform' nor 'quad'. This helper picks which DDPM timesteps the DDIM sampler uses; the method name comes from sampler parameters and must match exactly. Any other string raises NotImplementedError.
Source
Thrown at comfy/ldm/modules/diffusionmodules/util.py:128
)
elif schedule == "sqrt_linear":
betas = torch.linspace(linear_start, linear_end, n_timestep, dtype=torch.float64)
elif schedule == "sqrt":
betas = torch.linspace(linear_start, linear_end, n_timestep, dtype=torch.float64) ** 0.5
else:
raise ValueError(f"schedule '{schedule}' unknown.")
return betas
def make_ddim_timesteps(ddim_discr_method, num_ddim_timesteps, num_ddpm_timesteps, verbose=True):
if ddim_discr_method == 'uniform':
c = num_ddpm_timesteps // num_ddim_timesteps
ddim_timesteps = np.asarray(list(range(0, num_ddpm_timesteps, c)))
elif ddim_discr_method == 'quad':
ddim_timesteps = ((np.linspace(0, np.sqrt(num_ddpm_timesteps * .8), num_ddim_timesteps)) ** 2).astype(int)
else:
raise NotImplementedError(f'There is no ddim discretization method called "{ddim_discr_method}"')
# assert ddim_timesteps.shape[0] == num_ddim_timesteps
# add one to get the final alpha values right (the ones from first scale to data during sampling)
steps_out = ddim_timesteps + 1
if verbose:
logging.info(f'Selected timesteps for ddim sampler: {steps_out}')
return steps_out
def make_ddim_sampling_parameters(alphacums, ddim_timesteps, eta, verbose=True):
# select alphas for computing the variance schedule
alphas = alphacums[ddim_timesteps]
alphas_prev = np.asarray([alphacums[0]] + alphacums[ddim_timesteps[:-1]].tolist())
# according to the formula provided in https://arxiv.org/abs/2010.02502
sigmas = eta * np.sqrt((1 - alphas_prev) / (1 - alphas) * (1 - alphas / alphas_prev))
if verbose:
logging.info(f'Selected alphas for ddim sampler: a_t: {alphas}; a_(t-1): {alphas_prev}')View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Use 'uniform' (even timestep spacing) or 'quad' (quadratic spacing)
- If you need another discretization, add the branch to make_ddim_timesteps rather than passing an unknown name
- Map external naming (e.g. 'leading') to 'uniform' at your adapter boundary
Example fix
# before
steps = make_ddim_timesteps('leading', 50, 1000)
# after
steps = make_ddim_timesteps('uniform', 50, 1000) Defensive patterns
Strategy: validation
Validate before calling
if ddim_discr_method not in ('uniform', 'quad'):
raise ValueError(f"ddim_discr_method must be 'uniform' or 'quad', got {ddim_discr_method!r}")
steps = make_ddim_timesteps(ddim_discr_method, num_ddim_timesteps, num_ddpm_timesteps) Type guard
def is_valid_discr_method(m: str) -> bool:
return m in ('uniform', 'quad') Prevention
- Translate external scheduler naming (leading/trailing/linspace) to 'uniform'/'quad' before calling
- Keep sampler parameter dicts aligned with this repo's supported methods
When it happens
Trigger: Calling make_ddim_timesteps('leading', ...) or constructing a DDIM sampler with a custom ddim_discr_method value like 'linspace' or 'trailing'.
Common situations: Copying sampler parameter dicts from other repos (k-diffusion naming, HuggingFace schedulers use 'leading'/'trailing'); extending sampler code and forgetting to add the branch; typos in the method string.
Related errors
- schedule '{schedule}' unknown.
- `only_cross_attention` can only be set to True if `added_kv_
- Unknown normalization type: {norm_type}
- Unknown activation type: {activation_type}
- Block with {block_type=} is not supported.
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/b8dfcf42841cdb06.
Report an issue: GitHub.