{"record":{"id":"923c2a7bad6caf89","repo":"sgl-project/sglang","slug":"pixel-values-and-image-grid-thw-must-be-given-toge","errorCode":null,"errorMessage":"pixel_values and image_grid_thw must be given together","messagePattern":"pixel_values and image_grid_thw must be given together","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/encoders/minimax_h3_qwen3vl.py","lineNumber":341,"sourceCode":"            use_cache=False,\n            **kwargs,\n        )\n        return BaseEncoderOutput(last_hidden_state=outputs.last_hidden_state)\n\n    @torch.no_grad()\n    def encode_ids(\n        self,\n        input_ids: torch.Tensor,\n        *,\n        pixel_values: torch.Tensor | None = None,\n        image_grid_thw: torch.Tensor | None = None,\n        pixel_values_videos: torch.Tensor | None = None,\n        video_grid_thw: torch.Tensor | None = None,\n    ) -> torch.Tensor:\n        if input_ids.dim() != 1:\n            raise ValueError(f\"input_ids must be 1-D, got {list(input_ids.shape)}\")\n        if (pixel_values is None) != (image_grid_thw is None):\n            raise ValueError(\"pixel_values and image_grid_thw must be given together\")\n        if (pixel_values_videos is None) != (video_grid_thw is None):\n            raise ValueError(\n                \"pixel_values_videos and video_grid_thw must be given together\"\n            )\n\n        host_ids = input_ids.to(device=\"cpu\", dtype=torch.long)[None]\n        host_image_grid_thw = (\n            image_grid_thw.to(device=\"cpu\", dtype=torch.long)\n            if image_grid_thw is not None\n            else None\n        )\n        host_video_grid_thw = (\n            video_grid_thw.to(device=\"cpu\", dtype=torch.long)\n            if video_grid_thw is not None\n            else None\n        )\n        position_ids = None\n        if host_image_grid_thw is not None or host_video_grid_thw is not None:","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/encoders/minimax_h3_qwen3vl.py#L323-L359","documentation":"encode_ids requires pixel_values and image_grid_thw to be supplied together (both or neither). Passing only one indicates a malformed call — grid metadata is required to interpret image patches.","triggerScenarios":"encode_ids(..., pixel_values=t, image_grid_thw=None) or the reverse — exactly one of the pair given.","commonSituations":"Adapting call sites that previously passed only pixel tensors; optional-chaining bugs (e.g. `or None` collapsing an empty tensor); refactoring that dropped the grid tensor.","solutions":["Pass image_grid_thw alongside pixel_values (take it from the processor output)","If there are no images, pass both as None"],"exampleFix":"# before\nhidden = enc.encode_ids(ids, pixel_values=pv)\n# after\nhidden = enc.encode_ids(ids, pixel_values=pv, image_grid_thw=grid_thw)","handlingStrategy":"validation","validationCode":"assert (pixel_values is None) == (image_grid_thw is None)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Thread the full processor output object through instead of picking fields","Add paired-presence asserts in test fixtures"],"tags":["minimax-h3","encode-ids","paired-args","image-input"],"backgroundTag":"missing-required-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}