{"record":{"id":"d12682ecc6a355db","repo":"sgl-project/sglang","slug":"context-video-block-token-count-must-be-positive","errorCode":null,"errorMessage":"{context}video block token count must be positive","messagePattern":"(.+?)video block 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":101,"sourceCode":"\ndef _timestamped_video_blocks(\n    presentation: _Presentation,\n    tokenizer: Any,\n    *,\n    counts: Sequence[int],\n    timestamps: Sequence[float],\n    context: str,\n    video_token_id: int | None,\n) -> None:\n    \"\"\"Emit per-temporal-block ``<{t:.1f} seconds>`` text + VIDEO vision.\"\"\"\n\n    counts = [int(value) for value in counts]\n    timestamps = [float(value) for value in timestamps]\n    if not counts or len(counts) != len(timestamps):\n        raise ValueError(f\"{context}video block token counts and timestamps must align\")\n    for count, timestamp in zip(counts, timestamps):\n        if count <= 0:\n            raise ValueError(f\"{context}video block token count must be positive\")\n        presentation.text(_text_ids(tokenizer, f\"<{timestamp:.1f} seconds>\"))\n        presentation.vision(\n            _vision_block_ids(tokenizer, VIDEO_PAD, count),\n            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,","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/presentation.py#L83-L119","documentation":"Raised when a video temporal block's token count is <= 0 while emitting the timestamped VIDEO_PAD vision blocks. Each block must contain at least one VIDEO pad token for the vision encoder to have content.","triggerScenarios":"Passing a video_block_token_counts entry of 0 or a negative number (e.g. [0, 196]) to minimax_h3_ref2va_video_presentation for a video reference.","commonSituations":"Patch-count arithmetic that floors to zero for very short/thin video frames; default-initialized arrays containing 0; unit conversions producing 0 tokens for tiny segments.","solutions":["Filter out or clamp zero-count blocks before calling the API","Fix the token-count computation so each retained segment yields >= 1 vision token","Drop the corresponding timestamp as well so lengths stay aligned"],"exampleFix":"// before\ncounts = [0, 196]\n// after\ncounts = [max(1, c) for c in counts]","handlingStrategy":"validation","validationCode":"counts = [c for c in counts if c > 0]\n# then re-pair timestamps accordingly","typeGuard":"def positive_blocks(counts: list[int], ts: list[float]) -> bool:\n    return all(c >= 1 for c in counts)","tryCatchPattern":null,"preventionTips":["Filter zero-token blocks at chunking time","Clamp token budgets to a minimum of 1"],"tags":["minimax-h3","video-presentation","validation"],"backgroundTag":"invalid-value-validation","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}