Skip to content

[optimizer] Fix LayerWise expert ownership - #82

Merged
yushengsu-thu merged 2 commits into
miles-mainfrom
fix-layerwise
Aug 19, 2026
Merged

[optimizer] Fix LayerWise expert ownership#82
yushengsu-thu merged 2 commits into
miles-mainfrom
fix-layerwise

Conversation

@yushengsu-thu

@yushengsu-thu yushengsu-thu commented Aug 13, 2026

Copy link
Copy Markdown

Summary

Fix LayerWiseDistributedOptimizer when dense and expert parameters have different data-parallel ownership groups.

In the reproduced TP2 / ETP1 / EP1 / DP1 setup, dp_cp has one rank while expt_dp has 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 norm sqrt(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:

  • CPU ownership and empty-shard regressions;
  • NCCL topologies: TP2 / ETP1, TP4 / ETP2 / EP1, and TP2 / ETP1 / EP2;
  • full 4-GPU LayerWise suite: 21 passed per rank;
  • single-GPU optimizer suite: 16 passed, 40 skipped.

The distributed tests cover unique ownership, exact norm and clipping, zero counts, parameter updates, and expert-DP replica equality.

Related work

Signed-off-by: Ethan (Yusheng) Su <yushengsu.thu@gmail.com>
@yushengsu-thu

Copy link
Copy Markdown
Author

@codex review

@yushengsu-thu
yushengsu-thu merged commit 2e64d78 into miles-main Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants