{"record":{"id":"56cd89cf3083aa60","repo":"sgl-project/sglang","slug":"cannot-restore-flashinfer-trt-llm-bf16-moe-weight","errorCode":null,"errorMessage":"Cannot restore flashinfer TRT-LLM BF16 MoE weight shape for {weight_name}: current shape={tuple(param.data.shape)}, expected shape={expected_shape}.","messagePattern":"Cannot restore flashinfer TRT-LLM BF16 MoE weight shape for (.+?): current shape=(.+?), expected shape=(.+?)\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/layers/quantization/unquant.py","lineNumber":695,"sourceCode":"            w13_rows = (\n                2 * layer.intermediate_size_per_partition\n                if layer.moe_runner_config.is_gated\n                else layer.intermediate_size_per_partition\n            )\n            expected_shape = (layer.num_local_experts, w13_rows, layer.hidden_size)\n        elif weight_name.endswith(\".experts.w2_weight\"):\n            expected_shape = (\n                layer.num_local_experts,\n                layer.hidden_size,\n                layer.intermediate_size_per_partition,\n            )\n\n        if expected_shape is None or tuple(param.data.shape) == expected_shape:\n            return\n\n        expected_numel = expected_shape[0] * expected_shape[1] * expected_shape[2]\n        if param.data.numel() != expected_numel:\n            raise RuntimeError(\n                f\"Cannot restore flashinfer TRT-LLM BF16 MoE weight shape for {weight_name}: \"\n                f\"current shape={tuple(param.data.shape)}, expected shape={expected_shape}.\"\n            )\n\n        param.data = param.data.reshape(expected_shape)\n\n    def _aiter_ck_moe_supported(self, layer) -> bool:\n        # aiter CK fused-MoE requires intermediate_size_per_partition to be 128-aligned\n        # (GemmSpec=Default; otherwise CK raises \"not support this GEMM problem\").\n        return layer.intermediate_size_per_partition % 128 == 0\n\n    def create_moe_runner(\n        self, layer: torch.nn.Module, moe_runner_config: MoeRunnerConfig\n    ):\n        self.moe_runner_config = moe_runner_config\n        if self.use_flashinfer_trtllm_moe:\n            backend = (\n                MoeRunnerBackend.FLASHINFER_TRTLLM_ROUTED","sourceCodeStart":677,"sourceCodeEnd":713,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/layers/quantization/unquant.py#L677-L713","documentation":"Error \"Cannot restore flashinfer TRT-LLM BF16 MoE weight shape for {weight_name}: current shape={tuple(param.data.shape)}, expected shape={expected_shape}.\" thrown in sgl-project/sglang.","triggerScenarios":"Thrown at python/sglang/srt/layers/quantization/unquant.py:695 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}