sgl-project/sglang · critical · ValueError

H3 conditioning projection {bias_name} has shape {tuple(bias

Error message

H3 conditioning projection {bias_name} has shape {tuple(bias.shape)}, expected ({int(weight.shape[0])},)

What it means

Raised while building the MiniMax H3 conditioning projection MLP: the bias tensor paired with a projection weight does not have shape (weight.shape[0],). The constructor walks the checkpoint tensors in order, so a bias whose length doesn't match its weight's output width indicates a corrupted or mismatched projection checkpoint.

Source

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

                int(name.split(".")[1])
                for name in tensors
                if re.fullmatch(r"mlp\.\d+\.weight", name)
            }
        )
        layers: list[nn.Module] = []
        layer_input_dim = self.input_dim
        for layer_index in layer_indices:
            weight_name = f"mlp.{layer_index}.weight"
            bias_name = f"mlp.{layer_index}.bias"
            weight = tensors.pop(weight_name)
            bias = tensors.pop(bias_name, None)
            if weight.ndim != 2 or int(weight.shape[1]) != layer_input_dim:
                raise ValueError(
                    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) != (

View on GitHub (pinned to 0132848349)

Solutions

  1. Verify the bias tensor length equals weight.shape[0] for each layer: load the safetensors file and print shapes
  2. Re-export or re-download the conditioning projection checkpoint from the matching MiniMax H3 Qwen3-VL release
  3. Confirm you're passing the correct --component-paths.conditioning_projection file for the model size in use

Example fix

# before
proj = MiniMaxH3ConditioningProjection(torch.load("proj.pt"), input_dim=2048, output_dim=4096)
# after
sd = torch.load("proj.pt")
for k, v in sd.items():
    print(k, tuple(v.shape))
proj = MiniMaxH3ConditioningProjection(sd, input_dim=2048, output_dim=4096)  # shapes now verified
Defensive patterns

Strategy: validation

Validate before calling

sd = torch.load(proj_path)
for k, v in sd.items():
    if "bias" in k:
        w_key = k.replace("bias", "weight")
        if w_key in sd and tuple(v.shape) != (int(sd[w_key].shape[0]),):
            raise SystemExit(f"bias {k} mismatch: {tuple(v.shape)} vs {(int(sd[w_key].shape[0]),)}")

Prevention

When it happens

Trigger: MiniMaxH3ConditioningProjection(...) is constructed (or configure_component_paths inspects/loads) with a checkpoint dict containing a bias tensor whose shape differs from the preceding weight matrix's first dimension.

Common situations: Passing a projection checkpoint exported from a different MiniMax H3 model size (e.g. 32B weights on a smaller encoder), a partially downloaded/safetensors-copied file, or mixing up which tensor is weight vs bias.

Related errors


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