sgl-project/sglang · error · ValueError

unused image_token_count entries

Error message

unused image_token_count entries

What it means

After processing all condition_labels, extra image_token_count entries remain — more counts were supplied than there are image references in the plan, indicating a mismatch between conditioning data and the plan.

Source

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

            counts = video_counts_by_ref[video_seen - 1]
            timestamps = video_timestamps_by_ref[video_seen - 1]
            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)

Solutions

  1. Trim image_token_count to the number of image references in condition_labels
  2. Update the plan to include the missing image reference
  3. Regenerate both from one source of truth

Example fix

// before
image_token_count=[196,196,196], 2 image refs in plan
// after
image_token_count=[196,196], 2 image refs in plan
Defensive patterns

Strategy: validation

Validate before calling

n_images = sum(1 for t, _ in condition_labels if t == "image")
assert len(image_token_counts_list) == n_images

Prevention

When it happens

Trigger: image_token_count=[196,196,196] but condition_labels has only 2 image entries.

Common situations: Reusing a multi-image counts list with a plan that dropped an image; stale counts after editing the plan; off-by-one when building lists.

Related errors


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