{"record":{"id":"924797e63d795dfd","repo":"sgl-project/sglang","slug":"internvl-internlm2-image-data-provided-but-no-i","errorCode":null,"errorMessage":"[internvl][internlm2] image_data provided but no images parsed from prompt placeholders","messagePattern":"\\[internvl\\]\\[internlm2\\] image_data provided but no images parsed from prompt placeholders","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/multimodal/processors/internvl.py","lineNumber":677,"sourceCode":"        for image in base_output.images:\n            if isinstance(image, Image.Image):\n                img_np = np.array(image.convert(\"RGB\"))\n                tensor = (\n                    torch.from_numpy(img_np).permute(2, 0, 1).to(get_device()).float()\n                    / 255.0\n                )\n            else:\n                tensor = image.to(get_device())\n\n            tensor = (tensor - mean) / std\n            tiles = self.dynamic_preprocess(\n                tensor, image_size=448, max_num=12, use_thumbnail=True\n            )\n            pixel_values_list.append(tiles)\n            num_patches_list.append(int(tiles.shape[0]))\n\n        if image_data and not pixel_values_list:\n            raise ValueError(\n                \"[internvl][internlm2] image_data provided but no images parsed from prompt placeholders\"\n            )\n\n        pixel_values = (\n            torch.cat(pixel_values_list, dim=0) if pixel_values_list else None\n        )\n\n        # Expand each <IMG_CONTEXT> into <img> + <IMG_CONTEXT>*N + </img>\n        ph = \"<<<__IMG_CONTEXT_PLACEHOLDER__>>>\"\n        input_text_base = (base_output.input_text or prompt).replace(\n            self.IMG_CONTEXT, ph\n        )\n\n        input_text_updated = input_text_base\n        for num_patches in num_patches_list:\n            image_tokens = (\n                self.IMG_START\n                + (self.IMG_CONTEXT * (self.num_image_token * int(num_patches)))","sourceCodeStart":659,"sourceCodeEnd":695,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/multimodal/processors/internvl.py#L659-L695","documentation":"Raised by SGLang's InternVL multimodal processor when the request carries image_data but no InternLM2-style image placeholders were found and parsed from the prompt text, leaving pixel_values_list empty. The processor locates images by scanning the prompt for placeholder tokens, so image data alone is not enough. It aborts rather than silently dropping the images.","triggerScenarios":"Calling process_mm_data_async (directly or via the server /generate API) with a non-empty image_data list while the prompt string contains no InternLM2 image placeholder tokens, or placeholders in a format the scanner does not recognize.","commonSituations":"Chat template not inserting image placeholder tokens (template/config mismatch), sending images with a hand-built prompt that omits placeholders, or a model/config combination where the internlm2 path expects a different placeholder string than the one emitted.","solutions":["Ensure the prompt is produced by the correct chat template so image placeholder tokens are inserted for each image","Verify the number of placeholder tokens in the prompt matches len(image_data)","If building prompts manually, insert the model's image placeholder token once per image before calling process_mm_data_async","If images are optional, do not pass image_data when the prompt has no placeholders"],"exampleFix":"// before\nresp = await client.generate(prompt=\"describe this\", image_data=[img])\n\n// after\nplaceholder = \"<image>\"  # model's image placeholder token\nresp = await client.generate(prompt=f\"{placeholder}describe this\", image_data=[img])","handlingStrategy":"validation","validationCode":"placeholder = \"<image>\"  # model-specific token\nn_img = len(image_data or [])\nassert input_text.count(placeholder) == n_img, (\n    f\"prompt has {input_text.count(placeholder)} placeholders for {n_img} images\"\n)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always build prompts through the model's chat template rather than string concatenation","Assert placeholder count equals image count before each request","Log the final prompt when debugging multimodal requests"],"tags":["multimodal","internvl","image-placeholders","prompt-validation"],"backgroundTag":"multimodal-placeholder-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}