sgl-project/sglang · error · ValueError
Number of inference steps is 'None', you need to call 'set_t
Error message
Number of inference steps is 'None', you need to call 'set_timesteps' after creating the scheduler
What it means
scheduler.step() requires a timestep grid; num_inference_steps is None until set_timesteps() has been called. The scheduler is stateful and steps through precomputed sigmas indexed by step_index, so stepping before initialization has no valid sigma schedule.
Source
Thrown at python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_unipc_multistep.py:1113
Args:
model_output (`torch.Tensor`):
The direct output from learned diffusion model.
timestep (`int`):
The current discrete timestep in the diffusion chain.
sample (`torch.Tensor`):
A current instance of a sample created by the diffusion process.
return_dict (`bool`):
Whether or not to return a [`~schedulers.scheduling_utils.SchedulerOutput`] or `tuple`.
Returns:
[`~schedulers.scheduling_utils.SchedulerOutput`] or `tuple`:
If return_dict is `True`, [`~schedulers.scheduling_utils.SchedulerOutput`] is returned, otherwise a
tuple is returned where the first element is the sample tensor.
"""
if self.num_inference_steps is None:
raise ValueError(
"Number of inference steps is 'None', you need to call 'set_timesteps' after creating the scheduler"
)
if self.step_index is None:
self._init_step_index(timestep)
use_corrector = (
self.step_index > 0
and self.step_index - 1 not in self.disable_corrector
and self.last_sample is not None
)
model_output_convert = self.convert_model_output(model_output, sample=sample)
if use_corrector:
sample = self.multistep_uni_c_bh_update(
this_model_output=model_output_convert,
last_sample=self.last_sample,
this_sample=sample,View on GitHub (pinned to 0132848349)
Solutions
- Call scheduler.set_timesteps(num_inference_steps) once before the denoising loop
- Order pipeline code: create scheduler -> set_timesteps -> loop step()
- If re-running generation, re-call set_timesteps each run
Example fix
// before
for t in sched.timesteps:
out = sched.step(model_output, t, latents)
// after
sched.set_timesteps(num_inference_steps=50)
for t in sched.timesteps:
out = sched.step(model_output, t, latents).prev_sample Defensive patterns
Strategy: validation
Validate before calling
assert sched.num_inference_steps is not None, "call set_timesteps() before stepping"
Prevention
- Always structure pipelines as: build scheduler -> set_timesteps -> denoise loop -> step()
- Re-call set_timesteps when reusing a scheduler for a new generation
When it happens
Trigger: Calling scheduler.step(model_output, t, sample) before scheduler.set_timesteps(num_inference_steps) in the denoise loop.
Common situations: Custom sampling loops that skip set_timesteps; refactoring a pipeline and dropping the init call; reusing a scheduler across runs where timesteps were reset to None.
Related errors
- {beta_schedule} is not implemented for {self.__class__}
- {solver_type} is not implemented for {self.__class__}
- {self.config.timestep_spacing} is not supported. Please make
- `final_sigmas_type` must be one of 'zero', or 'sigma_min', b
- missing `sample` as a required keyword argument
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/fe52cf584674e958.
Report an issue: GitHub.