sgl-project/sglang · error · ValueError
`sigmas` and `timesteps` should have the same length as…
Error message
`sigmas` and `timesteps` should have the same length as num_inference_steps, if `num_inference_steps` is provided
What it means
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.
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
Example fix
# before scheduler.set_timesteps(num_inference_steps=28, sigmas=my_sigmas) # len 30 # after scheduler.set_timesteps(num_inference_steps=len(my_sigmas), sigmas=my_sigmas)
Defensive patterns
Strategy: validation
Validate before calling
if num_inference_steps is not None:
if sigmas is not None: assert len(sigmas) == num_inference_steps
if timesteps is not None: assert len(timesteps) == num_inference_steps Prevention
- Derive num_inference_steps from len(sigmas) instead of hardcoding
- Regenerate schedules when changing step counts
When it happens
Trigger: set_timesteps(28, sigmas=[...30 values...]) or a timesteps list off by one (terminal sigma inclusion).
Common situations: Interpolating schedules at a different resolution/count and forgetting to update num_inference_steps; distillation presets with off-by-one lists.
Related errors
- `sigmas` and `timesteps` should have the same length
- denoising_strength must be positive
- Either num_inference_steps, sigmas, or timesteps must be…
- kv-canary: max_prefill_tokens must be positive, got
- kv-canary: length must be , got
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/2159d183dba74e32.
Report an issue: GitHub.
Appendix: source
Thrown at python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_flow_match_euler_discrete.py:317
"""
if self.config.use_dynamic_shifting and mu is None:
raise ValueError(
"`mu` must be passed when `use_dynamic_shifting` is set to be `True`"
)
if (
sigmas is not None
and timesteps is not None
and len(sigmas) != len(timesteps)
):
raise ValueError("`sigmas` and `timesteps` should have the same length")
if num_inference_steps is not None:
if (sigmas is not None and len(sigmas) != num_inference_steps) or (
timesteps is not None and len(timesteps) != num_inference_steps
):
raise ValueError(
"`sigmas` and `timesteps` should have the same length as num_inference_steps, if `num_inference_steps` is provided"
)
else:
if sigmas is not None:
num_inference_steps = len(sigmas)
elif timesteps is not None:
num_inference_steps = len(timesteps)
else:
raise ValueError(
"Either num_inference_steps, sigmas, or timesteps must be provided"
)
self.num_inference_steps = num_inference_steps
# 1. Prepare default sigmas
is_timesteps_provided = timesteps is not None
timesteps_array: np.ndarray | None = NoneView on GitHub (pinned to 0132848349)