sgl-project/sglang · error · ValueError
{self.config.timestep_spacing} is not supported. Please make
Error message
{self.config.timestep_spacing} is not supported. Please make sure to choose one of 'linspace', 'leading' or 'trailing'. What it means
Raised by set_timesteps when config.timestep_spacing is not 'linspace', 'leading', or 'trailing'. The scheduler branches on this value to compute the timestep grid; an unrecognized spacing cannot produce timesteps.
Source
Thrown at python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_unipc_multistep.py:414
(np.arange(0, num_inference_steps + 1) * step_ratio)
.round()[::-1][:-1]
.copy()
.astype(np.int64)
)
timesteps += self.config.steps_offset
elif self.config.timestep_spacing == "trailing":
step_ratio = self.config.num_train_timesteps / num_inference_steps
# creates integer timesteps by multiplying by ratio
# casting to int to avoid issues when num_inference_step is power of 3
timesteps = (
np.arange(self.config.num_train_timesteps, 0, -step_ratio)
.round()
.copy()
.astype(np.int64)
)
timesteps -= 1
else:
raise ValueError(
f"{self.config.timestep_spacing} is not supported. Please make sure to choose one of 'linspace', 'leading' or 'trailing'."
)
sigmas = np.array(((1 - self.alphas_cumprod) / self.alphas_cumprod) ** 0.5)
if self.config.use_karras_sigmas:
log_sigmas = np.log(sigmas)
sigmas = np.flip(sigmas).copy()
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(View on GitHub (pinned to 0132848349)
Solutions
- Set timestep_spacing to 'linspace', 'leading', or 'trailing'
- For models trained with zero terminal SNR use 'trailing' along with rescale_betas_zero_snr=True
- Validate the scheduler_config.json before loading
Example fix
// before sched = UniPCMultistepScheduler.from_config(cfg, timestep_spacing="steps") // after sched = UniPCMultistepScheduler.from_config(cfg, timestep_spacing="trailing", rescale_betas_zero_snr=True)
Defensive patterns
Strategy: validation
Validate before calling
assert cfg.get("timestep_spacing", "linspace") in {"linspace", "leading", "trailing"} Prevention
- Pair rescale_betas_zero_snr=True with timestep_spacing='trailing'
- Validate spacing string before set_timesteps
When it happens
Trigger: Calling scheduler.set_timesteps(num_inference_steps) after constructing the scheduler with timestep_spacing set to e.g. 'hop' or a typo like 'trailng'.
Common situations: Configs ported from schedulers that support additional spacings (e.g. DDIM-style or LCM 'trailing' variants), or manual config edits. Zero terminal SNR workflows usually require 'trailing'.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- {beta_schedule} is not implemented for {self.__class__}
- {solver_type} is not implemented for {self.__class__}
- `final_sigmas_type` must be one of 'zero', or 'sigma_min', b
- missing `sample` as a required keyword argument
- prediction_type given as {self.config.prediction_type} must
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/be32a5cab9599045.
Report an issue: GitHub.