sgl-project/sglang · error · ValueError
Video placeholder count does not match video_data: {len(vide
Error message
Video placeholder count does not match video_data: {len(video_data)} video(s) given What it means
Raised by process_mm_data_async when, after substituting all supplied videos into their placeholders, a video placeholder token still remains in input_text. The count of video markers must equal len(video_data).
Source
Thrown at python/sglang/srt/multimodal/processors/dots_note_omni.py:454
audio_cap=audio_cap,
audio_sr=audio_sr,
k_mode=k_mode,
max_new_tokens=max_new_tokens,
),
)
total_content_items += len(content)
total_frames += sum(item.get("type") == "image_url" for item in content)
total_audio_segments += sum(
item.get("type") == "audio_url" for item in content
)
input_text, media = self._render_video_content(
input_text, question, video_index, content
)
video_media.update(media)
leftover = self.video_placeholder_regex.search(input_text)
if leftover is not None:
raise ValueError(
"Video placeholder count does not match video_data: "
f"{len(video_data)} video(s) given"
)
input_text, image_data, audio_data = self._merge_video_media(
input_text, image_data, audio_data, video_media
)
preprocess_elapsed = time.perf_counter() - preprocess_started
logger.info(
"[dots_mm] rid=%s video_preprocess elapsed=%.3fs "
"expanded_frames=%d expanded_audio_segments=%d content_items=%d "
"after_preprocess images=%d audios=%d",
request_obj.rid,
preprocess_elapsed,
total_frames,
total_audio_segments,
total_content_items,
len(image_data),
len(audio_data),View on GitHub (pinned to 0132848349)
Solutions
- Make the number of video placeholders in the prompt equal len(video_data)
- If a video is optional, remove its placeholder when absent
- Validate client-side: count video tokens in the prompt against your video list before sending
Example fix
// before prompt = "<video> <video>" # 2 placeholders video_data = [v1] # 1 video // after prompt = "<video>" # 1 placeholder video_data = [v1]
Defensive patterns
Strategy: validation
Validate before calling
import re
VIDEO_RE = re.compile(r'<your-model-video-placeholder>') # match server's video_placeholder_regex
count = len(VIDEO_RE.findall(prompt))
assert count == len(video_data or []), f'{count} placeholders vs {len(video_data or [])} videos' Try / catch
try:
await processor.process_mm_data_async(...)
except ValueError as e:
if 'Video placeholder count' in str(e):
rebuild prompt so placeholder count equals len(video_data); resubmit Prevention
- Build prompts with exactly one video token per video
- Drop the placeholder when an optional video is absent
When it happens
Trigger: The prompt/template contains more video placeholder tokens (matched by self.video_placeholder_regex) than entries in video_data — e.g. template renders 2 video tags but only 1 video was sent.
Common situations: Multi-video prompts built by hand or by a template that always emits N video slots; or a video item was dropped (None/failed download) before reaching the processor.
Related errors
- seq must be positive, got {seq}
- k_mode must not be empty
- Image placeholder count does not match image_data
- Audio placeholder count does not match audio_data
- Unsupported video input type: {type(video_file)}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/29b6188266a02561.
Report an issue: GitHub.