[Model Runer V2][DFlash] Fix lm head sharing for dflash (#46435)
Signed-off-by: Giancarlo Delfin <gdelfin@inferact.ai>
This commit is contained in:
@@ -55,16 +55,13 @@ def load_dflash_model(target_model: nn.Module, vllm_config: VllmConfig) -> nn.Mo
|
|||||||
del draft_inner.embed_tokens
|
del draft_inner.embed_tokens
|
||||||
draft_inner.embed_tokens = target_embed
|
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)
|
target_lm_head = getattr(target_model, "lm_head", None)
|
||||||
draft_lm_head = getattr(dflash_model, "lm_head", None)
|
draft_lm_head = getattr(dflash_model, "lm_head", None)
|
||||||
if (
|
if target_lm_head is not None and _should_share(
|
||||||
target_lm_head is not None
|
dflash_model, "has_own_lm_head", draft_lm_head, target_lm_head
|
||||||
and draft_lm_head is not None
|
|
||||||
and getattr(dflash_model, "draft_id_to_target_id", None) is None
|
|
||||||
):
|
):
|
||||||
del dflash_model.lm_head
|
if draft_lm_head is not None:
|
||||||
|
del dflash_model.lm_head
|
||||||
dflash_model.lm_head = target_lm_head
|
dflash_model.lm_head = target_lm_head
|
||||||
|
|
||||||
return dflash_model
|
return dflash_model
|
||||||
|
|||||||
Reference in New Issue
Block a user