{"record":{"id":"f339c22f9bb819af","repo":"sgl-project/sglang","slug":"image-token-count-must-be-positive","errorCode":null,"errorMessage":"image_token_count must be positive","messagePattern":"image_token_count must be positive","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/presentation.py","lineNumber":127,"sourceCode":"def minimax_h3_text_only_ids(tokenizer: Any, prompt: str) -> torch.Tensor:\n    \"\"\"t2va presentation: verbatim prompt, no special tokens.\"\"\"\n    if not prompt:\n        raise ValueError(\"prompt must be non-empty\")\n    return torch.tensor(_text_ids(tokenizer, prompt), dtype=torch.long)\n\n\ndef minimax_h3_multi_image_presentation(\n    tokenizer: Any,\n    *,\n    prompt: str,\n    image_token_counts: list[int],\n) -> tuple[torch.Tensor, torch.Tensor]:\n    if not image_token_counts:\n        raise ValueError(\"image_token_counts must be non-empty\")\n    presentation = _Presentation()\n    for index, count in enumerate(image_token_counts, start=1):\n        if int(count) <= 0:\n            raise ValueError(\"image_token_count must be positive\")\n        presentation.text(_text_ids(tokenizer, f\"<Picture {index}>: \"))\n        presentation.vision(_vision_block_ids(tokenizer, IMAGE_PAD, count))\n    presentation.text(_text_ids(tokenizer, prompt))\n    return presentation.build()\n\n\ndef minimax_h3_ref2va_presentation(\n    tokenizer: Any,\n    *,\n    prompt: str,\n    condition_labels: list[tuple[str, int]],\n    image_token_count: int | list[int] | None,\n) -> tuple[torch.Tensor, torch.Tensor]:\n    \"\"\"ref2va positive presentation:\n\n    per condition in request order — image i: ``<Picture i>: `` label followed\n    by the vision block; audio j: ``<Audio j>: `` label only (audio content\n    never enters Qwen) — then the verbatim prompt. Returns ``(ids, token_tags)``","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/presentation.py#L109-L145","documentation":"Each image in the fl2va multi-image presentation needs a positive IMAGE_PAD token count; a zero or negative count cannot form a valid vision block.","triggerScenarios":"Passing image_token_counts containing a 0 or negative entry, e.g. [196, 0].","commonSituations":"Resolution-derived token math flooring to 0 for tiny images; default zero-filled arrays; index bugs mapping image sizes to counts.","solutions":["Recompute the offending entry's token budget from image dimensions","Clamp to at least 1 or drop that image and its `<Picture N>` reference","Add pre-call validation of all counts"],"exampleFix":"// before\nimage_token_counts=[196, 0]\n// after\nimage_token_counts=[196, 196]","handlingStrategy":"validation","validationCode":"assert all(int(c) > 0 for c in image_token_counts), \"image counts must be positive\"","typeGuard":"def valid_image_counts(cs: list[int]) -> bool:\n    return all(isinstance(c, int) and c > 0 for c in cs)","tryCatchPattern":null,"preventionTips":["Recompute counts from image resolution with a floor of 1","Validate the list before the API call"],"tags":["minimax-h3","multi-image","validation"],"backgroundTag":"invalid-value-validation","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}