Pull Request已成功合入, 合并人@ascend-robot
(感谢 LKONE 的贡献)变更摘要
本 PR 是一个针对 tie_word_embeddings 为 True 时权重绑定逻辑的 bugfix:将 _retie_embeddings(model) 的调用位置从 DCP 权重加载后的后处理流程(hf_load_utils.py 中的 post_process_after_load)移动到 trainer.py 中 Trainer 构建模型之后执行,用于重新绑定 embed_tokens 与 lm_head 的权重;同时在 Qwen3TTSConfig 的初始化中强制将 tie_word_embeddings 置为 False,规避 transformers 4.57.3 在未显式提供该字段时默认设为 True 所导致的 _retie_embeddings 失败问题。
主要改动
- 移除加载后处理中的重绑定调用:在
mindspeed_mm/fsdp/checkpoint/hf_load_utils.py的post_process_after_load中删除_retie_embeddings(model)调用,使权重加载阶段不再执行嵌入权重重绑定。 - 在 Trainer 中执行重绑定:在
mindspeed_mm/fsdp/train/trainer.py中新增_retie_embeddings的导入,并在Trainer完成模型构建(含LoraWeightManager设置)后调用_retie_embeddings(model),在tie_word_embeddings为 True 时重新绑定embed_tokens与lm_head权重。 - 修正
Qwen3TTSConfig默认配置:在mindspeed_mm/fsdp/models/qwen3tts/core/models/configuration_qwen3_tts.py的Qwen3TTSConfig.__init__中强制设置kwargs["tie_word_embeddings"] = False后再转发给父类配置,防止 transformers 4.57.3 的默认行为导致后续_retie_embeddings失败。


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-Ascend/MindSpeed-MM | ✅ 王海涛, gaojie_, WendongPang (3/2) | ✅ 王海涛 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
wanglikai1019, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


ascend docs pipeline is running...


ascend docs pipeline is running...


| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build | ✅ | >>> |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | Only_doc_commit | ✅ | >>> |
| codeCheck_pre-commit | ✅ | >>> | |
| pre-commit | ✅ | >>> | |
| Compatibility_Interface | ✅ | >>> | |
| 开源片段检查 | SCA | ✅ | >>> |
| 开发者测试 | UT | 🛑 | >>> |
| ST | 🛑 | >>> | |
| UT-pool | ✅ | >>> | |
| ST_pool | ✅ | >>> | |
| 流水线 | PR-pipeline_MindSpeed-MM | ✅ | >>> |
- compile : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


/lgtm


/lgtm


What this PR does / why we need it?
在对Qwen3.5-4B模型在hf权重和dcp权重两种加载场景下的精度进行对比时发现存在差异,定位发现Qwen3.5-4B的embed_tokens和lm_head层的权重是绑定的,在hf权重加载场景,两者能够共享同一份权重,但是在dcp场景下,两者虽然在权重转换过程中实现了权重的一致,但是在后续训练过程中并未保持一致,两者会独立进行更新,导致训练梯度存在差异,因此做以下改动:
(1)模型初始化完成后,对embed_tokens和lm_head层的weight进行绑定;
(3)删除原有Qwen3.5 readme权重转换过程中对4B以下模型的权重绑定要求,将其从权重转换过程中移至模型初始化过程中实现。
Does this PR introduce any user-facing change?
无
How was this patch tested?
(1)对于tie_word_embeddings=true的模型,原有hf权重和dcp权重加载时精度存在差异,本PR调整后精度完全对齐;
(2)对于tie_word_embeddings=false的模型,本PR调整后不会对精度产生任何影响。