Skip to content

[Refactor] Drop non-global aux-loss averaging mode#1965

Draft
HAOCHENYE wants to merge 1 commit into
reduce-sum-04-remove-world-sizefrom
reduce-sum-05-drop-nonglobal
Draft

[Refactor] Drop non-global aux-loss averaging mode#1965
HAOCHENYE wants to merge 1 commit into
reduce-sum-04-remove-world-sizefrom
reduce-sum-05-drop-nonglobal

Conversation

@HAOCHENYE

Copy link
Copy Markdown
Collaborator

This PR (5/5) — breaking config change. Drops the balancing_loss_global_average / z_loss_global_average switches and the non-global aux-loss mode, which is incompatible with reduce-sum (SUM-aggregated replicated router grad would inflate by world_size). Distributed = global-average; single-process is its W=1 special case.

Full stack (merge bottom-up, under #1959):

  1. reduce-sum-01-fsdp-helper — [FSDP] Add reduce-sum gradient reduction helper
  2. reduce-sum-02-split-logging — [Loss] Split logging loss from backward loss
  3. reduce-sum-03-switch-sum — [FSDP][Loss] Switch gradient reduction to SUM
  4. reduce-sum-04-remove-world-size — [Refactor] Remove unused world_size plumbing
  5. reduce-sum-05-drop-nonglobal — [Refactor] Drop non-global aux-loss averaging mode

BREAKING CONFIG CHANGE: remove BalancingLossConfig.balancing_loss_global_average
and ZLossConfig.z_loss_global_average. These switches only selected the per-rank
(non-global) averaging mode, which is incompatible with reduce-sum gradients: the
router/gate is a replicated param whose gradient is SUM-aggregated across the
replicate group, so a full per-rank aux loss would inflate that gradient by
world_size (the old FSDP AVG hid this by mean-reducing). No config or test in the
repo ever set either switch to False.

The finalize/accumulate branch now keys purely on dist.is_initialized():
distributed uses the global-average statistics; the single-process branch is kept
(reference / eval run with the process group uninitialized) and is numerically the
world-size-1 special case of the global branch (tokens_per_expert_global ==
tokens_per_expert_local, seqlen_global == valid_tokens), so its values are
unchanged. Design doc S5.3 updated to state aux loss has only one averaging mode.

Verified: single-process balancing/z-loss values bit-identical before/after;
distributed balancing A/B, z-loss A/B and EP=1/EP=2 token-mean parity all pass.
@HAOCHENYE
HAOCHENYE force-pushed the reduce-sum-04-remove-world-size branch from 006ac3c to 4f4db55 Compare July 17, 2026 08:11
@HAOCHENYE
HAOCHENYE force-pushed the reduce-sum-05-drop-nonglobal branch from 853ebc1 to 433634c Compare July 17, 2026 08:11
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.

1 participant