[Model Runer V2][DFlash] Fix lm head sharing for dflash (#46435)

Signed-off-by: Giancarlo Delfin <gdelfin@inferact.ai>
This commit is contained in:
Giancarlo Delfin
2026-06-23 19:09:06 +00:00
committed by GitHub
parent acce57d8dd
commit ef361de916
@@ -55,16 +55,13 @@ def load_dflash_model(target_model: nn.Module, vllm_config: VllmConfig) -> nn.Mo
del draft_inner.embed_tokens
draft_inner.embed_tokens = target_embed
# Share lm_head with the target unless the draft remaps vocab via
# draft_id_to_target_id (in which case its own lm_head is required).
target_lm_head = getattr(target_model, "lm_head", None)
draft_lm_head = getattr(dflash_model, "lm_head", None)
if (
target_lm_head is not None
and draft_lm_head is not None
and getattr(dflash_model, "draft_id_to_target_id", None) is None
if target_lm_head is not None and _should_share(
dflash_model, "has_own_lm_head", draft_lm_head, target_lm_head
):
del dflash_model.lm_head
if draft_lm_head is not None:
del dflash_model.lm_head
dflash_model.lm_head = target_lm_head
return dflash_model