{"record":{"id":"b31ca29f22c09c3f","repo":"sgl-project/sglang","slug":"image-token-counts-must-be-non-empty","errorCode":null,"errorMessage":"image_token_counts must be non-empty","messagePattern":"image_token_counts must be non-empty","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":123,"sourceCode":"            video_token_id=video_token_id,\n        )\n\n\ndef 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:","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/presentation.py#L105-L141","documentation":"minimax_h3_multi_image_presentation (fl2va keyframe path) requires at least one image token count because it must emit `<Picture N>:` + IMAGE_PAD blocks for every image in the prompt.","triggerScenarios":"Calling minimax_h3_multi_image_presentation with image_token_counts=[] while prompt describes images.","commonSituations":"Multi-image prompts where vision token budgets were not computed (missing preprocessor output); conditioning built before image sizes are known; accidentally passing the wrong variable (e.g. video counts).","solutions":["Compute per-image token counts (from image resolution/patch math) and pass a non-empty list","If the prompt is text-only, use minimax_h3_text_only_ids instead","Check that the number of counts matches the number of images referenced in the prompt"],"exampleFix":"// before\nminimax_h3_multi_image_presentation(tok, prompt=p, image_token_counts=[])\n// after\nminimax_h3_multi_image_presentation(tok, prompt=p, image_token_counts=[196, 196])","handlingStrategy":"validation","validationCode":"if not image_token_counts:\n    raise ValueError(\"at least one image token count required\")","typeGuard":"def has_image_counts(cs: list[int]) -> bool:\n    return len(cs) > 0 and all(c > 0 for c in cs)","tryCatchPattern":null,"preventionTips":["Compute vision token budgets before building the presentation","Route text-only prompts to minimax_h3_text_only_ids"],"tags":["minimax-h3","multi-image","validation"],"backgroundTag":"empty-input-validation","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}