sgl-project/sglang · error · ValueError
{context}video block token count must be positive
Error message
{context}video block token count must be positive What it means
Raised when a video temporal block's token count is <= 0 while emitting the timestamped VIDEO_PAD vision blocks. Each block must contain at least one VIDEO pad token for the vision encoder to have content.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/presentation.py:101
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(
tokenizer: Any,
*,
prompt: str,View on GitHub (pinned to 0132848349)
Solutions
- Filter out or clamp zero-count blocks before calling the API
- Fix the token-count computation so each retained segment yields >= 1 vision token
- Drop the corresponding timestamp as well so lengths stay aligned
Example fix
// before counts = [0, 196] // after counts = [max(1, c) for c in counts]
Defensive patterns
Strategy: validation
Validate before calling
counts = [c for c in counts if c > 0] # then re-pair timestamps accordingly
Type guard
def positive_blocks(counts: list[int], ts: list[float]) -> bool:
return all(c >= 1 for c in counts) Prevention
- Filter zero-token blocks at chunking time
- Clamp token budgets to a minimum of 1
When it happens
Trigger: Passing a video_block_token_counts entry of 0 or a negative number (e.g. [0, 196]) to minimax_h3_ref2va_video_presentation for a video reference.
Common situations: Patch-count arithmetic that floors to zero for very short/thin video frames; default-initialized arrays containing 0; unit conversions producing 0 tokens for tiny segments.
Related errors
- {context}video block token counts and timestamps must align
- MiniMax-H3 adaln_t_table must have shape [N, D] with N >= 2,
- MiniMax H3 AdaLN cache has invalid timestep plans
- TP size must be positive.
- num_attention_heads must be positive.
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/d12682ecc6a355db.
Report an issue: GitHub.