sgl-project/sglang · error · ValueError

Step3-VL image item is missing num_patches.

Error message

Step3-VL image item is missing num_patches.

What it means

Identical to the step3_vl check: get_image_feature for step3-vl-10b requires num_patches in each image item's model_specific_data; without it, patch-count-driven feature assembly cannot proceed.

Source

Thrown at python/sglang/srt/models/step3_vl_10b.py:494

        return torch.cat(tuple(self._flatten_embeddings(t) for t in embeddings))

    def _process_image_features(self, image_features: torch.Tensor) -> torch.Tensor:
        image_features, _ = self.vit_large_projector(image_features)
        return image_features

    def get_image_feature(self, items: List[MultimodalDataItem]) -> torch.Tensor:
        # Phase 1: Collect thumbnails and patches separately (different resolutions).
        all_thumbnails = []
        all_patches = []
        # Per-item metadata: (thumb_count, num_patches_list, patch_count)
        item_metadata = []

        for item in items:
            pixel_values = item.feature.type(self.vision_model.dtype)
            num_patches = item.model_specific_data.get("num_patches")
            if num_patches is None:
                raise ValueError("Step3-VL image item is missing num_patches.")
            if isinstance(num_patches, torch.Tensor):
                num_patches = [int(x) for x in num_patches.flatten().cpu().tolist()]
            elif isinstance(num_patches, (list, tuple)):
                num_patches = [
                    int(x.item()) if isinstance(x, torch.Tensor) else int(x)
                    for x in num_patches
                ]
            else:
                num_patches = [int(num_patches)]

            patch_pixel_values = item.model_specific_data.get(
                "patch_pixel_values", None
            )
            if patch_pixel_values is not None and patch_pixel_values.shape[0] == 0:
                patch_pixel_values = None
            if patch_pixel_values is not None:
                patch_pixel_values = patch_pixel_values.type(
                    self.vision_model.dtype

View on GitHub (pinned to 0132848349)

Solutions

  1. Update sglang so preprocessing emits num_patches
  2. Set item.model_specific_data['num_patches'] from the processor output when building items manually
  3. Re-run inputs through the server's standard multimodal preprocessing

Example fix

# before
item.model_specific_data = {}
# after
item.model_specific_data = {"num_patches": num_patches_list}
Defensive patterns

Strategy: validation

Validate before calling

for item in items:
    assert item.model_specific_data.get("num_patches") is not None

Prevention

When it happens

Trigger: Serving step3-vl-10b with image items lacking model_specific_data['num_patches'] (processor/model version mismatch or manual item construction).

Common situations: Mixed-version sglang installs, custom input pipelines, or older preprocessing configs for the 10B variant.

Related errors


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