sgl-project/sglang · error · ValueError

{context}video block token counts and timestamps must align

Error message

{context}video block token counts and timestamps must align

What it means

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.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/presentation.py:98

            raise ValueError("video mask was not tracked for this presentation")
        return (*result, torch.tensor(self.video_mask, dtype=torch.bool))


def _timestamped_video_blocks(
    presentation: _Presentation,
    tokenizer: Any,
    *,
    counts: Sequence[int],
    timestamps: Sequence[float],
    context: str,
    video_token_id: int | None,
) -> None:
    """Emit per-temporal-block ``<{t:.1f} seconds>`` text + VIDEO vision."""

    counts = [int(value) for value in counts]
    timestamps = [float(value) for value in timestamps]
    if not counts or len(counts) != len(timestamps):
        raise ValueError(f"{context}video block token counts and timestamps must align")
    for count, timestamp in zip(counts, timestamps):
        if count <= 0:
            raise ValueError(f"{context}video block token count must be positive")
        presentation.text(_text_ids(tokenizer, f"<{timestamp:.1f} seconds>"))
        presentation.vision(
            _vision_block_ids(tokenizer, VIDEO_PAD, count),
            video_token_id=video_token_id,
        )


def minimax_h3_text_only_ids(tokenizer: Any, prompt: str) -> torch.Tensor:
    """t2va presentation: verbatim prompt, no special tokens."""
    if not prompt:
        raise ValueError("prompt must be non-empty")
    return torch.tensor(_text_ids(tokenizer, prompt), dtype=torch.long)


def minimax_h3_multi_image_presentation(

View on GitHub (pinned to 0132848349)

Solutions

  1. Ensure every video reference supplies exactly one timestamp per video block
  2. Verify the upstream chunker emits paired (count, timestamp) tuples per block
  3. If the video genuinely has no blocks, drop the video reference from condition_labels instead of passing empty lists
  4. Add an assertion in your data prep code: len(counts) == len(timestamps) > 0

Example fix

// before
video_block_token_counts=[[196,196]],
video_block_timestamps=[[3.5]],
// after
video_block_token_counts=[[196,196]],
video_block_timestamps=[[3.5,7.0]],
Defensive patterns

Strategy: validation

Validate before calling

assert len(counts) == len(timestamps) and len(counts) > 0, "counts and timestamps must be paired and non-empty"

Type guard

def valid_video_blocks(c: list[int], t: list[float]) -> bool:
    return len(c) > 0 and len(c) == len(t) and all(x > 0 for x in c)

Try / catch

try:
    minimax_h3_ref2va_video_presentation(...)
except ValueError as e:
    if "must align" in str(e):
        logger.error("video block counts/timestamps mismatch: %s", e)

Prevention

When it happens

Trigger: 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].

Common situations: 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.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/c2efd61fbe4192af. Report an issue: GitHub.