fix: correct weight loading prefix mapping for Qwen3-VL (#18024)

Co-authored-by: liuxiaoming <liuxiaoming@modelbest.cn>
Co-authored-by: Xinyuan Tong <115166877+JustinTong0323@users.noreply.github.com>
This commit is contained in:
Xiaoming Liu
2026-02-02 13:50:21 +08:00
committed by GitHub
parent a480ca7ead
commit 522e13b4d2

View File

@@ -959,7 +959,13 @@ class Qwen3VLForConditionalGeneration(nn.Module):
name = name.replace(r"model.language_model.", r"model.")
layer_id = get_layer_id(name)
if self.pp_group.is_last_rank and "model.embed_tokens.weight" in name:
# Only copy embed_tokens to lm_head when tie_word_embeddings=True
# For models with tie_word_embeddings=False (e.g. 8B), lm_head has independent weights
if (
self.pp_group.is_last_rank
and "model.embed_tokens.weight" in name
and self.config.tie_word_embeddings
):
if "lm_head.weight" in params_dict:
lm_head_param = params_dict["lm_head.weight"]
weight_loader = getattr(