{"record":{"id":"1bad5b41da542b8d","repo":"sgl-project/sglang","slug":"minimax-h3-text-payload-must-contain-positive-hidd","errorCode":null,"errorMessage":"MiniMax H3 text payload must contain positive.hidden_states with at least two dimensions","messagePattern":"MiniMax H3 text payload must contain positive\\.hidden_states with at least two dimensions","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/stages/text_encoding.py","lineNumber":226,"sourceCode":"\n    @staticmethod\n    def _publish_native_text_conditioning(batch: Req) -> None:\n        \"\"\"Mirror H3's rich payload onto the native text-stage fields.\n\n        H3 keeps token tags and presentation metadata in ``Req.extra``, but\n        the shared TextEncodingStage contract still owns ``prompt_embeds``.\n        Publishing the same tensor there preserves native verification,\n        grouped-request deduplication, and downstream memory accounting\n        without duplicating the embedding storage.\n        \"\"\"\n        payload = batch.extra.get(MINIMAX_H3_TEXT_EMBEDDINGS_EXTRA_KEY)\n        positive = payload.get(\"positive\") if isinstance(payload, dict) else None\n        hidden_states = (\n            positive.get(\"hidden_states\") if isinstance(positive, dict) else None\n        )\n        text_len = positive.get(\"text_len\") if isinstance(positive, dict) else None\n        if not isinstance(hidden_states, torch.Tensor) or hidden_states.ndim < 2:\n            raise ValueError(\n                \"MiniMax H3 text payload must contain positive.hidden_states \"\n                \"with at least two dimensions\"\n            )\n        if not isinstance(text_len, int) or text_len != int(hidden_states.shape[0]):\n            raise ValueError(\n                \"MiniMax H3 text payload positive.text_len must match the \"\n                \"hidden-state sequence dimension\"\n            )\n        batch.prompt_embeds = [hidden_states]\n        batch.prompt_seq_lens = [[text_len]]\n\n    def _encode_from_plan(\n        self,\n        batch: Req,\n        plan,\n        *,\n        include_video_token_mask: bool = False,\n    ) -> None:","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/stages/text_encoding.py#L208-L244","documentation":"When publishing native text conditioning, the payload must include payload['positive']['hidden_states'] as a tensor with ndim >= 2. This ValueError fires when 'positive' or its hidden_states is missing or the tensor is rank-1/0 — the conditioning contract for prompt_embeds is broken.","triggerScenarios":"_publish_native_text_conditioning receives a payload dict whose 'positive' sub-dict is absent, hidden_states is None/non-tensor, or hidden_states is a flat 1-D tensor.","commonSituations":"A custom or older text encoder returning {'positive': None} or a flattened embedding vector; payloads built by hand or deserialized from a checkpoint losing structure.","solutions":["Ensure the encoder returns payload['positive']['hidden_states'] as a [seq, hidden] tensor","Reshape rank-1 embeddings to [1, hidden] or [seq, hidden] as appropriate before publishing","Use the stock MiniMaxH3Qwen3VLEncoder output format"],"exampleFix":"// before\npayload = {\"positive\": {\"hidden_states\": flat_vec}}  # rank-1\n// after\npayload = {\"positive\": {\"hidden_states\": flat_vec.unsqueeze(0)}}  # [1, hidden]","handlingStrategy":"type-guard","validationCode":"pos = payload.get(\"positive\") if isinstance(payload, dict) else None\nhs = pos.get(\"hidden_states\") if isinstance(pos, dict) else None\nassert isinstance(hs, torch.Tensor) and hs.ndim >= 2, \"bad positive.hidden_states\"","typeGuard":"def valid_positive_hidden_states(payload) -> bool:\n    pos = payload.get(\"positive\") if isinstance(payload, dict) else None\n    hs = pos.get(\"hidden_states\") if isinstance(pos, dict) else None\n    return isinstance(hs, torch.Tensor) and hs.ndim >= 2","tryCatchPattern":null,"preventionTips":["Always emit hidden_states as [seq, hidden]","Validate encoder output structure once in encoder tests"],"tags":["minimax-h3","text-encoding","tensor-shape","payload-validation"],"backgroundTag":"payload-schema-validation","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}