sgl-project/sglang · error · ValueError
Passing integer indices as timesteps is not supported. Pass
Error message
Passing integer indices as timesteps is not supported. Pass one of `scheduler.timesteps` as a timestep.
What it means
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.
Source
Thrown at python/sglang/multimodal_gen/runtime/models/schedulers/hunyuan3d_scheduler.py:194
self._step_index = self.index_for_timestep(timestep)
else:
self._step_index = self._begin_index
def step(
self,
model_output: torch.FloatTensor,
timestep: Union[float, torch.FloatTensor],
sample: torch.FloatTensor,
s_churn: float = 0.0,
s_tmin: float = 0.0,
s_tmax: float = float("inf"),
s_noise: float = 1.0,
generator: Optional[torch.Generator] = None,
return_dict: bool = True,
) -> Union[Hunyuan3DFlowMatchSchedulerOutput, Tuple]:
"""Predict the sample from the previous timestep."""
if isinstance(timestep, (int, torch.IntTensor, torch.LongTensor)):
raise ValueError(
"Passing integer indices as timesteps is not supported. "
"Pass one of `scheduler.timesteps` as a timestep."
)
if self.step_index is None:
self._init_step_index(timestep)
# Upcast to avoid precision issues
sample = sample.to(torch.float32)
sigma = self.sigmas[self.step_index]
sigma_next = self.sigmas[self.step_index + 1]
prev_sample = sample + (sigma_next - sigma) * model_output
prev_sample = prev_sample.to(model_output.dtype)
self._step_index += 1
View on GitHub (pinned to 0132848349)
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
Example fix
# before
for i, t in enumerate(scheduler.timesteps):
sample = scheduler.step(model_output, i, sample).prev_sample
# after
for t in scheduler.timesteps:
sample = scheduler.step(model_output, t, sample).prev_sample Defensive patterns
Strategy: type-guard
Validate before calling
t = scheduler.timesteps[i] assert not isinstance(t, (int, torch.IntTensor, torch.LongTensor))
Type guard
def is_float_timestep(t) -> bool:
return not isinstance(t, (int, torch.IntTensor, torch.LongTensor)) Prevention
- Iterate over timesteps directly, never use enumerate indices
- Cast numpy ints with float(t)
When it happens
Trigger: 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).
Common situations: Porting loop code from DDPM-style schedulers that accept ints; timesteps stored as numpy int64; tqdm progress loops using indices.
Related errors
- pair_postprocess must return a torch.Tensor
- Passing integer indices as timesteps is not supported.
- Passing integer indices (e.g. from `enumerate(timesteps)`) a
- Expected scheduler.sigmas to be a tensor for JoyEcho.
- Unsupported type {type(data)}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/806e30a70a945890.
Report an issue: GitHub.