{"record":{"id":"981d545e8be92a30","repo":"sgl-project/sglang","slug":"kimi-expert-pack-size-does-not-match-its-manifest","errorCode":null,"errorMessage":"Kimi expert-pack size does not match its manifest","messagePattern":"Kimi expert-pack size does not match its manifest","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"python/sglang/srt/layers/moe/expert_pack.py","lineNumber":764,"sourceCode":"            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\n            ):\n                raise ValueError(f\"Kimi expert-pack {role} quant type is unsupported\")\n\n        expected_entry_count = len(active_layers) * expected_experts * len(ROLE_NAMES)\n        index_digest = hashlib.sha256()\n        self.entries: dict[tuple[int, int, int], ExpertPackEntry] = {}","sourceCodeStart":746,"sourceCodeEnd":782,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/layers/moe/expert_pack.py#L746-L782","documentation":"The expert_pack.size recorded in the manifest differs from the actual on-disk size of the pack file (path.stat().st_size). This detects truncated downloads, partially written packs, or manifest/pack version skew before any bytes are parsed.","triggerScenarios":"Interrupted download or copy of the .pack file; manifest generated against a different revision of the pack; filesystem corruption.","commonSituations":"See trigger scenarios.","solutions":["Re-download or re-copy the pack file and verify its size matches the manifest","If the pack is correct and the manifest stale, regenerate the manifest","Check disk space if the pack was produced locally"],"exampleFix":"// before\n$ ls -l model.pack   # 12345678 bytes, manifest says 123456780\n// after\n# resume/redo download until size == manifest.expert_pack.size","handlingStrategy":"validation","validationCode":"import os\nif os.path.getsize(pack_path) != int(manifest['expert_pack']['size']):\n    raise RuntimeError('pack size mismatch — likely truncated download')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify file size right after downloading/copying packs","Keep manifest next to the pack it describes"],"tags":["kimi","moe","expert-pack","file-size-mismatch"],"backgroundTag":"file-integrity-check-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}