{"record":{"id":"36c75509e954dbfc","repo":"sgl-project/sglang","slug":"number-of-inference-steps-is-none-run-set-time","errorCode":null,"errorMessage":"Number of inference steps is 'None', run 'set_timesteps' first","messagePattern":"Number of inference steps is 'None', run 'set_timesteps' first","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_helios.py","lineNumber":563,"sourceCode":"                torch.einsum(\"k,bkc...->bc...\", rhos_c[:-1], D1s)\n                if D1s is not None\n                else 0\n            )\n            D1_t = model_t - m0\n            x_t = x_t_ - sigma_t * B_h * (corr_res + rhos_c[-1] * D1_t)\n\n        return x_t.to(x.dtype)\n\n    def step_unipc(\n        self,\n        model_output,\n        timestep=None,\n        sample=None,\n        return_dict: bool = True,\n        **kwargs,\n    ) -> HeliosSchedulerOutput | tuple:\n        if self.num_inference_steps is None:\n            raise ValueError(\n                \"Number of inference steps is 'None', run 'set_timesteps' first\"\n            )\n\n        if self.step_index is None:\n            self._step_index = 0\n\n        use_corrector = (\n            self.step_index > 0\n            and self.step_index - 1 not in self.disable_corrector\n            and self.last_sample is not None\n        )\n\n        model_output_convert = self.convert_model_output(model_output, sample=sample)\n\n        if use_corrector:\n            sample = self.multistep_uni_c_bh_update(\n                this_model_output=model_output_convert,\n                last_sample=self.last_sample,","sourceCodeStart":545,"sourceCodeEnd":581,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_helios.py#L545-L581","documentation":"The Helios scheduler's step() was called before set_timesteps(), so self.num_inference_steps is None. Like diffusers schedulers, the UniPC multistep solver needs a timestep schedule initialized before any denoising step can compute coefficients.","triggerScenarios":"Calling scheduler.step(...) or step_unipc(...) on a HeliosScheduler without a prior scheduler.set_timesteps(num_inference_steps) call; or re-using a scheduler after reset without re-running set_timesteps.","commonSituations":"Custom denoise loops that skip the standard pipeline setup; copying scheduler code into a new runtime (multimodal_gen) and forgetting the timesteps init; resetting scheduler state between generations.","solutions":["Call scheduler.set_timesteps(num_inference_steps) before the first scheduler.step() in your denoise loop","Verify num_inference_steps stays non-None across the loop (e.g. it wasn't cleared by reset_scheduler_history or a fresh pipeline run)","If wrapping the scheduler, add an assertion/guard after init to fail fast with a clearer message"],"exampleFix":"// before\nfor t in timesteps:\n    sample = scheduler.step(model_out, t, sample).prev_sample  # ValueError\n\n// after\nscheduler.set_timesteps(num_inference_steps=50)\nfor t in scheduler.timesteps:\n    sample = scheduler.step(model_out, t, sample).prev_sample","handlingStrategy":"validation","validationCode":"assert scheduler.num_inference_steps is not None, \"call scheduler.set_timesteps(N) before stepping\"","typeGuard":"def is_scheduler_ready(s) -> bool:\n    return getattr(s, \"num_inference_steps\", None) is not None","tryCatchPattern":null,"preventionTips":["Always call set_timesteps immediately after constructing the scheduler","Wrap the denoise loop so it fails fast if num_inference_steps is None before iterating"],"tags":["diffusion","scheduler","state-not-initialized","helios"],"backgroundTag":"scheduler-not-initialized","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}