sgl-project/sglang · critical · ValueError

Kimi expert-pack range mismatch at index {index}

Error message

Kimi expert-pack range mismatch at index {index}

What it means

An index entry's byte range is invalid: nbytes differs from the role's expected size, offset is not aligned to the manifest alignment, offset goes backwards (before previous entry's end), or offset+nbytes exceeds the file size. The data region must be a strictly increasing, aligned, in-bounds layout.

Source

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

                match = KIMI_EXPERT_RE.fullmatch(name)
                if (
                    match is None
                    or int(match.group("layer")) != layer
                    or match.group("role") != physical_role
                    or expert != expected_expert
                    or reserved != 0
                ):
                    raise ValueError(
                        f"Kimi expert-pack identity mismatch at index {index}"
                    )
                expected_nbytes = role_nbytes[physical_role]
                if (
                    nbytes != expected_nbytes
                    or offset % int(pack_manifest["alignment"])
                    or offset < previous_end
                    or offset + nbytes > self.path.stat().st_size
                ):
                    raise ValueError(
                        f"Kimi expert-pack range mismatch at index {index}"
                    )
                previous_end = offset + nbytes
                object_key = (layer, expert)
                if physical_role_id == 0:
                    self.object_offsets[object_key] = offset
                expected_offset = (
                    self.object_offsets[object_key] + role_offsets[physical_role]
                )
                if offset != expected_offset:
                    raise ValueError(
                        f"Kimi expert object is not contiguous at index {index}"
                    )
                generation_bytes = hashlib.sha256(
                    f"{pack_manifest['index_sha256']}:{layer}:{expert}".encode("ascii")
                ).digest()
                generation = int.from_bytes(generation_bytes[:8], "little") or 1
                logical_role_id = ROLE_NAMES.index(physical_role)

View on GitHub (pinned to 0132848349)

Solutions

  1. Verify file integrity (size, then SHA-256) and re-download if mismatched
  2. Re-pack with consistent alignment; ensure offsets are emitted in increasing order and role sizes match expected_nbytes
Defensive patterns

Strategy: validation

Validate before calling

null

Try / catch

try:
    pack = KimiExpertPack(path, manifest)
except ValueError as e:
    if 'range mismatch' in str(e):
        log.error('pack data region corrupt; re-download')
    raise

Prevention

When it happens

Trigger: Corrupted index after bit rot or bad writes; a pack written with different alignment or unsorted offsets; manifest alignment field inconsistent with actual data.

Common situations: See trigger scenarios.

Related errors


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