sgl-project/sglang · error · ValueError
Step3-VL image item has num_patches > 0 but no patch_pixel_v
Error message
Step3-VL image item has num_patches > 0 but no patch_pixel_values.
What it means
When an image item declares num_patches > 0 for a given image, Step3-VL expects per-patch features (item_patch_features) to splice in; if none were provided the feature vector cannot be built and it raises ValueError.
Source
Thrown at python/sglang/srt/models/step3_vl.py:885
patch_offset = 0
for thumb_count, num_patches_list, patch_count in item_metadata:
item_thumb_features = all_thumb_features[
thumb_offset : thumb_offset + thumb_count
]
thumb_offset += thumb_count
item_patch_features = (
all_patch_features[patch_offset : patch_offset + patch_count]
if patch_count > 0
else None
)
patch_offset += patch_count
cur_patch_idx = 0
for i, num_patch in enumerate(num_patches_list):
cur_feature = []
if num_patch > 0:
if item_patch_features is None:
raise ValueError(
"Step3-VL image item has num_patches > 0 but no patch_pixel_values."
)
patch_slice = item_patch_features[
cur_patch_idx : cur_patch_idx + num_patch
]
cur_feature.append(patch_slice.view(-1, patch_slice.shape[-1]))
cur_feature.append(
item_thumb_features[i].view(-1, item_thumb_features.shape[-1])
)
cur_patch_idx += num_patch
merged_image_features.append(
torch.cat(cur_feature) if len(cur_feature) > 1 else cur_feature[0]
)
return self._flatten_embeddings(merged_image_features)
def pad_input_ids(self, input_ids: List[int], mm_inputs: MultimodalInputs):
pattern = MultiModalityDataPaddingPatternMultimodalTokens()
return pattern.pad_input_tokens(input_ids, mm_inputs)View on GitHub (pinned to 0132848349)
Solutions
- Ensure preprocessing produces patch_pixel_values whenever num_patches > 0 and they are attached to the item
- If patches were intentionally removed, set num_patches entries to 0
- Align processor and model versions from the same sglang release
Example fix
# before
item.model_specific_data = {"num_patches": [2, 1]}
# after
item.model_specific_data = {"num_patches": [2, 1], "patch_pixel_values": patches} Defensive patterns
Strategy: validation
Validate before calling
for n, p in zip(num_patches_list, patches_per_item):
assert p is not None or n == 0, f"num_patches {n} but no patch features" Prevention
- Emit patch pixels and counts atomically in preprocessing
When it happens
Trigger: get_image_feature processing an item whose num_patches_list has positive entries while patch_pixel_values / patch features are absent (None) at python/sglang/srt/models/step3_vl.py:885.
Common situations: Dropping the patch branch of preprocessing (only global features kept) while num_patches still says patches exist; version mismatch where the processor emits patch counts but not patch pixels; manually constructed inputs.
Related errors
- Step3-VL image item is missing num_patches.
- Step3-VL image item has num_patches > 0 but no patch_pixel_v
- Expected CHW image tensor, got shape {shape}
- Expected CHW image tensor with 1 or 3 channels, got shape {s
- Unsupported image type: {type}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/a526cdf471bdb991.
Report an issue: GitHub.