sgl-project/sglang · error · ValueError

`final_sigmas_type` must be one of 'zero', or 'sigma_min', b

Error message

`final_sigmas_type` must be one of 'zero', or 'sigma_min', but got {self.config.final_sigmas_type}

What it means

Raised by set_timesteps (Karras sigma path) when final_sigmas_type is neither 'zero' nor 'sigma_min'. This determines the sigma appended after the last timestep when use_karras_sigmas=True.

Source

Thrown at python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_unipc_multistep.py:440

            sigmas = self._convert_to_karras(
                in_sigmas=sigmas, num_inference_steps=num_inference_steps
            )
            if self.config.use_flow_sigmas:
                # Karras builds sigmas in EDM space; flow-matching models expect
                # sigmas in [0, 1]. Map EDM -> flow with sigma / (sigma + 1) and
                # derive timesteps from the flow sigmas (matches diffusers >=0.38).
                sigmas = sigmas / (sigmas + 1)
                timesteps = (sigmas * self.config.num_train_timesteps).copy()
            else:
                timesteps = np.array(
                    [self._sigma_to_t(sigma, log_sigmas) for sigma in sigmas]
                ).round()
            if self.config.final_sigmas_type == "sigma_min":
                sigma_last = sigmas[-1]
            elif self.config.final_sigmas_type == "zero":
                sigma_last = 0
            else:
                raise ValueError(
                    f"`final_sigmas_type` must be one of 'zero', or 'sigma_min', but got {self.config.final_sigmas_type}"
                )
            sigmas = np.concatenate([sigmas, [sigma_last]]).astype(np.float32)
        elif self.config.use_exponential_sigmas:
            log_sigmas = np.log(sigmas)
            sigmas = np.flip(sigmas).copy()
            sigmas = self._convert_to_exponential(
                in_sigmas=sigmas, num_inference_steps=num_inference_steps
            )
            timesteps = np.array(
                [self._sigma_to_t(sigma, log_sigmas) for sigma in sigmas]
            )
            if self.config.final_sigmas_type == "sigma_min":
                sigma_last = sigmas[-1]
            elif self.config.final_sigmas_type == "zero":
                sigma_last = 0
            else:
                raise ValueError(

View on GitHub (pinned to 0132848349)

Solutions

  1. Set final_sigmas_type='zero' (default for most DDPM-style models)
  2. Set final_sigmas_type='sigma_min' for models trained with nonzero terminal noise
  3. Remove the key entirely to accept the default rather than setting an invalid string

Example fix

// before
UniPCMultistepScheduler.from_config(cfg, use_karras_sigmas=True, final_sigmas_type="sigma_last")
// after
UniPCMultistepScheduler.from_config(cfg, use_karras_sigmas=True, final_sigmas_type="zero")
Defensive patterns

Strategy: validation

Validate before calling

assert cfg.get("final_sigmas_type", "zero") in {"zero", "sigma_min"}

Prevention

When it happens

Trigger: scheduler.set_timesteps(N) with use_karras_sigmas=True and final_sigmas_type set to an invalid string (e.g. 'sigma_last', '').

Common situations: Configs copied from EDM-style pipelines where 'sigma_min' semantics differ, or default None value being written as a string; older diffusers versions lacked this key and hand-merged configs get it wrong.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/4bdb2c1ad53221f2. Report an issue: GitHub.