sgl-project/sglang · error · ValueError
{name} must have length {length}, got {list(value)!r}
Error message
{name} must have length {length}, got {list(value)!r} What it means
The _int_tuple helper validates shape-like arguments to the minimax_h3 patchify/unpatchify functions and requires exactly the expected length (patch_size must be length 3, latent_shape length 4). The error names the argument and echoes the received list so mismatches are immediately visible.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/packed_tokens.py:11
# 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."""
View on GitHub (pinned to 0132848349)
Solutions
- Pass patch_size as a 3-tuple (pt, ph, pw) and latent_shape as a 4-tuple (t, h, w, channel).
- Check the model config's patch_size/latent shape entries and pad/convert them before calling.
- Add an assert on len() at the call site if values come from dynamic config.
Example fix
# before minimax_h3_patchify_video_latent(latent, patch_size=(16, 16)) # after minimax_h3_patchify_video_latent(latent, patch_size=(1, 16, 16))
Defensive patterns
Strategy: validation
Validate before calling
assert len(patch_size) == 3, f"patch_size must be (pt, ph, pw), got {patch_size}"
assert len(latent_shape) == 4, f"latent_shape must be (t, h, w, c), got {latent_shape}" Type guard
def is_patch_size(v) -> bool:
return len(v) == 3 and all(isinstance(x, int) and x > 0 for x in v) Prevention
- Document the expected tuple order (pt,ph,pw) and (t,h,w,c) at call sites.
- Validate config-derived tuples once at startup.
When it happens
Trigger: Calling minimax_h3_patchify_video_latent with patch_size=(16, 16) (length 2) or minimax_h3_unpatchify_video_tokens with latent_shape=(8, 64, 64) (length 3) instead of 4 elements (t,h,w,c).
Common situations: Passing a 2D spatial patch size where (t,h,w) is expected; reusing a VAE latent shape of (C,T,H,W) as latent_shape which expects (T,H,W,C)-ordering of 4 dims; config files that list only height/width patch sizes.
Related errors
- {name} values must be positive, got {list(value)!r}
- video latent spatial/time dims must be divisible by patch_si
- 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
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/c0a0d0a018b375e2.
Report an issue: GitHub.