sgl-project/sglang · critical · ValueError
ffn_hidden_size must be positive.
Error message
ffn_hidden_size must be positive.
What it means
The FFN hidden dimension must be positive because it is TP-sharded (each rank holds ffn_hidden_size/tp_size columns/rows). The constructor rejects non-positive values before allocating MLP weights.
Source
Thrown at python/sglang/multimodal_gen/runtime/models/dits/minimax_h3.py:1813
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}."
)
@staticmethod
def _validate_sequence_parallel_config(View on GitHub (pinned to 0132848349)
Solutions
- Set ffn_hidden_size to the checkpoint's MLP width (commonly a multiple like 4x hidden_size)
- Check the config deserialization: confirm the JSON key matches the dataclass field
- Add a pre-flight assert on all positive-size fields before construction
Example fix
# before arch = MiniMaxH3DiTArchConfig(..., ffn_hidden_size=0) # after arch = MiniMaxH3DiTArchConfig(..., ffn_hidden_size=4 * hidden_size)
Defensive patterns
Strategy: validation
Validate before calling
assert arch.ffn_hidden_size > 0
Type guard
def ffn_ok(arch) -> bool:
return getattr(arch, "ffn_hidden_size", 0) > 0 Prevention
- Keep a required-fields checklist for arch configs
- Unit-test config parsing with the real checkpoint JSON
When it happens
Trigger: Building the model with an arch config where ffn_hidden_size is 0, negative, or missing (defaulted to 0), e.g. from a partially converted checkpoint.
Common situations: Config field renamed between versions (intermediate_size vs ffn_hidden_size); hand-written configs omitting the MLP width; YAML/JSON with a null value coerced to 0.
Related errors
- num_attention_heads must be positive.
- hidden_size must be positive.
- attention_head_dim 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/3e42fdb0f996649e.
Report an issue: GitHub.