{"record":{"id":"d0d118996b1288e0","repo":"sgl-project/sglang","slug":"len-missing-routed-expert-tensors-were-not-load","errorCode":null,"errorMessage":"{len(missing)} routed-expert tensors were not loaded (sample: {sample}). Expected {len(expected)} (layers={moe_layer_ids}, num_experts={self.config.num_experts}, shards=3).","messagePattern":"(.+?) routed-expert tensors were not loaded \\(sample: (.+?)\\)\\. Expected (.+?) \\(layers=(.+?), num_experts=(.+?), shards=3\\)\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"python/sglang/srt/models/laguna.py","lineNumber":846,"sourceCode":"                logger.warning(\"Parameter %s not found in params_dict\", name)\n                continue\n            param = params_dict[name]\n            weight_loader = getattr(param, \"weight_loader\", default_weight_loader)\n            weight_loader(param, loaded_weight)\n\n        # If any routed-expert tensor was silently dropped (e.g. a future\n        # checkpoint renaming `gate_proj`, or a ckpt-vs-mapping shape mismatch),\n        # fail loud here instead of generating garbage.\n        expected = {\n            (layer_id, expert_id, shard_id)\n            for layer_id in moe_layer_ids\n            for expert_id in range(self.config.num_experts)\n            for shard_id in (\"w1\", \"w2\", \"w3\")\n        }\n        missing = expected - loaded_expert_shards\n        if missing:\n            sample = sorted(missing)[:5]\n            raise RuntimeError(\n                f\"{len(missing)} routed-expert tensors were not loaded \"\n                f\"(sample: {sample}). Expected {len(expected)} (layers={moe_layer_ids}, \"\n                f\"num_experts={self.config.num_experts}, shards=3).\"\n            )\n\n    def get_embed_and_head(self):\n        return self.model.embed_tokens.weight, self.lm_head.weight\n\n    def set_embed_and_head(self, embed, head):\n        del self.model.embed_tokens.weight\n        del self.lm_head.weight\n        self.model.embed_tokens.weight = embed\n        self.lm_head.weight = head\n        torch.cuda.empty_cache()\n        torch.cuda.synchronize()\n\n    def set_dflash_layers_to_capture(self, layer_ids: List[int]):\n        if not self.pp_group.is_last_rank:","sourceCodeStart":828,"sourceCodeEnd":864,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/models/laguna.py#L828-L864","documentation":"After loading, Laguna verifies every routed-expert shard (per MoE layer x num_experts x {w1,w2,w3}) was filled; if any are missing it lists the count and a sample (laguna.py:846). Missing shards mean the checkpoint file set was incomplete or name mapping failed, which would leave experts with uninitialized weights.","triggerScenarios":"Loading a sharded checkpoint with missing safetensors files, or expert tensor names that don't match the expected pattern (e.g. different expert prefix), leaving some experts.w{1,2,3}_weight slots empty.","commonSituations":"Interrupted checkpoint downloads, partial uploads, LoRA-merged exports with renamed expert keys, or quantized checkpoints lacking fp fallbacks for some shards.","solutions":["Verify all checkpoint shard files are present and hashes match the hub manifest","Re-download the model","Inspect expert key names in the safetensors index and fix the mapping if a conversion renamed them"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"expected = len(moe_layers) * cfg.num_experts * 3\nloaded = count_expert_tensors_in_index(path)\nassert loaded >= expected, f\"{loaded}/{expected} expert tensors\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify shard counts/hashes against the hub manifest after download","Never serve a model that raised this - expert weights are missing"],"tags":["laguna","moe","weight-loading","missing-weights"],"backgroundTag":"incomplete-checkpoint-weights","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}