{"record":{"id":"7c836d21518c527e","repo":"sgl-project/sglang","slug":"passing-integer-indices-as-timesteps-is-not-suppor-7c836d","errorCode":null,"errorMessage":"Passing integer indices as timesteps is not supported.","messagePattern":"Passing integer indices as timesteps is not supported\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/schedulers/hunyuan3d_scheduler.py","lineNumber":338,"sourceCode":"    def _init_step_index(self, timestep: Union[float, torch.Tensor]):\n        if self.begin_index is None:\n            if isinstance(timestep, torch.Tensor):\n                timestep = timestep.to(self.timesteps.device)\n            self._step_index = self.index_for_timestep(timestep)\n        else:\n            self._step_index = self._begin_index\n\n    def step(\n        self,\n        model_output: torch.FloatTensor,\n        timestep: Union[float, torch.FloatTensor],\n        sample: torch.FloatTensor,\n        generator: Optional[torch.Generator] = None,\n        return_dict: bool = True,\n    ) -> Union[Hunyuan3DConsistencyFlowMatchSchedulerOutput, Tuple]:\n        \"\"\"Perform one step of the consistency flow matching scheduler.\"\"\"\n        if isinstance(timestep, (int, torch.IntTensor, torch.LongTensor)):\n            raise ValueError(\"Passing integer indices as timesteps is not supported.\")\n\n        if self.step_index is None:\n            self._init_step_index(timestep)\n\n        sample = sample.to(torch.float32)\n\n        sigma = self.sigmas_[self.step_index]\n        sigma_next = self.sigmas_[self.step_index + 1]\n\n        prev_sample = sample + (sigma_next - sigma) * model_output\n        prev_sample = prev_sample.to(model_output.dtype)\n\n        pred_original_sample = sample + (1.0 - sigma) * model_output\n        pred_original_sample = pred_original_sample.to(model_output.dtype)\n\n        self._step_index += 1\n\n        if not return_dict:","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/schedulers/hunyuan3d_scheduler.py#L320-L356","documentation":"The consistency flow-match variant of step() enforces the same rule as 1749: timesteps are continuous floats, and integer indices cannot be mapped to a sigma. Passed timesteps must come from scheduler.timesteps as floats.","triggerScenarios":"Calling the consistency scheduler's step with an int or integer tensor timestep, e.g. an enumerate index or an int-cast numpy value.","commonSituations":"Shared denoising loop code reused across the standard and consistency schedulers where one path yields ints.","solutions":["Pass float values from scheduler.timesteps","Cast before calling: float(t) or t.to(torch.float32)","Audit shared loop code for index-based timestep passing"],"exampleFix":"# before\nsample = scheduler.step(model_output, step_idx, sample).prev_sample\n# after\nsample = scheduler.step(model_output, scheduler.timesteps[step_idx], sample).prev_sample","handlingStrategy":"type-guard","validationCode":"t = float(scheduler.timesteps[step_idx])\nscheduler.step(model_output, t, sample)","typeGuard":"def as_float_timestep(t):\n    return float(t) if isinstance(t, (int, np.integer)) else t","tryCatchPattern":null,"preventionTips":["Wrap timestep values in a float() coercion helper","Keep loop code shared across schedulers float-only"],"tags":["scheduler","timestep-type","consistency-model"],"backgroundTag":"invalid-timestep-type","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}