sgl-project/sglang · error · ValueError

unused video block token count entries

Error message

unused video block token count entries

What it means

There are leftover video block token count entries not consumed by any video reference. Remove the unused entries.

Solutions

  1. Remove unused counts (and their timestamps) groups
  2. Add the missing video reference to condition_labels
  3. Derive both from the same conditioning record

Example fix

// before
video_block_token_counts=[[196],[196]], one video ref in plan
// after
video_block_token_counts=[[196]], one video ref in plan
Defensive patterns

Strategy: validation

Validate before calling

n_videos = sum(1 for t, _ in condition_labels if t == "video")
assert len(video_counts_by_ref) == n_videos

Prevention

When it happens

Trigger: video_block_token_counts=[[196],[196]] but condition_labels contains only one ("video", N) entry.

Common situations: Removing a video from the plan without removing its counts group; building counts for all segments while the plan references a subset.

Related errors


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

Appendix: source

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

            if not counts or not timestamps:
                raise ValueError(
                    "video reference requires block token counts and timestamps"
                )
            presentation.text(_text_ids(tokenizer, f"<Video {ordinal}>: "))
            _timestamped_video_blocks(
                presentation,
                tokenizer,
                counts=counts,
                timestamps=timestamps,
                context="",
                video_token_id=video_token_id,
            )
        else:
            raise ValueError(f"unsupported ref2va condition type {cond_type!r}")
    if image_seen != len(image_token_counts):
        raise ValueError("unused image_token_count entries")
    if video_seen != len(video_counts_by_ref):
        raise ValueError("unused video block token count entries")
    presentation.text(_text_ids(tokenizer, prompt))
    return presentation.build(return_video_mask=return_video_mask)


__all__ = [
    "minimax_h3_multi_image_presentation",
    "minimax_h3_ref2va_presentation",
    "minimax_h3_ref2va_video_presentation",
    "minimax_h3_text_only_ids",
]

View on GitHub (pinned to 0132848349)