{"record":{"id":"b8dfcf42841cdb06","repo":"Comfy-Org/ComfyUI","slug":"there-is-no-ddim-discretization-method-called-dd","errorCode":null,"errorMessage":"There is no ddim discretization method called \"{ddim_discr_method}\"","messagePattern":"There is no ddim discretization method called \"(.+?)\"","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"comfy/ldm/modules/diffusionmodules/util.py","lineNumber":128,"sourceCode":"        )\n\n    elif schedule == \"sqrt_linear\":\n        betas = torch.linspace(linear_start, linear_end, n_timestep, dtype=torch.float64)\n    elif schedule == \"sqrt\":\n        betas = torch.linspace(linear_start, linear_end, n_timestep, dtype=torch.float64) ** 0.5\n    else:\n        raise ValueError(f\"schedule '{schedule}' unknown.\")\n    return betas\n\n\ndef make_ddim_timesteps(ddim_discr_method, num_ddim_timesteps, num_ddpm_timesteps, verbose=True):\n    if ddim_discr_method == 'uniform':\n        c = num_ddpm_timesteps // num_ddim_timesteps\n        ddim_timesteps = np.asarray(list(range(0, num_ddpm_timesteps, c)))\n    elif ddim_discr_method == 'quad':\n        ddim_timesteps = ((np.linspace(0, np.sqrt(num_ddpm_timesteps * .8), num_ddim_timesteps)) ** 2).astype(int)\n    else:\n        raise NotImplementedError(f'There is no ddim discretization method called \"{ddim_discr_method}\"')\n\n    # assert ddim_timesteps.shape[0] == num_ddim_timesteps\n    # add one to get the final alpha values right (the ones from first scale to data during sampling)\n    steps_out = ddim_timesteps + 1\n    if verbose:\n        logging.info(f'Selected timesteps for ddim sampler: {steps_out}')\n    return steps_out\n\n\ndef make_ddim_sampling_parameters(alphacums, ddim_timesteps, eta, verbose=True):\n    # select alphas for computing the variance schedule\n    alphas = alphacums[ddim_timesteps]\n    alphas_prev = np.asarray([alphacums[0]] + alphacums[ddim_timesteps[:-1]].tolist())\n\n    # according to the formula provided in https://arxiv.org/abs/2010.02502\n    sigmas = eta * np.sqrt((1 - alphas_prev) / (1 - alphas) * (1 - alphas / alphas_prev))\n    if verbose:\n        logging.info(f'Selected alphas for ddim sampler: a_t: {alphas}; a_(t-1): {alphas_prev}')","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/modules/diffusionmodules/util.py#L110-L146","documentation":"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.","triggerScenarios":"Calling make_ddim_timesteps('leading', ...) or constructing a DDIM sampler with a custom ddim_discr_method value like 'linspace' or 'trailing'.","commonSituations":"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.","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"],"exampleFix":"# before\nsteps = make_ddim_timesteps('leading', 50, 1000)\n# after\nsteps = make_ddim_timesteps('uniform', 50, 1000)","handlingStrategy":"validation","validationCode":"if ddim_discr_method not in ('uniform', 'quad'):\n    raise ValueError(f\"ddim_discr_method must be 'uniform' or 'quad', got {ddim_discr_method!r}\")\nsteps = make_ddim_timesteps(ddim_discr_method, num_ddim_timesteps, num_ddpm_timesteps)","typeGuard":"def is_valid_discr_method(m: str) -> bool:\n    return m in ('uniform', 'quad')","tryCatchPattern":null,"preventionTips":["Translate external scheduler naming (leading/trailing/linspace) to 'uniform'/'quad' before calling","Keep sampler parameter dicts aligned with this repo's supported methods"],"tags":["sampler","ddim","diffusion","config"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}