Repository navigation
fix: exclude frozen parameters from DDP and improve cross-entropy reduction precision - #244
Open
chen2021673 wants to merge 2 commits into
Open
chen2021673 wants to merge 2 commits into
chen2021673 wants to merge 2 commits into
Conversation
Contributor
Author
Chamberlain0w0
approved these changes
Oct 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

背景
在 LoRA 等部分参数训练场景中,模型同时包含可训练参数和冻结参数。此前 DDP 初始化时会将全部参数传入 Reducer、梯度桶及反向 Hook,可能导致冻结参数被错误纳入梯度同步流程。
此外,CrossEntropy 在主机端使用 FP32 累加 batch loss,batch size 较大时可能产生较明显的数值误差。
修改内容
requires_grad=true的参数,仅为可训练参数执行以下操作:c_fc加入目标模块,覆盖更多冻结参数与可训练参数混合的场景。影响
测试
精度测试:

性能测试:
