sgl-project/sglang · critical · ValueError

Kimi expert-pack role sizes do not match object bytes

Error message

Kimi expert-pack role sizes do not match object bytes

What it means

The sum of per-role byte sizes (role_nbytes summed over KIMI_PHYSICAL_ROLES) does not equal the manifest's expert_pack.object_bytes. This means the declared per-tensor sizes are internally inconsistent with the declared payload size, indicating a corrupt or miscomputed manifest.

Source

Thrown at python/sglang/srt/layers/moe/expert_pack.py:795

            ):
                raise ValueError(f"Kimi expert-pack {role} quant type is unsupported")

        expected_entry_count = len(active_layers) * expected_experts * len(ROLE_NAMES)
        index_digest = hashlib.sha256()
        self.entries: dict[tuple[int, int, int], ExpertPackEntry] = {}
        self.object_offsets: dict[tuple[int, int], int] = {}
        object_payload_bytes = int(pack_manifest["object_bytes"])
        previous_end = int(pack_manifest["data_start"])
        role_offsets: dict[str, int] = {}
        role_nbytes = {
            role: int(roles[role]["expert_bytes"]) for role in KIMI_PHYSICAL_ROLES
        }
        running_role_offset = 0
        for role in KIMI_PHYSICAL_ROLES:
            role_offsets[role] = running_role_offset
            running_role_offset += role_nbytes[role]
        if running_role_offset != object_payload_bytes:
            raise ValueError("Kimi expert-pack role sizes do not match object bytes")

        with self.path.open("rb", buffering=0) as stream:
            raw_header = stream.read(GGML_PACK_HEADER.size)
            if len(raw_header) != GGML_PACK_HEADER.size:
                raise ValueError("Kimi expert-pack header is truncated")
            index_digest.update(raw_header)
            magic, version, header_size, index_count, data_start = (
                GGML_PACK_HEADER.unpack(raw_header)
            )
            if (
                magic != GGML_PACK_MAGIC
                or version != 1
                or header_size != GGML_PACK_HEADER.size
                or index_count != expected_entry_count
                or data_start != int(pack_manifest["data_start"])
            ):
                raise ValueError("Kimi expert-pack header does not match its manifest")

View on GitHub (pinned to 0132848349)

Solutions

  1. Regenerate the manifest with the official packing tool so role sizes and object_bytes are computed consistently
  2. Check that num_experts, intermediate size, and quant block-size math used to compute role_nbytes match the actual pack
Defensive patterns

Strategy: validation

Validate before calling

total = sum(role_nbytes[r] for r in KIMI_PHYSICAL_ROLES)
assert total == int(manifest['expert_pack']['object_bytes'])

Prevention

When it happens

Trigger: Manifest where role sizes were edited or computed with wrong shard counts (experts, hidden dims, quant block sizes) so their sum diverges from object_bytes.

Common situations: See trigger scenarios.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/ab6f1d63a34a84e8. Report an issue: GitHub.