{"record":{"id":"c0a0d0a018b375e2","repo":"sgl-project/sglang","slug":"name-must-have-length-length-got-list-value","errorCode":null,"errorMessage":"{name} must have length {length}, got {list(value)!r}","messagePattern":"(.+?) must have length (.+?), 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":11,"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","sourceCodeStart":1,"sourceCodeEnd":29,"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-L29","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"# before\nminimax_h3_patchify_video_latent(latent, patch_size=(16, 16))\n\n# after\nminimax_h3_patchify_video_latent(latent, patch_size=(1, 16, 16))","handlingStrategy":"validation","validationCode":"assert len(patch_size) == 3, f\"patch_size must be (pt, ph, pw), got {patch_size}\"\nassert len(latent_shape) == 4, f\"latent_shape must be (t, h, w, c), got {latent_shape}\"","typeGuard":"def is_patch_size(v) -> bool:\n    return len(v) == 3 and all(isinstance(x, int) and x > 0 for x in v)","tryCatchPattern":null,"preventionTips":["Document the expected tuple order (pt,ph,pw) and (t,h,w,c) at call sites.","Validate config-derived tuples once at startup."],"tags":["validation","shape","patchify","minimax-h3"],"backgroundTag":"invalid-argument-shape","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}