sgl-project/sglang · critical · ValueError

Kimi expert-pack index SHA-256 does not match manifest

Error message

Kimi expert-pack index SHA-256 does not match manifest

What it means

The SHA-256 computed incrementally over the header plus every index entry does not match manifest.expert_pack.index_sha256. The index bytes on disk differ from what the manifest recorded — the file or manifest was modified/corrupted.

Source

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

                    dtype=str(roles[physical_role]["dtype"]),
                    tensor_name=name,
                    source_slice_offset=0,
                    source_slice_nbytes=nbytes,
                    pack_offset=offset,
                    pack_nbytes=nbytes,
                    checksum="",
                    shape=logical_shape,
                    quant_scheme=str(roles[physical_role]["dtype"]),
                    transform_id="identity-v1",
                    block_size=256,
                    generation=generation,
                )

        if previous_end != self.path.stat().st_size:
            raise ValueError("Kimi expert-pack file has trailing or missing bytes")
        actual_index_sha256 = index_digest.hexdigest()
        if actual_index_sha256 != pack_manifest["index_sha256"]:
            raise ValueError("Kimi expert-pack index SHA-256 does not match manifest")
        if verify_pack_sha256:
            expected_sha256 = pack_manifest.get("sha256")
            if not expected_sha256:
                raise ValueError(
                    "full pack verification requested, but manifest has no full SHA-256"
                )
            if _sha256_file(self.path) != expected_sha256:
                raise ValueError("Kimi expert-pack SHA-256 does not match manifest")

        self.header = ExpertPackHeader(
            flags=REQUIRED_FLAGS,
            index_count=expected_entry_count,
            data_start=int(pack_manifest["data_start"]),
            alignment=int(pack_manifest["alignment"]),
            num_layers=expected_layers,
            num_experts=expected_experts,
            top_k=expected_top_k,
            role_count=len(ROLE_NAMES),

View on GitHub (pinned to 0132848349)

Solutions

  1. Verify and re-download/rebuild the pack so index bytes match the manifest
  2. Regenerate the manifest after any legitimate repack (index_sha256 must be recomputed)
  3. Never hand-edit pack bytes or manifest hashes
Defensive patterns

Strategy: validation

Validate before calling

import hashlib
h = hashlib.sha256()
# for quick pre-check, verify the full-file sha256 first if available
if 'sha256' in manifest['expert_pack']:
    assert _sha256_file(pack_path) == manifest['expert_pack']['sha256']

Try / catch

try:
    pack = KimiExpertPack(path, manifest)
except ValueError as e:
    if 'index SHA-256' in str(e):
        log.error('pack index corrupted; re-download from source')
    raise

Prevention

When it happens

Trigger: Any bit-level change in header or index region: partial write, disk corruption, byte-level patching of entry fields, or a manifest from a different pack revision.

Common situations: See trigger scenarios.

Related errors


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