{"record":{"id":"976f2ec0c967fe9d","repo":"sgl-project/sglang","slug":"language-model-does-not-support-get-embed-and-head","errorCode":null,"errorMessage":"language_model does not support get_embed_and_head().","messagePattern":"language_model does not support get_embed_and_head\\(\\)\\.","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/models/kimi_k25.py","lineNumber":968,"sourceCode":"            raise AttributeError(\n                \"language_model does not support get_input_embeddings().\"\n            )\n\n        return self.language_model.get_input_embeddings()\n\n    @property\n    def lm_head(self):\n        if not hasattr(self.language_model, \"lm_head\"):\n            raise AttributeError(\"language_model does not expose lm_head.\")\n\n        return self.language_model.lm_head\n\n    def get_embed_and_head(self) -> Tuple[torch.Tensor, torch.Tensor]:\n        \"\"\"Get embedding and LM head weights for speculative decoding.\"\"\"\n        if self.language_model is None or not hasattr(\n            self.language_model, \"get_embed_and_head\"\n        ):\n            raise AttributeError(\n                \"language_model does not support get_embed_and_head().\"\n            )\n\n        return self.language_model.get_embed_and_head()\n\n    def set_embed_and_head(self, embed: torch.Tensor, head: torch.Tensor) -> None:\n        \"\"\"Set embedding and LM head weights for speculative decoding.\"\"\"\n        if self.language_model is None or not hasattr(\n            self.language_model, \"set_embed_and_head\"\n        ):\n            raise AttributeError(\n                \"language_model does not support set_embed_and_head().\"\n            )\n\n        self.language_model.set_embed_and_head(embed, head)\n\n\nEntryClass = [KimiK25ForConditionalGeneration]","sourceCodeStart":950,"sourceCodeEnd":986,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/models/kimi_k25.py#L950-L986","documentation":"KimiK25ForCausalLM.get_embed_and_head() delegates to the wrapped language_model to fetch embedding and LM-head weights for speculative decoding. If language_model is None or lacks its own get_embed_and_head method, this AttributeError is raised. It signals that the model wrapper is not compatible with the speculative-decoding weight-access API.","triggerScenarios":"Calling model.get_embed_and_head() on a Kimi K2.5 wrapper whose self.language_model is None (e.g. draft-model wiring skipped) or whose language_model class (e.g. a MTP/module variant) does not define get_embed_and_head. Typically invoked by the EAGLE/speculative spec worker during draft setup.","commonSituations":"Enabling speculative decoding (EAGLE/MTP) with a target model whose inner language model implementation doesn't implement the spec-decoding hooks; partial initialization where the language model failed to construct; version skew after refactoring model classes.","solutions":["Verify self.language_model is constructed (not None) before enabling speculative decoding.","Check the inner language model class implements get_embed_and_head (see Qwen3/deepseek wrappers for reference) and add the delegation method if missing.","If the inner model is not spec-decode compatible, disable speculative decoding for this model.","Upgrade sglang to a version where the Kimi K2.5 language model implements the spec-decoding weight hooks."],"exampleFix":"// before\nembed, head = model.get_embed_and_head()  # AttributeError\n\n// after\nlm = model.language_model\nif lm is None or not hasattr(lm, \"get_embed_and_head\"):\n    raise RuntimeError(\"speculative decoding unsupported for this language model\")\nembed, head = lm.get_embed_and_head()","handlingStrategy":"type-guard","validationCode":"def supports_spec_weights(model) -> bool:\n    lm = getattr(model, \"language_model\", None)\n    return lm is not None and hasattr(lm, \"get_embed_and_head\")","typeGuard":"def has_get_embed_and_head(model) -> bool:\n    lm = getattr(model, \"language_model\", None)\n    return lm is not None and callable(getattr(lm, \"get_embed_and_head\", None))","tryCatchPattern":null,"preventionTips":["Check hasattr(model.language_model, 'get_embed_and_head') before enabling speculative decoding.","Prefer a smoke-test launch with spec decoding on a small batch when adding a new model variant."],"tags":["speculative-decoding","kimi","attribute-error","model-loading"],"backgroundTag":"unsupported-model-architecture","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}