{"record":{"id":"d2ab428a2dfc2775","repo":"sgl-project/sglang","slug":"name-must-be-a-floating-point-tensor","errorCode":null,"errorMessage":"{name} must be a floating point tensor","messagePattern":"(.+?) must be a floating point tensor","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_minimax_h3_euler_ancestral.py","lineNumber":19,"sourceCode":"# SPDX-License-Identifier: Apache-2.0\nfrom __future__ import annotations\n\nimport math\nfrom typing import Any\n\nimport torch\n\n\ndef _require_finite_tensor(tensor: torch.Tensor, name: str) -> None:\n    if not bool(torch.isfinite(tensor).all().item()):\n        raise ValueError(f\"{name} must be finite\")\n\n\ndef _validate_unit_timestep(timestep: torch.Tensor, name: str) -> None:\n    if not isinstance(timestep, torch.Tensor):\n        raise ValueError(f\"{name} must be a torch.Tensor\")\n    if not torch.is_floating_point(timestep):\n        raise ValueError(f\"{name} must be a floating point tensor\")\n    _require_finite_tensor(timestep, name)\n    out_of_range = (timestep < 0) | (timestep > 1)\n    if bool(out_of_range.any().item()):\n        raise ValueError(f\"{name} must be in [0, 1]\")\n\n\ndef _validate_sigma(value: float, name: str) -> float:\n    sigma = float(value)\n    if not math.isfinite(sigma):\n        raise ValueError(f\"{name} must be finite\")\n    if sigma < 0.0:\n        raise ValueError(f\"{name} must be non-negative\")\n    return sigma\n\n\ndef _validate_timestep_sigma_pair(\n    timestep: torch.Tensor,\n    sigma_curr: float,","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_minimax_h3_euler_ancestral.py#L1-L37","documentation":"The unit-timestep validator requires a floating-point dtype tensor (float32/float16/bfloat16). Integer-dtype timesteps — the diffusers convention (e.g. 700, 250 as long tensors) — are rejected because the flow-matching math treats timestep as a continuous value in [0,1].","triggerScenarios":"Passing timestep as an int/long tensor such as torch.tensor(700) or a timesteps schedule of dtype torch.int64 from a standard diffusion pipeline.","commonSituations":"Reusing a discrete diffusion timestep schedule (ints in [1,1000]) with the minimax_h3 normalized flow scheduler without converting to unit-scale floats.","solutions":["Convert the discrete timestep to the unit scale the scheduler expects: t_unit = timestep.float() / num_train_timesteps (e.g. /1000), yielding a float in [0,1]","Or use the scheduler's own generated schedule (sigma/timestep pairs) instead of hand-built integer timesteps"],"exampleFix":"# before\nx0 = minimax_h3_rf_v_to_x0(xt, v, torch.tensor(700))  # ValueError: not floating point\n\n# after\nt_unit = torch.tensor(700, dtype=torch.float32) / 1000.0  # 0.7\nx0 = minimax_h3_rf_v_to_x0(xt, v, t_unit)","handlingStrategy":"type-guard","validationCode":"assert isinstance(timestep, torch.Tensor) and torch.is_floating_point(timestep)","typeGuard":"def is_float_unit_timestep(t) -> bool:\n    return isinstance(t, torch.Tensor) and torch.is_floating_point(t)","tryCatchPattern":null,"preventionTips":["Never feed int64 diffusion timesteps directly; normalize with .float() / 1000","Build schedules in float32 from the start"],"tags":["diffusion","scheduler","dtype","timestep"],"backgroundTag":"wrong-tensor-dtype","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}