{"record":{"id":"bdf31bcc008d4691","repo":"sgl-project/sglang","slug":"kimi-expert-pack-header-is-truncated","errorCode":null,"errorMessage":"Kimi expert-pack header is truncated","messagePattern":"Kimi expert-pack header is truncated","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"python/sglang/srt/layers/moe/expert_pack.py","lineNumber":800,"sourceCode":"        self.entries: dict[tuple[int, int, int], ExpertPackEntry] = {}\n        self.object_offsets: dict[tuple[int, int], int] = {}\n        object_payload_bytes = int(pack_manifest[\"object_bytes\"])\n        previous_end = int(pack_manifest[\"data_start\"])\n        role_offsets: dict[str, int] = {}\n        role_nbytes = {\n            role: int(roles[role][\"expert_bytes\"]) for role in KIMI_PHYSICAL_ROLES\n        }\n        running_role_offset = 0\n        for role in KIMI_PHYSICAL_ROLES:\n            role_offsets[role] = running_role_offset\n            running_role_offset += role_nbytes[role]\n        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)","sourceCodeStart":782,"sourceCodeEnd":818,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/layers/moe/expert_pack.py#L782-L818","documentation":"The first GGML_PACK_HEADER.size bytes read from the pack file are shorter than the fixed header struct, i.e. the file is smaller than a valid header. The pack is unusable — almost certainly truncated or empty.","triggerScenarios":"Opening a 0-byte or few-byte file (failed download, interrupted write, wrong path pointing at a stub file).","commonSituations":"See trigger scenarios.","solutions":["Verify the file path points at the real pack","Re-download/recreate the pack and check size against the manifest before loading"],"exampleFix":"// before\npack = KimiExpertPack(Path('/data/model.pack.tmp'))\n// after\nassert p.stat().st_size == manifest['expert_pack']['size']\npack = KimiExpertPack(p)","handlingStrategy":"validation","validationCode":"import struct\nHEADER_SIZE = struct.calcsize('<5Q')  # match GGML_PACK_HEADER.size\nif pack_path.stat().st_size < HEADER_SIZE:\n    raise RuntimeError('pack file too small to contain a header')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check file size > header size before opening","Confirm downloads completed (curl -f, check exit code)"],"tags":["kimi","moe","expert-pack","truncated-file"],"backgroundTag":"truncated-file-read","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}