[optimizer] Fix LayerWise expert ownership - #82
Merged
Conversation
Signed-off-by: Ethan (Yusheng) Su <yushengsu.thu@gmail.com>
yushengsu-thu
force-pushed
the
fix-layerwise
branch
from
August 13, 2026 19:28
6a82d9d to
3d10775
Compare
yushengsu-thu
marked this pull request as ready for review
August 13, 2026 19:38
This was referenced Aug 13, 2026
Open
Author
|
@codex review |
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.
Summary
Fix
LayerWiseDistributedOptimizerwhen dense and expert parameters have different data-parallel ownership groups.In the reproduced TP2 / ETP1 / EP1 / DP1 setup,
dp_cphas one rank whileexpt_dphas two. The old singleton fast path skipped sharding entirely, leaving a full expert optimizer copy on both ranks. World-reduced gradient statistics then counted the same expert replicas twice, making the normsqrt(2)too large and clipping too strong.The fix shards dense and expert parameters independently, handles pure-expert and empty ownership shards in all-gather/broadcast, filters expert replicas with the ETP group, and preserves the required topology metadata on child optimizers and BF16 master parameters. It assumes source expert parameters are already tagged correctly and is not a full upstream backport.
Validation
Manually tested on 4×H200 at
3d107754:The distributed tests cover unique ownership, exact norm and clipping, zero counts, parameter updates, and expert-DP replica equality.
Related work
expert-topology correctness fix。 (on main)
main; this PR is the LayerWise counterpart onmiles-main.mainin #2241. This PR fixes the singleton and empty-shard cases in that path.