sgl-project/sglang · critical · ValueError
H3 conditioning projection expects width {self.input_dim}, g
Error message
H3 conditioning projection expects width {self.input_dim}, got {int(hidden_states.shape[-1])} What it means
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.
Source
Thrown at python/sglang/multimodal_gen/runtime/models/encoders/minimax_h3_qwen3vl.py:171
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}, "
f"got {int(hidden_states.shape[-1])}"
)
normalized = (hidden_states.float() - self.mean_in) / self.std_in
projected = normalized @ self.weight if self.weight is not None else None
if self.layers:
residual = normalized.to(self.layers[0].weight.dtype)
for index, layer in enumerate(self.layers):
residual = layer(residual)
if index + 1 < len(self.layers):
residual = F.gelu(residual)
residual = residual.float()
projected = residual if projected is None else projected + residual
if projected is None:
raise RuntimeError("H3 conditioning projection produced no output")
output = projected * self.std_out + self.mean_out
if self.sink_out is not None and int(output.shape[-2]) > 0:
output[..., 0, :] = self.sink_outView on GitHub (pinned to 0132848349)
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
Defensive patterns
Strategy: validation
Validate before calling
assert hidden_states.shape[-1] == proj.input_dim, (
f"encoder width {hidden_states.shape[-1]} != projection input {proj.input_dim}") Prevention
- Validate encoder hidden_size == projection input_dim once at setup, not per forward
- Regenerate projections whenever the text encoder changes
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- H3 conditioning projection MLP outputs width {layer_input_di
- H3 conditioning projection expects encoder width {input_dim}
- H3 conditioning projection must output width {MINIMAX_H3_QWE
- H3 conditioning projection {bias_name} has shape {tuple(bias
- H3 conditioning projection contains unsupported tensors: {so
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/6271418dac7ef434.
Report an issue: GitHub.