{"record":{"id":"4755022b86d41643","repo":"sgl-project/sglang","slug":"h3-conditioning-projection-bias-name-has-shape","errorCode":null,"errorMessage":"H3 conditioning projection {bias_name} has shape {tuple(bias.shape)}, expected ({int(weight.shape[0])},)","messagePattern":"H3 conditioning projection (.+?) has shape (.+?), expected \\((.+?),\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"python/sglang/multimodal_gen/runtime/models/encoders/minimax_h3_qwen3vl.py","lineNumber":140,"sourceCode":"                int(name.split(\".\")[1])\n                for name in tensors\n                if re.fullmatch(r\"mlp\\.\\d+\\.weight\", name)\n            }\n        )\n        layers: list[nn.Module] = []\n        layer_input_dim = self.input_dim\n        for layer_index in layer_indices:\n            weight_name = f\"mlp.{layer_index}.weight\"\n            bias_name = f\"mlp.{layer_index}.bias\"\n            weight = tensors.pop(weight_name)\n            bias = tensors.pop(bias_name, None)\n            if weight.ndim != 2 or int(weight.shape[1]) != layer_input_dim:\n                raise ValueError(\n                    f\"H3 conditioning projection {weight_name} cannot follow \"\n                    f\"width {layer_input_dim}: got {tuple(weight.shape)}\"\n                )\n            if bias is not None and tuple(bias.shape) != (int(weight.shape[0]),):\n                raise ValueError(\n                    f\"H3 conditioning projection {bias_name} has shape \"\n                    f\"{tuple(bias.shape)}, expected ({int(weight.shape[0])},)\"\n                )\n            layers.append(_FrozenLinear(weight, bias))\n            layer_input_dim = int(weight.shape[0])\n        if tensors:\n            raise ValueError(\n                \"H3 conditioning projection contains unsupported tensors: \"\n                f\"{sorted(tensors)}\"\n            )\n        if self.weight is None and not layers:\n            raise ValueError(\"H3 conditioning projection has neither W nor an MLP\")\n        if layers and layer_input_dim != self.output_dim:\n            raise ValueError(\n                f\"H3 conditioning projection MLP outputs width {layer_input_dim}, \"\n                f\"expected {self.output_dim}\"\n            )\n        if self.weight is not None and tuple(self.weight.shape) != (","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/encoders/minimax_h3_qwen3vl.py#L122-L158","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the bias tensor length equals weight.shape[0] for each layer: load the safetensors file and print shapes","Re-export or re-download the conditioning projection checkpoint from the matching MiniMax H3 Qwen3-VL release","Confirm you're passing the correct --component-paths.conditioning_projection file for the model size in use"],"exampleFix":"# before\nproj = MiniMaxH3ConditioningProjection(torch.load(\"proj.pt\"), input_dim=2048, output_dim=4096)\n# after\nsd = torch.load(\"proj.pt\")\nfor k, v in sd.items():\n    print(k, tuple(v.shape))\nproj = MiniMaxH3ConditioningProjection(sd, input_dim=2048, output_dim=4096)  # shapes now verified","handlingStrategy":"validation","validationCode":"sd = torch.load(proj_path)\nfor k, v in sd.items():\n    if \"bias\" in k:\n        w_key = k.replace(\"bias\", \"weight\")\n        if w_key in sd and tuple(v.shape) != (int(sd[w_key].shape[0]),):\n            raise SystemExit(f\"bias {k} mismatch: {tuple(v.shape)} vs {(int(sd[w_key].shape[0]),)}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always validate projection checkpoint shapes before model init","Pin projection checkpoints to the same model release as the encoder"],"tags":["minimax-h3","conditioning-projection","shape-mismatch","checkpoint"],"backgroundTag":"weight-shape-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}