{"record":{"id":"a334c27b89de3adb","repo":"sgl-project/sglang","slug":"step3-vl-image-item-is-missing-num-patches","errorCode":null,"errorMessage":"Step3-VL image item is missing num_patches.","messagePattern":"Step3-VL image item is missing num_patches\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/models/step3_vl.py","lineNumber":822,"sourceCode":"        image_features = self.vit_downsampler(image_features)\n        image_features = self.vit_downsampler2(image_features)\n        n_dim = image_features.size(1)\n        image_features = image_features.view(B, n_dim, -1).permute(0, 2, 1)\n        image_features = self.vit_large_projector(image_features)\n        return image_features\n\n    def get_image_feature(self, items: List[MultimodalDataItem]) -> torch.Tensor:\n        # Phase 1: Collect thumbnails and patches separately (different resolutions).\n        all_thumbnails = []\n        all_patches = []\n        # Per-item metadata: (thumb_count, num_patches_list, patch_count)\n        item_metadata = []\n\n        for item in items:\n            pixel_values = item.feature.type(self.vision_model.dtype)\n            num_patches = item.model_specific_data.get(\"num_patches\")\n            if num_patches is None:\n                raise ValueError(\"Step3-VL image item is missing num_patches.\")\n            if isinstance(num_patches, torch.Tensor):\n                num_patches = [int(x) for x in num_patches.flatten().cpu().tolist()]\n            elif isinstance(num_patches, (list, tuple)):\n                num_patches = [\n                    int(x.item()) if isinstance(x, torch.Tensor) else int(x)\n                    for x in num_patches\n                ]\n            else:\n                num_patches = [int(num_patches)]\n\n            patch_pixel_values = item.model_specific_data.get(\n                \"patch_pixel_values\", None\n            )\n            if patch_pixel_values is not None and patch_pixel_values.shape[0] == 0:\n                patch_pixel_values = None\n            if patch_pixel_values is not None:\n                patch_pixel_values = patch_pixel_values.type(\n                    self.vision_model.dtype","sourceCodeStart":804,"sourceCodeEnd":840,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/models/step3_vl.py#L804-L840","documentation":"Step3-VL's get_image_feature requires each multimodal item's model_specific_data to contain num_patches (how many crops/patches the processor produced per image). Missing metadata means patch feature assembly is impossible, so it raises ValueError per item.","triggerScenarios":"Passing image items whose model_specific_data lacks 'num_patches' — usually because the processor/tokenizer version predates or differs from the model implementation that consumes it.","commonSituations":"Mixing sglang versions (processor updated separately from model file), custom multimodal input pipelines that construct EmbeddingItems manually, or serving step3-vl with an outdated processor config.","solutions":["Update sglang so processor and model code are from the same release","If building items manually, set item.model_specific_data['num_patches'] to the per-image patch counts from preprocessing","Regenerate the multimodal inputs with the server's own preprocessing path"],"exampleFix":"# before\nitem.model_specific_data = {}\n# after\nitem.model_specific_data = {\"num_patches\": num_patches_list}","handlingStrategy":"validation","validationCode":"for item in items:\n    assert item.model_specific_data.get(\"num_patches\") is not None, item","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep processor and model from the same sglang release"],"tags":["step3-vl","multimodal","metadata"],"backgroundTag":"missing-multimodal-metadata","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}