ms-swift icon indicating copy to clipboard operation
ms-swift copied to clipboard

共享参数模型训练后的保存

Open HJXA opened this issue 8 months ago • 2 comments

Checklist / 检查清单

  • [x] I have searched existing issues, and this is a new bug report. / 我已经搜索过现有的 issues,确认这是一个新的 bug report。

Bug Description / Bug 描述

一个共享embedding参数的模型经过训练后,虽然embed和lm_head参数相同,但是会在tensor中保存为两份,所以如果继续训练,下次就不会再共享了。 训练前加载

embed_tokens.weight is lm_head.weight: True
embed_tokens.weight allclose lm_head.weight: True

加载训练后保存的模型时会提示will NOT tie them,且检查过后发现不是同一地址,但是数值相同。

The tied weights mapping and config for this model specifies to tie model.embed_tokens.weight to lm_head.weight, but both are present in the checkpoints, so we will NOT tie them. You should update the config with `tie_word_embeddings=False` to silence this warning
  [Tie Check] embed_tokens.weight is lm_head.weight: False
  [Tie Check] embed_tokens.weight allclose lm_head.weight: True

How to Reproduce / 如何复现

ms-swift版本4.0.0.dev0

Additional Information / 补充信息

No response

HJXA avatar Mar 19 '26 06:03 HJXA

This issue has been inactive for over 3 months and will be automatically closed in 7 days. If this issue is still relevant, please reply to this message.

github-actions[bot] avatar Jun 18 '26 00:06 github-actions[bot]

应该修复了

Jintao-Huang avatar Jun 24 '26 06:06 Jintao-Huang