From ef361de9163e1d0fe8c0ea9028b320994c24f218 Mon Sep 17 00:00:00 2001 From: Giancarlo Delfin <32987265+TheEpicDolphin@users.noreply.github.com> Date: Tue, 23 Jun 2026 14:09:06 -0500 Subject: [PATCH] [Model Runer V2][DFlash] Fix lm head sharing for dflash (#46435) Signed-off-by: Giancarlo Delfin --- vllm/v1/worker/gpu/spec_decode/dflash/utils.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/vllm/v1/worker/gpu/spec_decode/dflash/utils.py b/vllm/v1/worker/gpu/spec_decode/dflash/utils.py index f4ea4be8b8..01f6923a76 100644 --- a/vllm/v1/worker/gpu/spec_decode/dflash/utils.py +++ b/vllm/v1/worker/gpu/spec_decode/dflash/utils.py @@ -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