Comfy-Org/ComfyUI · error · ValueError

sigma_min and sigma_max must not be 0

Error message

sigma_min and sigma_max must not be 0

What it means

Guard at the top of sample_dpm_fast: the DPM-Solver time mapping t(sigma) = log(sigma) is undefined at sigma=0 (log of zero), and zero-sigma endpoints would also collapse the schedule. Both sigma_min and sigma_max must be strictly positive; a non-positive value raises before the solver is built.

Source

Thrown at comfy/k_diffusion/sampling.py:624

                x = x_high + su * s_noise * noise_sampler(self.sigma(s), self.sigma(t))
                s = t
                info['n_accept'] += 1
            else:
                info['n_reject'] += 1
            info['nfe'] += order
            info['steps'] += 1

            if self.info_callback is not None:
                self.info_callback({'x': x, 'i': info['steps'] - 1, 't': s, 't_up': s, 'denoised': denoised, 'error': error, 'h': pid.h, **info})

        return x, info


@torch.no_grad()
def sample_dpm_fast(model, x, sigma_min, sigma_max, n, extra_args=None, callback=None, disable=None, eta=0., s_noise=1., noise_sampler=None):
    """DPM-Solver-Fast (fixed step size). See https://arxiv.org/abs/2206.00927."""
    if sigma_min <= 0 or sigma_max <= 0:
        raise ValueError('sigma_min and sigma_max must not be 0')
    with tqdm(total=n, disable=disable) as pbar:
        dpm_solver = DPMSolver(model, extra_args, eps_callback=pbar.update)
        if callback is not None:
            dpm_solver.info_callback = lambda info: callback({'sigma': dpm_solver.sigma(info['t']), 'sigma_hat': dpm_solver.sigma(info['t_up']), **info})
        return dpm_solver.dpm_solver_fast(x, dpm_solver.t(torch.tensor(sigma_max)), dpm_solver.t(torch.tensor(sigma_min)), n, eta, s_noise, noise_sampler)


@torch.no_grad()
def sample_dpm_adaptive(model, x, sigma_min, sigma_max, extra_args=None, callback=None, disable=None, order=3, rtol=0.05, atol=0.0078, h_init=0.05, pcoeff=0., icoeff=1., dcoeff=0., accept_safety=0.81, eta=0., s_noise=1., noise_sampler=None, return_info=False):
    """DPM-Solver-12 and 23 (adaptive step size). See https://arxiv.org/abs/2206.00927."""
    if sigma_min <= 0 or sigma_max <= 0:
        raise ValueError('sigma_min and sigma_max must not be 0')
    with tqdm(disable=disable) as pbar:
        dpm_solver = DPMSolver(model, extra_args, eps_callback=pbar.update)
        if callback is not None:
            dpm_solver.info_callback = lambda info: callback({'sigma': dpm_solver.sigma(info['t']), 'sigma_hat': dpm_solver.sigma(info['t_up']), **info})
        x, info = dpm_solver.dpm_solver_adaptive(x, dpm_solver.t(torch.tensor(sigma_max)), dpm_solver.t(torch.tensor(sigma_min)), order, rtol, atol, h_init, pcoeff, icoeff, dcoeff, accept_safety, eta, s_noise, noise_sampler)
    if return_info:

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Clamp sigma_min to a small positive epsilon, e.g. max(sigma_min, 1e-5) or the model's sigma_min (often ~0.03)
  2. Strip the terminal 0.0 from computed sigma schedules before passing bounds
  3. Check widget defaults in custom nodes are not 0

Example fix

# before
sample_dpm_fast(model, x, sigma_min=float(sigmas[-1]), sigma_max=float(sigmas[0]), n=steps)  # sigmas[-1] == 0.0
# after
sample_dpm_fast(model, x, sigma_min=max(float(sigmas[-2]), 1e-5), sigma_max=float(sigmas[0]), n=steps)
Defensive patterns

Strategy: validation

Validate before calling

sigma_min = max(float(sigma_min), 1e-5)
sigma_max = max(float(sigma_max), sigma_min)
assert sigma_min > 0 and sigma_max > 0

Prevention

When it happens

Trigger: Calling sample_dpm_fast(model, x, sigma_min=0.0, ...) or with a negative bound. Common when code forwards a scheduler's last sigma (which is often exactly 0.0 for terminal denoise) directly as sigma_min.

Common situations: Custom samplers piping schedule endpoints computed with final sigmas zeroed (ComfyUI's sigmas convention ends in 0); UI widgets defaulting to 0; converting from samplers that take a full sigmas tensor and silently drop the zero.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/0be9398cf58e39e4. Report an issue: GitHub.