Skip to content

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

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

[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

Copy link
Copy Markdown
Collaborator Author

Superseded by the consolidated 2-PR stack #1968 (core) + #1969 (drop non-global). Closing this fragmented stack.

@HAOCHENYE HAOCHENYE closed this Jul 20, 2026
@HAOCHENYE
HAOCHENYE deleted the reduce-sum-05-drop-nonglobal branch July 20, 2026 16:35
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