{"record":{"id":"a62c239e19899870","repo":"sgl-project/sglang","slug":"kimi-expert-pack-header-does-not-match-its-manifes","errorCode":null,"errorMessage":"Kimi expert-pack header does not match its manifest","messagePattern":"Kimi expert-pack header does not match its manifest","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"python/sglang/srt/layers/moe/expert_pack.py","lineNumber":812,"sourceCode":"        if running_role_offset != object_payload_bytes:\n            raise ValueError(\"Kimi expert-pack role sizes do not match object bytes\")\n\n        with self.path.open(\"rb\", buffering=0) as stream:\n            raw_header = stream.read(GGML_PACK_HEADER.size)\n            if len(raw_header) != GGML_PACK_HEADER.size:\n                raise ValueError(\"Kimi expert-pack header is truncated\")\n            index_digest.update(raw_header)\n            magic, version, header_size, index_count, data_start = (\n                GGML_PACK_HEADER.unpack(raw_header)\n            )\n            if (\n                magic != GGML_PACK_MAGIC\n                or version != 1\n                or header_size != GGML_PACK_HEADER.size\n                or index_count != expected_entry_count\n                or data_start != int(pack_manifest[\"data_start\"])\n            ):\n                raise ValueError(\"Kimi expert-pack header does not match its manifest\")\n\n            for index in range(index_count):\n                raw_entry = stream.read(GGML_PACK_ENTRY.size)\n                if len(raw_entry) != GGML_PACK_ENTRY.size:\n                    raise ValueError(\"Kimi expert-pack index is truncated\")\n                index_digest.update(raw_entry)\n                name_raw, expert, reserved, offset, nbytes = GGML_PACK_ENTRY.unpack(\n                    raw_entry\n                )\n                object_index, physical_role_id = divmod(index, len(KIMI_PHYSICAL_ROLES))\n                layer_index, expected_expert = divmod(object_index, expected_experts)\n                layer = active_layers[layer_index]\n                physical_role = KIMI_PHYSICAL_ROLES[physical_role_id]\n                name = _fixed_string(name_raw)\n                match = KIMI_EXPERT_RE.fullmatch(name)\n                if (\n                    match is None\n                    or int(match.group(\"layer\")) != layer","sourceCodeStart":794,"sourceCodeEnd":830,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/layers/moe/expert_pack.py#L794-L830","documentation":"The binary header fields (magic, version=1, header_size, index_count == expected entry count, data_start) disagree with the manifest or the fixed format. This catches wrong file format, version skew, or manifest/header mismatch before the index is parsed.","triggerScenarios":"Opening a non-pack file (e.g. a GGUF or safetensors); a pack written by a newer/older format version; manifest's data_start inconsistent with the header.","commonSituations":"See trigger scenarios.","solutions":["Confirm the file is a Kimi expert-pack produced by the matching tool version","Regenerate both pack and manifest together from the same tool run","Check magic bytes with a hex dump (xxd file | head -1) to rule out a wrong/HTML error file"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import struct\nmagic, version, hsize, count, data_start = struct.unpack('<5Q', open(pack_path,'rb').read(40))\nassert magic == GGML_PACK_MAGIC and version == 1 and count == 92 * n_experts * 3","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Sanity check the first bytes of any downloaded pack","Keep pack format version and tool version in sync"],"tags":["kimi","moe","expert-pack","header-validation"],"backgroundTag":"invalid-file-header","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}