{"record":{"id":"67fcf2e478191ceb","repo":"sgl-project/sglang","slug":"name-values-must-be-positive-got-list-value-r","errorCode":null,"errorMessage":"{name} values must be positive, got {list(value)!r}","messagePattern":"(.+?) values must be positive, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/packed_tokens.py","lineNumber":14,"sourceCode":"# SPDX-License-Identifier: Apache-2.0\nfrom __future__ import annotations\n\nfrom collections.abc import Sequence\n\nimport torch\n\n\ndef _int_tuple(value: Sequence[int], name: str, length: int) -> tuple[int, ...]:\n    if len(value) != length:\n        raise ValueError(f\"{name} must have length {length}, got {list(value)!r}\")\n    out = tuple(int(item) for item in value)\n    if any(item <= 0 for item in out):\n        raise ValueError(f\"{name} values must be positive, got {list(value)!r}\")\n    return out\n\n\ndef _rank(tensor: torch.Tensor, name: str, rank: int) -> None:\n    if tensor.ndim != rank:\n        raise ValueError(f\"{name} must be rank {rank}, got shape={list(tensor.shape)}\")\n\n\ndef minimax_h3_patchify_video_latent(\n    latent: torch.Tensor,\n    *,\n    patch_size: Sequence[int],\n) -> torch.Tensor:\n    \"\"\"Pack SGLang video latent [B,C,T,H,W] into DiT token rows.\"\"\"\n\n    _rank(latent, \"video latent\", 5)\n    pt, ph, pw = _int_tuple(patch_size, \"patch_size\", 3)\n    batch, channel, full_t, full_h, full_w = (int(dim) for dim in latent.shape)","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/packed_tokens.py#L1-L32","documentation":"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.","triggerScenarios":"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)).","commonSituations":"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.","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."],"exampleFix":"# before\npatch_size = (t, h, w)  # t = num_latent_frames // pt, may be 0 for empty clip\n\n# after\nif t <= 0 or h <= 0 or w <= 0:\n    raise ValueError(\"empty video segment\")\npatch_size = (t, h, w)","handlingStrategy":"validation","validationCode":"assert all(x > 0 for x in patch_size), f\"patch_size entries must be > 0, got {patch_size}\"\nassert all(x > 0 for x in latent_shape), f\"latent_shape entries must be > 0, got {latent_shape}\"","typeGuard":"def is_positive_tuple(v) -> bool:\n    return len(v) > 0 and all(isinstance(x, int) and x > 0 for x in v)","tryCatchPattern":null,"preventionTips":["Skip empty media segments before computing latent shapes.","Never compute dims via expressions like n - k without guarding n > k."],"tags":["validation","shape","positive-check","minimax-h3"],"backgroundTag":"invalid-argument-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}