{"record":{"id":"fa2714a838d31149","repo":"sgl-project/sglang","slug":"hidden-size-must-be-positive","errorCode":null,"errorMessage":"hidden_size must be positive.","messagePattern":"hidden_size must be positive\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"python/sglang/multimodal_gen/runtime/models/dits/minimax_h3.py","lineNumber":1809,"sourceCode":"        return (\n            self.adaln_cache is None\n            and get_tp_world_size() > 1\n            and not torch.compiler.is_compiling()\n            and not envs.SGLANG_CACHE_DIT_ENABLED\n            and not hasattr(self, \"_sglang_cache_dit_adapter\")\n            and not is_layerwise_offloaded_module(self)\n            and all(type(block) is MiniMaxH3DiTBlock for block in self.blocks)\n        )\n\n    def _validate_tp_config(\n        self, *, arch: MiniMaxH3DiTArchConfig, tp_size: int\n    ) -> None:\n        if tp_size <= 0:\n            raise ValueError(\"TP size must be positive.\")\n        if arch.num_attention_heads <= 0:\n            raise ValueError(\"num_attention_heads must be positive.\")\n        if arch.hidden_size <= 0:\n            raise ValueError(\"hidden_size must be positive.\")\n        if arch.attention_head_dim <= 0:\n            raise ValueError(\"attention_head_dim must be positive.\")\n        if arch.ffn_hidden_size <= 0:\n            raise ValueError(\"ffn_hidden_size must be positive.\")\n        for name, value in (\n            (\"num_attention_heads\", arch.num_attention_heads),\n            (\"hidden_size\", arch.hidden_size),\n            (\"ffn_hidden_size\", arch.ffn_hidden_size),\n            (\"time_embed_hidden_size\", arch.time_embed_hidden_size),\n            (\"adaln_out_features\", arch.adaln_out_features),\n            (\"final_adaln_out_features\", arch.final_adaln_out_features),\n            (\"video_patch_output_dim\", arch.latents_dim * math.prod(arch.patch_size)),\n            (\"audio_patch_output_dim\", arch.audio_latents_dim),\n        ):\n            if value % tp_size:\n                raise ValueError(\n                    f\"MiniMax H3 {name}={value} must be divisible by \"\n                    f\"TP size {tp_size}.\"","sourceCodeStart":1791,"sourceCodeEnd":1827,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/dits/minimax_h3.py#L1791-L1827","documentation":"MiniMax H3's constructor requires hidden_size > 0 since it sizes input patch projections, AdaLN layers, and TP-sharded linear weights from it. A non-positive hidden_size indicates a broken arch config and the model refuses to build.","triggerScenarios":"Passing a MiniMaxH3DiTArchConfig (or deserialized JSON config) where hidden_size is 0, negative, or omitted and defaulted to 0.","commonSituations":"Custom model configs authored from scratch; partial checkpoint conversion that forgets hidden_size; refactors that rename to dim/model_dim and leave hidden_size unset.","solutions":["Print/validate arch.hidden_size before constructing the model","Set it to the checkpoint's true embedding width (e.g. 3072)","Re-run the checkpoint converter and confirm all size fields are populated"],"exampleFix":"# before\narch.hidden_size = 0\n# after\narch.hidden_size = cfg_json[\"hidden_size\"]  # e.g. 3072","handlingStrategy":"validation","validationCode":"assert arch.hidden_size > 0","typeGuard":"def hidden_ok(arch) -> bool:\n    return getattr(arch, \"hidden_size\", 0) > 0","tryCatchPattern":null,"preventionTips":["Round-trip test the config JSON after renames","Fail fast on defaulted-zero size fields"],"tags":["config","model-architecture","validation","minimax-h3"],"backgroundTag":"invalid-model-config","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}