{"record":{"id":"adfea3b519bd742e","repo":"sgl-project/sglang","slug":"num-nextn-predict-layers-is-not-in-the-config-adfea3","errorCode":null,"errorMessage":"num nextn_predict_layers is not in the config","messagePattern":"num nextn_predict_layers is not in the config","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"python/sglang/srt/models/bailing_moe_linear.py","lineNumber":1406,"sourceCode":"            weight_loader = getattr(\n                param, \"weight_loader\", BailingMoELinearAttention.weight_direct_load\n            )\n            weight_loader = weight_loader_with_alias(name)(weight_loader)\n            weight_loader(param, loaded_weight)\n            return\n\n        if is_nextn:\n            if hasattr(self.config, \"num_nextn_predict_layers\"):\n                num_nextn_layers = self.config.num_nextn_predict_layers\n                assert num_nextn_layers == 1, \"Only 1 nextn layer is supported\"\n                # compatible with old design\n                nextn_layer_id = (\n                    0\n                    if self.config.num_hidden_layers == 1\n                    else self.config.num_hidden_layers\n                )\n            else:\n                raise ValueError(\"num nextn_predict_layers is not in the config\")\n\n        stacked_params_mapping = [\n            # (param_name, shard_name, shard_id)\n            (\"gate_up_proj\", \"gate_proj\", 0),\n            (\"gate_up_proj\", \"up_proj\", 1),\n        ]\n        expert_params_mapping = FusedMoE.make_expert_params_mapping(\n            ckpt_gate_proj_name=\"gate_proj\",\n            ckpt_down_proj_name=\"down_proj\",\n            ckpt_up_proj_name=\"up_proj\",\n            num_experts=self.config.num_experts,\n        )\n\n        if is_nextn:\n            nextn_layer_prefix = f\"model.layers.{nextn_layer_id}\"\n            nextn_spec_weight_names = [\n                \"final_layernorm\",\n                \"eh_proj\",","sourceCodeStart":1388,"sourceCodeEnd":1424,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/models/bailing_moe_linear.py#L1388-L1424","documentation":"Same nextn-layer resolution requirement as bailing_moe, in the linear-attention variant: load_weights needs num_nextn_predict_layers in the config to derive the MTP layer index, otherwise it raises.","triggerScenarios":"Loading a bailing_moe_linear checkpoint with nextn/MTP weights while config.json lacks num_nextn_predict_layers.","commonSituations":"Hand-built speculative configs; checkpoints saved before the field was standardized.","solutions":["Add \"num_nextn_predict_layers\": 1 to config.json","Ensure explicit nextn layer index config is present","Disable MTP if unused"],"exampleFix":"// before\n{ \"num_hidden_layers\": 48 }\n// after\n{ \"num_hidden_layers\": 48, \"num_nextn_predict_layers\": 1 }","handlingStrategy":"validation","validationCode":"assert hasattr(config, \"num_nextn_predict_layers\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add num_nextn_predict_layers when using MTP checkpoints"],"tags":["mtp","speculative-decoding","bailing","weight-loading"],"backgroundTag":"missing-config-field","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}