{"record":{"id":"6271418dac7ef434","repo":"sgl-project/sglang","slug":"h3-conditioning-projection-expects-width-self-inp","errorCode":null,"errorMessage":"H3 conditioning projection expects width {self.input_dim}, got {int(hidden_states.shape[-1])}","messagePattern":"H3 conditioning projection expects width (.+?), got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"python/sglang/multimodal_gen/runtime/models/encoders/minimax_h3_qwen3vl.py","lineNumber":171,"sourceCode":"        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) != (\n            self.input_dim,\n            self.output_dim,\n        ):\n            raise ValueError(\n                \"H3 conditioning projection W has shape \"\n                f\"{tuple(self.weight.shape)}, expected \"\n                f\"({self.input_dim}, {self.output_dim})\"\n            )\n        self.layers = nn.ModuleList(layers)\n\n    def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:\n        if int(hidden_states.shape[-1]) != self.input_dim:\n            raise ValueError(\n                f\"H3 conditioning projection expects width {self.input_dim}, \"\n                f\"got {int(hidden_states.shape[-1])}\"\n            )\n        normalized = (hidden_states.float() - self.mean_in) / self.std_in\n        projected = normalized @ self.weight if self.weight is not None else None\n        if self.layers:\n            residual = normalized.to(self.layers[0].weight.dtype)\n            for index, layer in enumerate(self.layers):\n                residual = layer(residual)\n                if index + 1 < len(self.layers):\n                    residual = F.gelu(residual)\n            residual = residual.float()\n            projected = residual if projected is None else projected + residual\n        if projected is None:\n            raise RuntimeError(\"H3 conditioning projection produced no output\")\n        output = projected * self.std_out + self.mean_out\n        if self.sink_out is not None and int(output.shape[-2]) > 0:\n            output[..., 0, :] = self.sink_out","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/encoders/minimax_h3_qwen3vl.py#L153-L189","documentation":"At forward time, the conditioning projection received a hidden_states tensor whose last dimension differs from input_dim (the width it was built/validated for). This means the encoder producing hidden_states does not match the projection configuration.","triggerScenarios":"Calling projection(hidden_states) where hidden_states.shape[-1] != projection.input_dim — e.g. encoder hidden_size changed (different text model selected) but the old projection checkpoint was reused.","commonSituations":"Swapping the text encoder (Qwen3-VL variant with different hidden size) without regenerating/re-selecting the conditioning projection; configuration drift between arch_config.hidden_size and the loaded projection.","solutions":["Ensure the selected text encoder's hidden_size equals the projection's input width (see error 1688 which validates this at config time)","Re-run with the projection checkpoint matching the current encoder, or fix the encoder selection"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"assert hidden_states.shape[-1] == proj.input_dim, (\n    f\"encoder width {hidden_states.shape[-1]} != projection input {proj.input_dim}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate encoder hidden_size == projection input_dim once at setup, not per forward","Regenerate projections whenever the text encoder changes"],"tags":["minimax-h3","conditioning-projection","forward","width-mismatch"],"backgroundTag":"model-dimension-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}