sgl-project/sglang · error · ValueError
video block token counts and timestamps must align
Error message
video block token counts and timestamps must align
What it means
After normalization, the number of video references implied by video_block_token_counts must equal the number implied by video_block_timestamps; each video reference needs both counts and timestamps.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/presentation.py:259
content tokens; vision delimiters remain dense.
"""
if not prompt:
raise ValueError("prompt must be non-empty")
presentation = _Presentation(track_video_mask=return_video_mask)
video_token_id = (
tokenizer.convert_tokens_to_ids(VIDEO_PAD) if return_video_mask else None
)
image_token_counts = _as_int_list(image_token_count, name="image_token_count")
video_counts_by_ref = _as_nested_int_list(
video_block_token_counts,
name="video_block_token_counts",
)
video_timestamps_by_ref = _as_nested_float_list(
video_block_timestamps,
name="video_block_timestamps",
)
if len(video_counts_by_ref) != len(video_timestamps_by_ref):
raise ValueError("video block token counts and timestamps must align")
image_seen = 0
video_seen = 0
for cond_type, ordinal in condition_labels:
if cond_type == "image":
image_seen += 1
if image_seen > len(image_token_counts):
raise ValueError("image_token_count required for an image reference")
count = int(image_token_counts[image_seen - 1])
if count <= 0:
raise ValueError("image_token_count required for an image reference")
presentation.text(_text_ids(tokenizer, f"<Picture {ordinal}>: "))
presentation.vision(_vision_block_ids(tokenizer, IMAGE_PAD, count))
elif cond_type == "audio":
presentation.text(_text_ids(tokenizer, f"<Audio {ordinal}>: "))
elif cond_type == "video":
video_seen += 1
if video_seen > len(video_counts_by_ref):
raise ValueError(View on GitHub (pinned to 0132848349)
Solutions
- Make both arguments use identical nesting and the same number of per-reference groups
- Generate counts and timestamps together as paired per-video records
- Add a pre-call check len(normalized_counts) == len(normalized_timestamps)
Example fix
// before video_block_token_counts=[196,196], video_block_timestamps=[[3.5],[7.0]], // after video_block_token_counts=[[196,196]], video_block_timestamps=[[3.5,7.0]],
Defensive patterns
Strategy: validation
Validate before calling
if len(video_block_token_counts) != len(video_block_timestamps):
raise ValueError("one counts group and one timestamps group per video") Prevention
- Use identical nesting for both arguments
- Generate them as paired per-video records
When it happens
Trigger: Passing counts for 2 videos but timestamps for 1, e.g. counts=[[196],[196]] with timestamps=[[3.5]]. This typically results from inconsistent flat/nested nesting between the two arguments.
Common situations: Building the two lists in different code paths; one argument flat for a single video while the other is nested (flat counts=[[196]] equivalent vs nested timestamps with extra/missing group).
Related errors
- image_token_count required for an image reference
- video reference requires block token counts and timestamps
- unused image_token_count entries
- unused video block token count entries
- seq_len {seq_len} < used rows {used}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/e05fa5e75cc16ea5.
Report an issue: GitHub.