Comfy-Org/ComfyUI · error · ValueError

Unsupported noise schedule {}. The schedule needs to be 'dis

Error message

Unsupported noise schedule {}. The schedule needs to be 'discrete' or 'linear' or 'cosine'

What it means

NoiseScheduleVP (the DPM-Solver schedule used by the uni_pc extra sampler) only implements three schedule types: 'discrete' (from betas or alphas_cumprod), 'linear' (continuous VPSDE), and 'cosine'. The constructor validates the schedule string and raises ValueError for anything else, because log-alpha computation differs per schedule and there is no generic fallback.

Source

Thrown at comfy/extra_samplers/uni_pc.py:100

            A wrapper object of the forward SDE (VP type).

        ===============================================================

        Example:

        # For discrete-time DPMs, given betas (the beta array for n = 0, 1, ..., N - 1):
        >>> ns = NoiseScheduleVP('discrete', betas=betas)

        # For discrete-time DPMs, given alphas_cumprod (the \hat{alpha_n} array for n = 0, 1, ..., N - 1):
        >>> ns = NoiseScheduleVP('discrete', alphas_cumprod=alphas_cumprod)

        # For continuous-time DPMs (VPSDE), linear schedule:
        >>> ns = NoiseScheduleVP('linear', continuous_beta_0=0.1, continuous_beta_1=20.)

        """

        if schedule not in ['discrete', 'linear', 'cosine']:
            raise ValueError("Unsupported noise schedule {}. The schedule needs to be 'discrete' or 'linear' or 'cosine'".format(schedule))

        self.schedule = schedule
        if schedule == 'discrete':
            if betas is not None:
                log_alphas = 0.5 * torch.log(1 - betas).cumsum(dim=0)
            else:
                assert alphas_cumprod is not None
                log_alphas = 0.5 * torch.log(alphas_cumprod)
            self.total_N = len(log_alphas)
            self.T = 1.
            self.t_array = torch.linspace(0., 1., self.total_N + 1)[1:].reshape((1, -1))
            self.log_alpha_array = log_alphas.reshape((1, -1,))
        else:
            self.total_N = 1000
            self.beta_0 = continuous_beta_0
            self.beta_1 = continuous_beta_1
            self.cosine_s = 0.008
            self.cosine_beta_max = 999.

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Use one of 'discrete', 'linear', 'cosine'.
  2. If you have raw betas/alphas_cumprod from the model, pass schedule='discrete' with betas= or alphas_cumprod=.
  3. Normalize the string: s.strip().lower() before constructing.
  4. For truly different schedules, precompute log_alphas yourself instead of relying on NoiseScheduleVP.

Example fix

# before
ns = NoiseScheduleVP('discrete ')

# after
betas = model_betas  # from your diffusion model
ns = NoiseScheduleVP('discrete', betas=betas)
Defensive patterns

Strategy: validation

Validate before calling

schedule = schedule.strip().lower()
if schedule not in ("discrete", "linear", "cosine"):
    raise SystemExit("schedule must be discrete, linear, or cosine")
ns = NoiseScheduleVP(schedule, betas=betas)

Type guard

def is_valid_schedule(name: str) -> bool:
    return name.strip().lower() in ("discrete", "linear", "cosine")

Try / catch

try:
    ns = NoiseScheduleVP(schedule, betas=betas)
except ValueError:
    ns = NoiseScheduleVP("discrete", betas=betas)  # known-safe path for raw betas

Prevention

When it happens

Trigger: Constructing NoiseScheduleVP('polynomial', ...) or with a typo ('Discrete', 'linear '); calling uni_pc sampling on a model whose noise-schedule metadata yields a string outside the three allowed values; custom samplers passing their own schedule names through.

Common situations: Adapting the uni_pc sampler to a new model family whose betas come from a different parameterization; passing model.predicted_info string directly; case/whitespace mismatches.

Related errors


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