{"record":{"id":"53cc3c2b0b37eb43","repo":"sgl-project/sglang","slug":"some-parameters-like-param-name-example-are-not","errorCode":null,"errorMessage":"Some parameters like {param_name_example} are not in the checkpoint and will falsely use random initialization","messagePattern":"Some parameters like (.+?) are not in the checkpoint and will falsely use random initialization","errorType":"validation","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"python/sglang/srt/models/step3p5_mtp.py","lineNumber":290,"sourceCode":"                    if \"shared_head\" in name:\n                        name = name.replace(\"shared_head.output\", \"shared_head.head\")\n                    if \"embed_tokens\" in name:\n                        assert (\n                            hasattr(self.config, \"num_nextn_predict_layers\")\n                            and self.config.num_nextn_predict_layers > 0\n                        )\n                        name = \"model.embed_tokens.weight\"\n                    param = params_dict[name]\n                    weight_loader = getattr(\n                        param, \"weight_loader\", default_weight_loader\n                    )\n                    weight_loader(param, loaded_weight)\n            loaded_params.add(name)\n        params_need_to_load = set(params_dict.keys())\n        if params_need_to_load != loaded_params:\n            missing_params = list(params_need_to_load - loaded_params)\n            param_name_example = missing_params[0]\n            raise RuntimeError(\n                f\"Some parameters like {param_name_example} are not in the checkpoint and will falsely use random initialization\"\n            )\n        return loaded_params\n\n    def _rewrite_spec_layer_name(self, spec_layer: Optional[int], name: str) -> str:\n        \"\"\"\n        Rewrite the weight name to match the format of the original model.\n        Add .mtp_block for modules in transformer layer block for spec layer\n        \"\"\"\n        if spec_layer is None:\n            return name\n\n        # Some checkpoints place MTP weights under \"model.layers.<id>.transformer.*\".\n        # Our modules use \"model.layers.<id>.*\", so drop the \".transformer.\" segment.\n        transformer_prefix = f\"model.layers.{spec_layer}.transformer.\"\n        if name.startswith(transformer_prefix):\n            name = name.replace(\".transformer.\", \".\", 1)\n","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/models/step3p5_mtp.py#L272-L308","documentation":"step3p5_mtp.load_weights verifies that every model parameter received checkpoint data; if any parameter was never loaded it raises RuntimeError instead of silently using random init (which would produce garbage draft predictions).","triggerScenarios":"Loading a draft checkpoint that is missing keys (e.g. shared/repacked embeddings, renamed head) so some parameter is never visited by the weight loop.","commonSituations":"Mismatched draft checkpoint format, missing lm_head in the draft file, renamed spec layer prefixes not covered by _rewrite_spec_layer_name.","solutions":["Inspect missing_params (first name is in the message) and extend the name-rewriting/mapping logic","Ensure the draft checkpoint includes all draft-model weights (embed/lm_head/shared towers)","Verify the draft architecture (spec config) matches the checkpoint"],"exampleFix":"// before\nparams_need_to_load = set(params_dict.keys())\nif params_need_to_load != loaded_params:\n    raise RuntimeError(...)\n// after: allow intentionally-shared params to be resolved from the target model\nshared = {n for n in params_need_to_load - loaded_params if 'lm_head' in n or 'embed' in n}\nif params_need_to_load - loaded_params - shared:\n    raise RuntimeError(...)","handlingStrategy":"validation","validationCode":"model_keys = {n for n,_ in draft_model.named_parameters()}\nck_keys = {k for k,_ in iter_checkpoint(draft_weights)}\nassert model_keys <= ck_keys, f\"missing: {sorted(model_keys - ck_keys)[:5]}\"","typeGuard":null,"tryCatchPattern":"try:\n    model.load_weights(w)\nexcept RuntimeError as e:\n    if 'falsely use random initialization' in str(e):\n        log_missing_and_reexport_checkpoint()\n    raise","preventionTips":["Diff draft params vs checkpoint keys pre-load","Include lm_head/embeddings in exported draft weights","Test-load drafts in CI"],"tags":["checkpoint-loading","mtp","random-init-guard"],"backgroundTag":"missing-checkpoint-weights","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}