{"record":{"id":"aeb4198d98304d50","repo":"sgl-project/sglang","slug":"image-token-count-required-for-an-image-reference","errorCode":null,"errorMessage":"image_token_count required for an image reference","messagePattern":"image_token_count required for an image reference","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":266,"sourceCode":"    )\n    image_token_counts = _as_int_list(image_token_count, name=\"image_token_count\")\n    video_counts_by_ref = _as_nested_int_list(\n        video_block_token_counts,\n        name=\"video_block_token_counts\",\n    )\n    video_timestamps_by_ref = _as_nested_float_list(\n        video_block_timestamps,\n        name=\"video_block_timestamps\",\n    )\n    if len(video_counts_by_ref) != len(video_timestamps_by_ref):\n        raise ValueError(\"video block token counts and timestamps must align\")\n    image_seen = 0\n    video_seen = 0\n    for cond_type, ordinal in condition_labels:\n        if cond_type == \"image\":\n            image_seen += 1\n            if image_seen > len(image_token_counts):\n                raise ValueError(\"image_token_count required for an image reference\")\n            count = int(image_token_counts[image_seen - 1])\n            if count <= 0:\n                raise ValueError(\"image_token_count required for an image reference\")\n            presentation.text(_text_ids(tokenizer, f\"<Picture {ordinal}>: \"))\n            presentation.vision(_vision_block_ids(tokenizer, IMAGE_PAD, count))\n        elif cond_type == \"audio\":\n            presentation.text(_text_ids(tokenizer, f\"<Audio {ordinal}>: \"))\n        elif cond_type == \"video\":\n            video_seen += 1\n            if video_seen > len(video_counts_by_ref):\n                raise ValueError(\n                    \"video reference requires block token counts and timestamps\"\n                )\n            counts = video_counts_by_ref[video_seen - 1]\n            timestamps = video_timestamps_by_ref[video_seen - 1]\n            if not counts or not timestamps:\n                raise ValueError(\n                    \"video reference requires block token counts and timestamps\"","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/presentation.py#L248-L284","documentation":"While walking condition_labels, an image reference was encountered but there are fewer normalized image_token_count entries than image references in the plan.","triggerScenarios":"condition_labels contains 2 image entries but image_token_count=196 (a single int normalizes to [196]) — the second image reference finds no count.","commonSituations":"Passing a scalar image_token_count for a multi-image plan; forgetting to extend counts for additional images; plan changed to include more images than the conditioning data provides.","solutions":["Pass image_token_count as a list with one positive entry per image reference","Regenerate counts to match the current condition_labels plan","Remove extra image references from the plan"],"exampleFix":"// before\ncondition_labels=[(\"image\",1),(\"image\",2)], image_token_count=196\n// after\ncondition_labels=[(\"image\",1),(\"image\",2)], image_token_count=[196,196]","handlingStrategy":"validation","validationCode":"n_images = sum(1 for t, _ in condition_labels if t == \"image\")\nassert len(image_token_counts_list) >= n_images","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive counts length from the plan's image count","Always use a list for multi-image plans"],"tags":["minimax-h3","ref2va","alignment"],"backgroundTag":"length-mismatch-validation","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}