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

  1. Call scheduler.set_timesteps(num_inference_steps) once before the denoising loop
  2. Order pipeline code: create scheduler -> set_timesteps -> loop step()
  3. 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

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


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