sgl-project/sglang · critical · ValueError
Kimi expert object is not contiguous at index {index}
Error message
Kimi expert object is not contiguous at index {index} What it means
For each (layer, expert) object, the three role blobs must be physically contiguous: each role's offset must equal the object's base offset plus the role's cumulative role_offsets. A mismatch means the pack interleaves objects or has gaps, which the mmap-based loader cannot handle.
Source
Thrown at python/sglang/srt/layers/moe/expert_pack.py:856
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)
logical_shape = tuple(
int(value) for value in roles[physical_role]["logical_shape"]
)
self.entries[(layer, expert, logical_role_id)] = ExpertPackEntry(
layer=layer,
expert=expert,
role_id=logical_role_id,
dtype_id=int(roles[physical_role]["dtype_id"]),
dtype=str(roles[physical_role]["dtype"]),
tensor_name=name,
source_slice_offset=0,View on GitHub (pinned to 0132848349)
Solutions
- Re-pack so each expert's up/gate/down blobs are adjacent in the fixed physical role order
- If writing a custom packer, compute each role offset as object_base + role_offsets[role]
Defensive patterns
Strategy: validation
Validate before calling
null
Try / catch
try:
pack = KimiExpertPack(path, manifest)
except ValueError as e:
if 'not contiguous' in str(e):
log.error('pack layout groups by role, not per-expert; re-pack required')
raise Prevention
- Use the official packer which writes per-expert contiguous blobs
When it happens
Trigger: A pack that stores tensors grouped by role (all ups, then all gates) instead of grouped per expert; or gaps/inserted padding between an expert's role blobs.
Common situations: See trigger scenarios.
Related errors
- Kimi active routed MoE layers must be exactly 1..92
- Kimi manifest expert-pack path does not match pack_path
- Kimi expert-pack size does not match its manifest
- Kimi expert-pack physical role order is unsupported
- Kimi expert-pack role sizes do not match object bytes
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/6c75edced53aa376.
Report an issue: GitHub.