sgl-project/sglang · error · ValueError
pairs length must be greater than 0
Error message
pairs length must be greater than 0
What it means
_dual_sigma_shift requires at least one pair row: pairs.shape[0] == 0 raises ValueError because num_steps = 0 would produce empty/degenerate linspace columns and divide-by-zero in the sigma transform. The check runs after the type/shape validations.
Source
Thrown at python/sglang/multimodal_gen/runtime/models/schedulers/flow_match_pair.py:371
kwargs.get("visual_denoising_strength", 1.0)
)
audio_denoising_strength = float(
kwargs.get("audio_denoising_strength", 1.0)
)
visual_mu = kwargs.get(
"visual_exponential_shift_mu", self.exponential_shift_mu
)
audio_mu = kwargs.get(
"audio_exponential_shift_mu", self.exponential_shift_mu
)
def _dual_sigma_shift(pairs: torch.Tensor, *, source: str):
if not isinstance(pairs, torch.Tensor):
raise TypeError("pairs must be a torch.Tensor")
if pairs.ndim != 2 or pairs.shape[1] != 2:
raise ValueError("pairs must be a torch.Tensor of shape [N, 2]")
if pairs.shape[0] == 0:
raise ValueError("pairs length must be greater than 0")
if source not in ("timesteps", "sigmas"):
raise ValueError("source must be 'timesteps' or 'sigmas'")
num_steps = pairs.shape[0]
device = pairs.device
dtype = pairs.dtype
def _build_column(
shift_value: float, denoising_strength: float, mu_override
):
if shift_value <= 0:
raise ValueError("shift must be positive")
if denoising_strength <= 0:
raise ValueError("denoising_strength must be positive")
sigma_start = (
self.sigma_min
+ (self.sigma_max - self.sigma_min) * denoising_strengthView on GitHub (pinned to 0132848349)
Solutions
- Guard num_inference_steps >= 1 before calling set_timesteps / the scheduler
- Check pairs.shape[0] > 0 in your loop and skip/return early for empty requests
- Fix the config default that yields 0 steps (e.g. missing YAML key defaulting to 0)
- Log the offending shape at the request boundary to catch upstream slicing bugs
Example fix
# before
steps = int(req.get("num_steps", 0))
scheduler.set_timesteps(steps)
# after
steps = int(req.get("num_steps", 50))
if steps < 1:
raise ValueError("num_steps must be >= 1")
scheduler.set_timesteps(steps) Defensive patterns
Strategy: validation
Validate before calling
if not isinstance(pairs, torch.Tensor) or pairs.shape[0] == 0:
raise ValueError("num_inference_steps must produce at least one pair")
# or: skip the request
if pairs.shape[0] == 0:
return early_response(request) Try / catch
try:
scheduler.set_timesteps(n)
except ValueError as e:
if 'length must be greater than 0' in str(e):
n = max(1, n) # or reject the request
else:
raise Prevention
- Clamp num_inference_steps to >= 1 at request parsing
- Validate step counts against masks/filters that could empty the schedule
When it happens
Trigger: set_pair_postprocess_by_name('dual_sigma_shift') then calling with an empty [0, 2] tensor — e.g. num_inference_steps=0 passed to set_timesteps, or an upstream filter/slice that removed all steps.
Common situations: num_inference_steps read from request config as 0 (missing field, bad default); slicing pairs with a boolean mask that selected nothing; edge case in batched serving where a request has zero scheduled steps.
Related errors
- pairs must be a torch.Tensor
- pairs must be a torch.Tensor of shape [N, 2]
- `dt_bias` must have {HV * K} elements (got {dt_bias.numel()}
- The batch size is expected to be 1 rather than {q.shape[0]}
- The number of initial states is expected to be equal to the
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/b03cefcda35a396b.
Report an issue: GitHub.