sgl-project/sglang · critical · ValueError

Kimi active routed MoE layers must be exactly 1..92

Error message

Kimi active routed MoE layers must be exactly 1..92

What it means

Raised while loading a Kimi expert-pack when the manifest's active_moe_layer_ids do not equal the range 1..92. The loader only supports the exact Kimi K2 routed-MoE layout (layers 1 through 92, layer 0 dense), so any deviation is rejected at validation time to prevent silent weight mis-mapping.

Source

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

        }:
            raise ValueError(
                "Kimi manifest hard constraints do not match runtime policy"
            )
        model = self.manifest["model"]
        dimensions = (
            int(model["num_hidden_layers"]),
            int(model["num_experts"]),
            int(model["num_experts_per_token"]),
        )
        expected_dimensions = (expected_layers, expected_experts, expected_top_k)
        if dimensions != expected_dimensions or expected_top_k != 16:
            raise ValueError(
                f"Kimi expert-pack dimensions {dimensions} != {expected_dimensions}; "
                "Top-K is immutable at 16"
            )
        active_layers = tuple(int(value) for value in model["active_moe_layer_ids"])
        if active_layers != tuple(range(1, 93)):
            raise ValueError("Kimi active routed MoE layers must be exactly 1..92")

        pack_manifest = self.manifest["expert_pack"]
        if Path(pack_manifest["path"]).resolve() != self.path:
            raise ValueError("Kimi manifest expert-pack path does not match pack_path")
        if int(pack_manifest["size"]) != self.path.stat().st_size:
            raise ValueError("Kimi expert-pack size does not match its manifest")
        if pack_manifest.get("physical_role_order") != list(KIMI_PHYSICAL_ROLES):
            raise ValueError("Kimi expert-pack physical role order is unsupported")
        roles = pack_manifest["roles"]
        expected_roles = {
            "up": ("Q2_K", 10),
            "gate": ("Q2_K", 10),
            "down": ("Q3_K", 11),
        }
        for role, (dtype, dtype_id) in expected_roles.items():
            if (
                roles[role]["dtype"] != dtype
                or int(roles[role]["dtype_id"]) != dtype_id

View on GitHub (pinned to 0132848349)

Solutions

  1. Regenerate or obtain a manifest from the official Kimi K2 checkpoint whose active_moe_layer_ids is exactly list(range(1, 93))
  2. Verify you are pointing pack_path at a Kimi K2 pack, not another MoE model's pack
  3. If you intentionally need a different layer layout, patch the loader's expected range — but note weights will not map correctly without deeper changes

Example fix

// before
"active_moe_layer_ids": [1, 2, 3]
// after
"active_moe_layer_ids": list(range(1, 93))
Defensive patterns

Strategy: validation

Validate before calling

ids = manifest['model']['active_moe_layer_ids']
if list(ids) != list(range(1, 93)):
    raise RuntimeError('manifest is not a Kimi K2 pack: active layers != 1..92')

Type guard

def is_kimi_k2_manifest(m: dict) -> bool:
    return list(m['model']['active_moe_layer_ids']) == list(range(1, 93))

Prevention

When it happens

Trigger: Constructing the expert-pack loader with a manifest whose model.active_moe_layer_ids is not exactly [1..92] — e.g. a trimmed/quantized pack with fewer layers, reordered ids, or a manifest generated for a different model variant.

Common situations: Using a custom or community-quantized Kimi pack with pruned layers; mixing manifests from different Kimi checkpoints; hand-editing the manifest JSON.

Related errors


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