{"record":{"id":"90ac532baa7a893f","repo":"sgl-project/sglang","slug":"kimi-active-routed-moe-layers-must-be-exactly-1-9","errorCode":null,"errorMessage":"Kimi active routed MoE layers must be exactly 1..92","messagePattern":"Kimi active routed MoE layers must be exactly 1\\.\\.92","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"python/sglang/srt/layers/moe/expert_pack.py","lineNumber":758,"sourceCode":"        }:\n            raise ValueError(\n                \"Kimi manifest hard constraints do not match runtime policy\"\n            )\n        model = self.manifest[\"model\"]\n        dimensions = (\n            int(model[\"num_hidden_layers\"]),\n            int(model[\"num_experts\"]),\n            int(model[\"num_experts_per_token\"]),\n        )\n        expected_dimensions = (expected_layers, expected_experts, expected_top_k)\n        if dimensions != expected_dimensions or expected_top_k != 16:\n            raise ValueError(\n                f\"Kimi expert-pack dimensions {dimensions} != {expected_dimensions}; \"\n                \"Top-K is immutable at 16\"\n            )\n        active_layers = tuple(int(value) for value in model[\"active_moe_layer_ids\"])\n        if active_layers != tuple(range(1, 93)):\n            raise ValueError(\"Kimi active routed MoE layers must be exactly 1..92\")\n\n        pack_manifest = self.manifest[\"expert_pack\"]\n        if Path(pack_manifest[\"path\"]).resolve() != self.path:\n            raise ValueError(\"Kimi manifest expert-pack path does not match pack_path\")\n        if int(pack_manifest[\"size\"]) != self.path.stat().st_size:\n            raise ValueError(\"Kimi expert-pack size does not match its manifest\")\n        if pack_manifest.get(\"physical_role_order\") != list(KIMI_PHYSICAL_ROLES):\n            raise ValueError(\"Kimi expert-pack physical role order is unsupported\")\n        roles = pack_manifest[\"roles\"]\n        expected_roles = {\n            \"up\": (\"Q2_K\", 10),\n            \"gate\": (\"Q2_K\", 10),\n            \"down\": (\"Q3_K\", 11),\n        }\n        for role, (dtype, dtype_id) in expected_roles.items():\n            if (\n                roles[role][\"dtype\"] != dtype\n                or int(roles[role][\"dtype_id\"]) != dtype_id","sourceCodeStart":740,"sourceCodeEnd":776,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/layers/moe/expert_pack.py#L740-L776","documentation":"Raised while loading a Kimi expert-pack when the manifest's active_moe_layer_ids do not equal the range 1..92. The loader only supports the exact Kimi K2 routed-MoE layout (layers 1 through 92, layer 0 dense), so any deviation is rejected at validation time to prevent silent weight mis-mapping.","triggerScenarios":"Constructing the expert-pack loader with a manifest whose model.active_moe_layer_ids is not exactly [1..92] — e.g. a trimmed/quantized pack with fewer layers, reordered ids, or a manifest generated for a different model variant.","commonSituations":"Using a custom or community-quantized Kimi pack with pruned layers; mixing manifests from different Kimi checkpoints; hand-editing the manifest JSON.","solutions":["Regenerate or obtain a manifest from the official Kimi K2 checkpoint whose active_moe_layer_ids is exactly list(range(1, 93))","Verify you are pointing pack_path at a Kimi K2 pack, not another MoE model's pack","If you intentionally need a different layer layout, patch the loader's expected range — but note weights will not map correctly without deeper changes"],"exampleFix":"// before\n\"active_moe_layer_ids\": [1, 2, 3]\n// after\n\"active_moe_layer_ids\": list(range(1, 93))","handlingStrategy":"validation","validationCode":"ids = manifest['model']['active_moe_layer_ids']\nif list(ids) != list(range(1, 93)):\n    raise RuntimeError('manifest is not a Kimi K2 pack: active layers != 1..92')","typeGuard":"def is_kimi_k2_manifest(m: dict) -> bool:\n    return list(m['model']['active_moe_layer_ids']) == list(range(1, 93))","tryCatchPattern":null,"preventionTips":["Only use manifests generated by the official Kimi packing tool","Validate manifest fields before constructing the loader","Keep manifest and pack files produced in the same run together"],"tags":["kimi","moe","expert-pack","manifest-validation"],"backgroundTag":"manifest-schema-validation-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}