Repository navigation
[草稿] token 模式复用公共 LM/MTP 辅助梯度 - #7
Draft
xingleixu123 wants to merge 1 commit into
Draft
xingleixu123 wants to merge 1 commit into
xingleixu123 wants to merge 1 commit into
Conversation
复用现有归一化模式和辅助梯度绑定,保留 legacy 默认与 microbatch 边界。 对 token 模式核验共享计数族及整步 loss 键一致,拒绝未经支持的序列并行计数。
This was referenced Nov 5, 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.
What type of PR is this?
/kind bug
What does this PR do / why do we need it:
此增量基于 主仓 #1410 的
7a55338d,提交到原功能分支供其吸收,避免另建一套归一化接口。保持legacy/microbatch/token三种定义和 legacy 默认;单卡 MF 对照使用 legacy,布局间自洽使用显式 token。原 token 模式只接收单个主 LM loss,无法用于含 MTP 的模型。本次只改三个逻辑文件(+28/−14):允许共享同一计数族和外部权重的多个 loss,并核验整步 loss 键不变;复用 #1441 对各 foundation 分支绑定公共辅助梯度倍率;microbatch 仍拒绝 MTP/aux。
MTP 各深度内部均值和可见 loss factor 不变;独立 MoE aux 按公共上下文继承 Trainer 外层倍率,不额外乘模型内部 MTP factor。不同计数族不能混为一个分母。新模式要求 token 计数在 TP 上复制,因此显式拒绝 sequence_parallel=True;TP loss parallel 且 SP=false 是不同路径。token 原有 graph compiler、外部梯度及 PP 限制保留,不以此次修改宣称支持这些组合。
#1453 同样处理整步归一化,具有重叠改动,最终应由原功能分支统一取舍;不能把两个 PR 直接按文件覆盖叠加。未改写 mindspore-ai#1439 或任何他人分支的提交历史。
Which issue(s) this PR fixes:
关联 主仓 #1418、hf1s#355、总跟踪 hf1s#353。
Test Plan and Test result:
Code review checklist [illustration]: