{"record":{"id":"f65aa9850d8e796d","repo":"sgl-project/sglang","slug":"adaln-out-features-mismatch-out-features-ex","errorCode":null,"errorMessage":"adaln out_features mismatch: {out_features} != {expand_ratio}*{arch.hidden_size}*{modality_num}","messagePattern":"adaln out_features mismatch: (.+?) != (.+?)\\*(.+?)\\*(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/dits/minimax_h3.py","lineNumber":1070,"sourceCode":"    Per block, three modalities each produce six H-wide vectors:\n    [M, t_dim] -> [M, 3*6H] -> view(M*3, 6H) -> chunk(6).\n    The final layer uses one modality and produces two H-wide vectors:\n    [M, t_dim] -> [M, 2H] -> chunk(2).\n    \"\"\"\n\n    def __init__(\n        self,\n        arch: MiniMaxH3DiTArchConfig,\n        out_features: int,\n        quant_config: QuantizationConfig | None,\n        *,\n        prefix: str,\n        expand_ratio: int,\n        modality_num: int,\n    ) -> None:\n        super().__init__()\n        if out_features != expand_ratio * arch.hidden_size * modality_num:\n            raise ValueError(\n                \"adaln out_features mismatch: \"\n                f\"{out_features} != {expand_ratio}*{arch.hidden_size}*{modality_num}\"\n            )\n        self.expand_ratio = expand_ratio\n        self.modality_num = modality_num\n        self.hidden_size = arch.hidden_size\n        # Curve checkpoints store both the sampled curve and their reduced\n        # AdaLN projections in FP32. Preserve that precision island to match\n        # the published pruned implementation; these outputs intentionally do\n        # not enter the BF16-only fused modulation kernels.\n        params_dtype = _FP32_DTYPE if arch.adaln_curve_grid is not None else _BF16_DTYPE\n        self.linear = ColumnParallelLinear(\n            arch.time_embed_dim,\n            out_features,\n            bias=True,\n            gather_output=False,\n            params_dtype=params_dtype,\n            quant_config=quant_config,","sourceCodeStart":1052,"sourceCodeEnd":1088,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/dits/minimax_h3.py#L1052-L1088","documentation":"The AdaLN projection layer's out_features must equal expand_ratio * hidden_size * modality_num so per-modality modulation signals can be split evenly. A mismatch means the architecture config, expand ratio, or modality count are inconsistent with the instantiated linear layer.","triggerScenarios":"Constructing the AdaLN module with an out_features value not equal to expand_ratio * arch.hidden_size * modality_num, typically from a mis-synced arch config or wrong expand_ratio/modality_num arguments.","commonSituations":"Porting a checkpoint with a different hidden_size than the code assumes, changing modality_num (adding/removing a modality branch) without updating out_features, or a config refactor that left stale values.","solutions":["Print/inspect arch.hidden_size, expand_ratio, modality_num and out_features to find the inconsistent one","Regenerate or fix the architecture config from the checkpoint's real dimensions","Align expand_ratio and modality_num with the values used to build the projection weights"],"exampleFix":"// before\nAdaLN(arch, out_features=6144, expand_ratio=2, modality_num=3)  # hidden=1024 -> expects 6144 ok; with hidden=1280 expects 7680\n// after\nexpected = expand_ratio * arch.hidden_size * modality_num\nAdaLN(arch, out_features=expected, expand_ratio=expand_ratio, modality_num=modality_num)","handlingStrategy":"validation","validationCode":"expected = expand_ratio * arch.hidden_size * modality_num\nassert out_features == expected, (out_features, expected)","typeGuard":"def adaln_dims_consistent(out_features: int, arch, expand_ratio: int, modality_num: int) -> bool:\n    return out_features == expand_ratio * arch.hidden_size * modality_num","tryCatchPattern":null,"preventionTips":["Derive out_features instead of hardcoding it","Add config smoke tests that instantiate AdaLN for every supported variant"],"tags":["minimax-h3","adaln","shape-mismatch","config-validation"],"backgroundTag":"dimension-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}