[BugFix]fix v1 loader lm head fp32 (#5270) (#5287)
CE Compile Job / ce_job_pre_check (push) Has been cancelled
CE Compile Job / print_ce_job_pre_check_outputs (push) Has been cancelled
CE Compile Job / FD-Clone-Linux (push) Has been cancelled
CE Compile Job / Show Code Archive Output (push) Has been cancelled
CE Compile Job / BUILD_SM8090 (push) Has been cancelled
CE Compile Job / BUILD_SM8689 (push) Has been cancelled
CE Compile Job / CE_UPLOAD (push) Has been cancelled

This commit is contained in:
chen
2025-11-28 17:52:25 +08:00
committed by GitHub
parent bab01e9f85
commit 4e392e8337
3 changed files with 6 additions and 3 deletions
@@ -251,7 +251,9 @@ class Qwen2_5_VLForConditionalGeneration(ModelForCasualLM):
self.model.load_state_dict(state_dict)
self.visual.load_state_dict(state_dict)
if self.tie_word_embeddings:
self.lm_head.linear.weight.set_value(self.model.embed_tokens.embeddings.weight.transpose([1, 0]))
self.lm_head.linear.weight.set_value(
self.model.embed_tokens.embeddings.weight.transpose([1, 0]).astype(self.lm_head.linear.weight.dtype)
)
else:
self.lm_head.load_state_dict(state_dict)