sgl-project/sglang · critical · ValueError

H3 conditioning projection MLP outputs width {layer_input_di

Error message

H3 conditioning projection MLP outputs width {layer_input_dim}, expected {self.output_dim}

What it means

An MLP chain was recognized in the conditioning projection tensors, but its final layer's output width (layer_input_dim after consuming all layers) does not equal the module's declared output_dim. The projected conditioning signal would then be the wrong width for the downstream model.

Source

Thrown at python/sglang/multimodal_gen/runtime/models/encoders/minimax_h3_qwen3vl.py:154

                    f"H3 conditioning projection {weight_name} cannot follow "
                    f"width {layer_input_dim}: got {tuple(weight.shape)}"
                )
            if bias is not None and tuple(bias.shape) != (int(weight.shape[0]),):
                raise ValueError(
                    f"H3 conditioning projection {bias_name} has shape "
                    f"{tuple(bias.shape)}, expected ({int(weight.shape[0])},)"
                )
            layers.append(_FrozenLinear(weight, bias))
            layer_input_dim = int(weight.shape[0])
        if tensors:
            raise ValueError(
                "H3 conditioning projection contains unsupported tensors: "
                f"{sorted(tensors)}"
            )
        if self.weight is None and not layers:
            raise ValueError("H3 conditioning projection has neither W nor an MLP")
        if layers and layer_input_dim != self.output_dim:
            raise ValueError(
                f"H3 conditioning projection MLP outputs width {layer_input_dim}, "
                f"expected {self.output_dim}"
            )
        if self.weight is not None and tuple(self.weight.shape) != (
            self.input_dim,
            self.output_dim,
        ):
            raise ValueError(
                "H3 conditioning projection W has shape "
                f"{tuple(self.weight.shape)}, expected "
                f"({self.input_dim}, {self.output_dim})"
            )
        self.layers = nn.ModuleList(layers)

    def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
        if int(hidden_states.shape[-1]) != self.input_dim:
            raise ValueError(
                f"H3 conditioning projection expects width {self.input_dim}, "

View on GitHub (pinned to 0132848349)

Solutions

  1. Check the last MLP weight's shape[0] and compare with the expected output width (MINIMAX_H3_QWEN3VL_HIDDEN_DIM)
  2. Use the projection checkpoint matching the target model's hidden size
Defensive patterns

Strategy: validation

Validate before calling

out_w = [v for k, v in sd.items() if "weight" in k][-1]
assert int(out_w.shape[0]) == expected_output_dim

Prevention

When it happens

Trigger: Constructing MiniMaxH3ConditioningProjection where the last MLP weight's shape[0] != output_dim, e.g. passing a projection for a different model's hidden size.

Common situations: Mixing projection checkpoints across MiniMax H3 model sizes (e.g. 4096 vs 5120 hidden dims), or mis-specifying output_dim when the checkpoint defines it implicitly.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/44ee100a3e68b53c. Report an issue: GitHub.