{"record":{"id":"ff540b7f3e3866fd","repo":"sgl-project/sglang","slug":"key-position-ids-is-required","errorCode":null,"errorMessage":"{key}.position_ids is required","messagePattern":"(.+?)\\.position_ids is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/dits/minimax_h3.py","lineNumber":2111,"sourceCode":"            assert self.time_embedder is not None\n            return self.time_embedder(timesteps)\n\n        grid = self.adaln_t_table.shape[0]\n        position = timesteps.to(_FP32_DTYPE).clamp(0, 1) * (grid - 1)\n        lower = position.floor().clamp(max=grid - 2).to(torch.long)\n        fraction = (position - lower).unsqueeze(-1)\n        lower_value = self.adaln_t_table.index_select(0, lower)\n        upper_value = self.adaln_t_table.index_select(0, lower + 1)\n        return torch.lerp(lower_value, upper_value, fraction)\n\n    @staticmethod\n    def _pos_ids(pos_info: Any, key: str) -> torch.Tensor:\n        if isinstance(pos_info, dict):\n            ids = pos_info.get(\"position_ids\")\n        else:\n            ids = getattr(pos_info, \"position_ids\", None)\n        if ids is None:\n            raise ValueError(f\"{key}.position_ids is required\")\n        return ids.view(-1).to(torch.long)\n\n    @staticmethod\n    def _psp_field(psp: Any, key: str, field: str) -> Any:\n        if isinstance(psp, dict):\n            value = psp.get(field)\n        else:\n            value = getattr(psp, field, None)\n        if value is None:\n            raise ValueError(f\"{key}.{field} is required\")\n        return value\n\n    @staticmethod\n    def _psp_optional_field(psp: Any, field: str) -> Any:\n        if isinstance(psp, dict):\n            return psp.get(field)\n        return getattr(psp, field, None)\n","sourceCodeStart":2093,"sourceCodeEnd":2129,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/dits/minimax_h3.py#L2093-L2129","documentation":"forward() extracts per-modality position ids via _pos_ids, which accepts either a dict with key 'position_ids' or an object with a .position_ids attribute, and requires it to be present. If the given pos_info for a modality (video/audio/text) has no position_ids, the error names the missing '{key}.position_ids'.","triggerScenarios":"Calling forward with position-encoding info like {\"video\": {\"grid\": ...}} (no position_ids key) or a dataclass/namespace lacking the position_ids attribute.","commonSituations":"Building multimodal inputs by hand and forgetting the position_ids tensor; migrating from an older input schema where positions were derived internally; passing None fields for an optional modality that the model actually expects.","solutions":["Add a [1, S, 3]-shaped (or model-specified) integer position_ids tensor under the reported key in the dict / attribute on the object","Reuse the position-id builder from the data pipeline instead of hand-crafting inputs","If the modality is truly absent, omit the whole modality entry rather than passing an empty one"],"exampleFix":"# before\npos = {\"video\": {\"grid\": grid}}\n# after\npos = {\"video\": {\"position_ids\": compute_video_pos_ids(grid)}}","handlingStrategy":"type-guard","validationCode":"def has_pos_ids(pos_info) -> bool:\n    ids = pos_info.get(\"position_ids\") if isinstance(pos_info, dict) else getattr(pos_info, \"position_ids\", None)\n    return ids is not None\nassert all(has_pos_ids(v) for v in pos_inputs.values())","typeGuard":"def has_pos_ids(pos_info: Any) -> bool:\n    if isinstance(pos_info, dict):\n        return pos_info.get(\"position_ids\") is not None\n    return getattr(pos_info, \"position_ids\", None) is not None","tryCatchPattern":null,"preventionTips":["Always build position ids via the official data pipeline","Pre-flight required-field checks on hand-built inputs"],"tags":["input-validation","position-ids","multimodal","forward"],"backgroundTag":"missing-required-input-field","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}