{"record":{"id":"2159d183dba74e32","repo":"sgl-project/sglang","slug":"sigmas-and-timesteps-should-have-the-same-leng-2159d1","errorCode":null,"errorMessage":"`sigmas` and `timesteps` should have the same length as num_inference_steps, if `num_inference_steps` is provided","messagePattern":"`sigmas` and `timesteps` should have the same length as num_inference_steps, if `num_inference_steps` is provided","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_flow_match_euler_discrete.py","lineNumber":317,"sourceCode":"        \"\"\"\n\n        if self.config.use_dynamic_shifting and mu is None:\n            raise ValueError(\n                \"`mu` must be passed when `use_dynamic_shifting` is set to be `True`\"\n            )\n\n        if (\n            sigmas is not None\n            and timesteps is not None\n            and len(sigmas) != len(timesteps)\n        ):\n            raise ValueError(\"`sigmas` and `timesteps` should have the same length\")\n\n        if num_inference_steps is not None:\n            if (sigmas is not None and len(sigmas) != num_inference_steps) or (\n                timesteps is not None and len(timesteps) != num_inference_steps\n            ):\n                raise ValueError(\n                    \"`sigmas` and `timesteps` should have the same length as num_inference_steps, if `num_inference_steps` is provided\"\n                )\n        else:\n            if sigmas is not None:\n                num_inference_steps = len(sigmas)\n            elif timesteps is not None:\n                num_inference_steps = len(timesteps)\n            else:\n                raise ValueError(\n                    \"Either num_inference_steps, sigmas, or timesteps must be provided\"\n                )\n\n        self.num_inference_steps = num_inference_steps\n\n        # 1. Prepare default sigmas\n        is_timesteps_provided = timesteps is not None\n\n        timesteps_array: np.ndarray | None = None","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_flow_match_euler_discrete.py#L299-L335","documentation":"If num_inference_steps is given explicitly, any provided sigmas or timesteps list must have exactly that length. This catches inconsistency between the declared step count and the custom schedule arrays.","triggerScenarios":"set_timesteps(28, sigmas=[...30 values...]) or a timesteps list off by one (terminal sigma inclusion).","commonSituations":"Interpolating schedules at a different resolution/count and forgetting to update num_inference_steps; distillation presets with off-by-one lists.","solutions":["Match the list length to num_inference_steps exactly (decide terminal-sigma convention)","Omit num_inference_steps and let it be inferred from len(sigmas)/len(timesteps)","Regenerate the schedule for the target step count"],"exampleFix":"# before\nscheduler.set_timesteps(num_inference_steps=28, sigmas=my_sigmas)  # len 30\n# after\nscheduler.set_timesteps(num_inference_steps=len(my_sigmas), sigmas=my_sigmas)","handlingStrategy":"validation","validationCode":"if num_inference_steps is not None:\n    if sigmas is not None: assert len(sigmas) == num_inference_steps\n    if timesteps is not None: assert len(timesteps) == num_inference_steps","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive num_inference_steps from len(sigmas) instead of hardcoding","Regenerate schedules when changing step counts"],"tags":["scheduler","length-mismatch","validation"],"backgroundTag":"schedule-length-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}