{"record":{"id":"806e30a70a945890","repo":"sgl-project/sglang","slug":"passing-integer-indices-as-timesteps-is-not-suppor","errorCode":null,"errorMessage":"Passing integer indices as timesteps is not supported. Pass one of `scheduler.timesteps` as a timestep.","messagePattern":"Passing integer indices as timesteps is not supported\\. Pass one of `scheduler\\.timesteps` as a timestep\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/schedulers/hunyuan3d_scheduler.py","lineNumber":194,"sourceCode":"            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        s_churn: float = 0.0,\n        s_tmin: float = 0.0,\n        s_tmax: float = float(\"inf\"),\n        s_noise: float = 1.0,\n        generator: Optional[torch.Generator] = None,\n        return_dict: bool = True,\n    ) -> Union[Hunyuan3DFlowMatchSchedulerOutput, Tuple]:\n        \"\"\"Predict the sample from the previous timestep.\"\"\"\n        if isinstance(timestep, (int, torch.IntTensor, torch.LongTensor)):\n            raise ValueError(\n                \"Passing integer indices as timesteps is not supported. \"\n                \"Pass one of `scheduler.timesteps` as a timestep.\"\n            )\n\n        if self.step_index is None:\n            self._init_step_index(timestep)\n\n        # Upcast to avoid precision issues\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        self._step_index += 1\n","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/schedulers/hunyuan3d_scheduler.py#L176-L212","documentation":"step() rejects int/IntTensor/LongTensor timesteps because the flow-match scheduler treats timesteps as continuous float values (indexed lookup via _init_step_index would be ambiguous). Timesteps must be float values taken from scheduler.timesteps.","triggerScenarios":"Looping `for i, t in enumerate(scheduler.timesteps)` and passing `t` that got cast to int, or passing the loop index i instead of t; passing timestep=int(t).","commonSituations":"Porting loop code from DDPM-style schedulers that accept ints; timesteps stored as numpy int64; tqdm progress loops using indices.","solutions":["Iterate directly over scheduler.timesteps and pass the raw float value","Convert with float(t) / t.float() if the value passed through numpy or casting","Never pass enumerate()'s index as the timestep"],"exampleFix":"# before\nfor i, t in enumerate(scheduler.timesteps):\n    sample = scheduler.step(model_output, i, sample).prev_sample\n# after\nfor t in scheduler.timesteps:\n    sample = scheduler.step(model_output, t, sample).prev_sample","handlingStrategy":"type-guard","validationCode":"t = scheduler.timesteps[i]\nassert not isinstance(t, (int, torch.IntTensor, torch.LongTensor))","typeGuard":"def is_float_timestep(t) -> bool:\n    return not isinstance(t, (int, torch.IntTensor, torch.LongTensor))","tryCatchPattern":null,"preventionTips":["Iterate over timesteps directly, never use enumerate indices","Cast numpy ints with float(t)"],"tags":["scheduler","timestep-type","type-mismatch"],"backgroundTag":"invalid-timestep-type","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}