{"record":{"id":"c2efd61fbe4192af","repo":"sgl-project/sglang","slug":"context-video-block-token-counts-and-timestamps-m","errorCode":null,"errorMessage":"{context}video block token counts and timestamps must align","messagePattern":"(.+?)video block token counts and timestamps must align","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":98,"sourceCode":"            raise ValueError(\"video mask was not tracked for this presentation\")\n        return (*result, torch.tensor(self.video_mask, dtype=torch.bool))\n\n\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(","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/presentation.py#L80-L116","documentation":"Raised by _timestamped_video_blocks in minimax_h3 presentation when the per-temporal-block video token counts list is empty or its length differs from the timestamps list length. The ref2va video presentation needs one timestamp per video block so it can emit a `<{t:.1f} seconds>` header before each VIDEO_PAD vision block.","triggerScenarios":"Calling minimax_h3_ref2va_video_presentation with video_block_token_counts and video_block_timestamps (flat or nested per video reference) that are empty for a video reference, or have mismatched lengths, e.g. counts=[64,64] with timestamps=[3.5].","commonSituations":"Building video conditioning data where block counts come from patch arithmetic but timestamps come from a separate chunker; empty video (no blocks) passed for a declared video reference; flat vs nested shape confusion producing length mismatch.","solutions":["Ensure every video reference supplies exactly one timestamp per video block","Verify the upstream chunker emits paired (count, timestamp) tuples per block","If the video genuinely has no blocks, drop the video reference from condition_labels instead of passing empty lists","Add an assertion in your data prep code: len(counts) == len(timestamps) > 0"],"exampleFix":"// before\nvideo_block_token_counts=[[196,196]],\nvideo_block_timestamps=[[3.5]],\n// after\nvideo_block_token_counts=[[196,196]],\nvideo_block_timestamps=[[3.5,7.0]],","handlingStrategy":"validation","validationCode":"assert len(counts) == len(timestamps) and len(counts) > 0, \"counts and timestamps must be paired and non-empty\"","typeGuard":"def valid_video_blocks(c: list[int], t: list[float]) -> bool:\n    return len(c) > 0 and len(c) == len(t) and all(x > 0 for x in c)","tryCatchPattern":"try:\n    minimax_h3_ref2va_video_presentation(...)\nexcept ValueError as e:\n    if \"must align\" in str(e):\n        logger.error(\"video block counts/timestamps mismatch: %s\", e)","preventionTips":["Generate counts and timestamps in the same loop over video blocks","Add unit tests asserting paired lengths for every video reference"],"tags":["minimax-h3","ref2va","video-presentation","validation"],"backgroundTag":"length-mismatch-validation","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}