sgl-project/sglang · error · ValueError
{name} values must be positive, got {list(value)!r}
Error message
{name} values must be positive, got {list(value)!r} What it means
After checking length, _int_tuple converts each element with int() and requires every value to be strictly positive. This fires when a shape/patch tuple contains a zero or negative entry, which would make patch grid math (divisions and row counts) invalid.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/packed_tokens.py:14
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from collections.abc import Sequence
import torch
def _int_tuple(value: Sequence[int], name: str, length: int) -> tuple[int, ...]:
if len(value) != length:
raise ValueError(f"{name} must have length {length}, got {list(value)!r}")
out = tuple(int(item) for item in value)
if any(item <= 0 for item in out):
raise ValueError(f"{name} values must be positive, got {list(value)!r}")
return out
def _rank(tensor: torch.Tensor, name: str, rank: int) -> None:
if tensor.ndim != rank:
raise ValueError(f"{name} must be rank {rank}, got shape={list(tensor.shape)}")
def minimax_h3_patchify_video_latent(
latent: torch.Tensor,
*,
patch_size: Sequence[int],
) -> torch.Tensor:
"""Pack SGLang video latent [B,C,T,H,W] into DiT token rows."""
_rank(latent, "video latent", 5)
pt, ph, pw = _int_tuple(patch_size, "patch_size", 3)
batch, channel, full_t, full_h, full_w = (int(dim) for dim in latent.shape)View on GitHub (pinned to 0132848349)
Solutions
- Fix the upstream producer so latent/patch dims are >= 1 (e.g. skip empty video segments).
- Guard against frame_count == 0 before computing frame_count - 1 style values.
- Validate config-loaded patch sizes at startup and fail with a clear config error.
Example fix
# before
patch_size = (t, h, w) # t = num_latent_frames // pt, may be 0 for empty clip
# after
if t <= 0 or h <= 0 or w <= 0:
raise ValueError("empty video segment")
patch_size = (t, h, w) Defensive patterns
Strategy: validation
Validate before calling
assert all(x > 0 for x in patch_size), f"patch_size entries must be > 0, got {patch_size}"
assert all(x > 0 for x in latent_shape), f"latent_shape entries must be > 0, got {latent_shape}" Type guard
def is_positive_tuple(v) -> bool:
return len(v) > 0 and all(isinstance(x, int) and x > 0 for x in v) Prevention
- Skip empty media segments before computing latent shapes.
- Never compute dims via expressions like n - k without guarding n > k.
When it happens
Trigger: Calling minimax_h3_patchify_video_latent with patch_size=(1, 0, 16) or minimax_h3_unpatchify_video_tokens with latent_shape containing a 0 dim (e.g. (0, 8, 8, 16)).
Common situations: Zero-dimensional latents from empty video segments or dropped frames; negative values from signed arithmetic upstream (e.g. frame_count - 1 when frame_count == 0); a default patch_size left as (0,0,0) in config before initialization.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- {name} must have length {length}, got {list(value)!r}
- Validate failed: unsupported tensor shape: {t.shape}.
- Validate failed: S({S}) must be divisible by F({F}).
- kv-canary: {name} must be 1-D, got shape {tuple(tensor.shape
- kv-canary: {name} must be 2-D, got shape {tuple(tensor.shape
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/67fcf2e478191ceb.
Report an issue: GitHub.