{"record":{"id":"5cd6fbecc2684fe6","repo":"sgl-project/sglang","slug":"tp-size-must-be-positive","errorCode":null,"errorMessage":"TP size must be positive.","messagePattern":"TP size must be positive\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"python/sglang/multimodal_gen/runtime/models/dits/minimax_h3.py","lineNumber":1805,"sourceCode":"\n        self.adaln_cache.build(step_timesteps, embed=embed)\n\n    def _can_batch_block_adaln(self) -> bool:\n        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        ):","sourceCodeStart":1787,"sourceCodeEnd":1823,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/dits/minimax_h3.py#L1787-L1823","documentation":"Raised by MiniMaxH3DiT's _validate_tp_config during __init__ when the tensor-parallel size is zero or negative. The DiT shards attention/FFN weights across TP ranks, so a non-positive TP size makes all the per-rank shape math invalid, and the constructor fails fast before any weights are allocated.","triggerScenarios":"Constructing the MiniMax H3 DiT model with tp_size=0 or a negative value, e.g. passing --tp-size 0 or a default/int parsing bug that yields 0 (unset env var coerced to int).","commonSituations":"Launching with a missing/miscomputed tp argument; scripts that derive tp_size from world_size when the distributed group hasn't been initialized yet (world_size=0); config typos like tp=-1.","solutions":["Set tp_size to a positive power-of-two divisor of num_attention_heads, e.g. 1, 2, 4, 8","Check where tp_size originates: unset env vars, int(None), or world_size read before init_process_group","Add an assertion/default in your launch script: tp_size = tp_size or 1"],"exampleFix":"// before\nmodel = MiniMaxH3DiT(config=cfg, tp_size=0)\n// after\nmodel = MiniMaxH3DiT(config=cfg, tp_size=max(1, args.tp_size))","handlingStrategy":"validation","validationCode":"tp_size = args.tp if args.tp and args.tp > 0 else 1\nassert tp_size > 0 and arch.num_attention_heads % tp_size == 0","typeGuard":"def valid_tp(tp: int) -> bool:\n    return isinstance(tp, int) and tp > 0","tryCatchPattern":null,"preventionTips":["Default unset TP flags to 1, never 0","Read world_size only after distributed init"],"tags":["config","tensor-parallel","minimax-h3","validation","init"],"backgroundTag":"invalid-parallelism-config","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}