sgl-project/sglang · critical · ValueError
hidden_size must be positive.
Error message
hidden_size must be positive.
What it means
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.
Source
Thrown at python/sglang/multimodal_gen/runtime/models/dits/minimax_h3.py:1809
return (
self.adaln_cache is None
and get_tp_world_size() > 1
and not torch.compiler.is_compiling()
and not envs.SGLANG_CACHE_DIT_ENABLED
and not hasattr(self, "_sglang_cache_dit_adapter")
and not is_layerwise_offloaded_module(self)
and all(type(block) is MiniMaxH3DiTBlock for block in self.blocks)
)
def _validate_tp_config(
self, *, arch: MiniMaxH3DiTArchConfig, tp_size: int
) -> None:
if tp_size <= 0:
raise ValueError("TP size must be positive.")
if arch.num_attention_heads <= 0:
raise ValueError("num_attention_heads must be positive.")
if arch.hidden_size <= 0:
raise ValueError("hidden_size must be positive.")
if arch.attention_head_dim <= 0:
raise ValueError("attention_head_dim must be positive.")
if arch.ffn_hidden_size <= 0:
raise ValueError("ffn_hidden_size must be positive.")
for name, value in (
("num_attention_heads", arch.num_attention_heads),
("hidden_size", arch.hidden_size),
("ffn_hidden_size", arch.ffn_hidden_size),
("time_embed_hidden_size", arch.time_embed_hidden_size),
("adaln_out_features", arch.adaln_out_features),
("final_adaln_out_features", arch.final_adaln_out_features),
("video_patch_output_dim", arch.latents_dim * math.prod(arch.patch_size)),
("audio_patch_output_dim", arch.audio_latents_dim),
):
if value % tp_size:
raise ValueError(
f"MiniMax H3 {name}={value} must be divisible by "
f"TP size {tp_size}."View on GitHub (pinned to 0132848349)
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
Example fix
# before arch.hidden_size = 0 # after arch.hidden_size = cfg_json["hidden_size"] # e.g. 3072
Defensive patterns
Strategy: validation
Validate before calling
assert arch.hidden_size > 0
Type guard
def hidden_ok(arch) -> bool:
return getattr(arch, "hidden_size", 0) > 0 Prevention
- Round-trip test the config JSON after renames
- Fail fast on defaulted-zero size fields
When it happens
Trigger: Passing a MiniMaxH3DiTArchConfig (or deserialized JSON config) where hidden_size is 0, negative, or omitted and defaulted to 0.
Common situations: 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.
Related errors
- num_attention_heads must be positive.
- attention_head_dim must be positive.
- ffn_hidden_size must be positive.
- TP size must be positive.
- Invalid threshold_type for topk: {threshold_type}. Choose 'q
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/fa2714a838d31149.
Report an issue: GitHub.