{"record":{"id":"dec76522f37d461f","repo":"sgl-project/sglang","slug":"expert-pack-index-is-truncated","errorCode":null,"errorMessage":"expert-pack index is truncated","messagePattern":"expert-pack index is truncated","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"python/sglang/srt/layers/moe/expert_pack.py","lineNumber":126,"sourceCode":"    dtype_id: int\n    dtype: str\n    tensor_name: str\n    source_slice_offset: int\n    source_slice_nbytes: int\n    pack_offset: int\n    pack_nbytes: int\n    checksum: str\n    shape: tuple[int, ...]\n    quant_scheme: str\n    transform_id: str\n    block_size: int\n    generation: int\n\n    @classmethod\n    def read(cls, stream) -> ExpertPackEntry:\n        raw = stream.read(ENTRY_STRUCT.size)\n        if len(raw) != ENTRY_STRUCT.size:\n            raise ValueError(\"expert-pack index is truncated\")\n        values = ENTRY_STRUCT.unpack(raw)\n        role_id, rank = values[2], values[3]\n        if role_id >= len(ROLE_NAMES) or not 1 <= rank <= 4:\n            raise ValueError(\"expert-pack index role or rank is invalid\")\n        return cls(\n            layer=values[0],\n            expert=values[1],\n            role_id=role_id,\n            dtype_id=values[4],\n            dtype=_fixed_string(values[5]),\n            tensor_name=_fixed_string(values[6]),\n            source_slice_offset=values[9],\n            source_slice_nbytes=values[10],\n            pack_offset=values[11],\n            pack_nbytes=values[12],\n            checksum=values[15].hex(),\n            shape=tuple(values[16 : 16 + rank]),\n            quant_scheme=_fixed_string(values[20]),","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/layers/moe/expert_pack.py#L108-L144","documentation":"While reading an index entry, fewer than ENTRY_STRUCT.size bytes were available — the entry index region is truncated relative to index_count declared in the header. This means the file is shorter than the header claims (corruption or incomplete write/transfer).","triggerScenarios":"ExpertPackEntry.read returning a short read because the file ends before index_count entries were consumed — e.g. an interrupted pack write, a truncated download, or a header with an inflated index_count.","commonSituations":"Killed packing job that wrote the header but not all entries; partial file transfer; disk-full during export; concatenated/appended files with wrong length.","solutions":["Verify and re-download/regenerate the pack (compare file size and sha256 with the manifest)","If packing yourself, ensure entries and data are fully flushed/fsynced before writing the header or finalizing the manifest","Check for disk-full or interrupted-write conditions on the machine that produced the pack"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import os\n\ndef pack_looks_complete(path, manifest_path):\n    with open(manifest_path) as f:\n        m = json.load(f)\n    if not m.get(\"complete\"):\n        return False\n    expected = m.get(\"file_size\") or m.get(\"pack_bytes\")\n    return expected is None or os.path.getsize(path) == expected","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always verify file size and sha256 against the manifest before loading","Ensure packers write the manifest only after fsync of the pack body"],"tags":["moe","expert-pack","binary-format","truncated-file","corruption"],"backgroundTag":"truncated-file","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}