Skip to content

[Refactor] Remove unused world_size plumbing#1964

Draft
HAOCHENYE wants to merge 1 commit into
reduce-sum-03-switch-sumfrom
reduce-sum-04-remove-world-size
Draft

[Refactor] Remove unused world_size plumbing#1964
HAOCHENYE wants to merge 1 commit into
reduce-sum-03-switch-sumfrom
reduce-sum-04-remove-world-size

Conversation

@HAOCHENYE

Copy link
Copy Markdown
Collaborator

This PR (4/5) — behavior-neutral cleanup. Removes the now-dead world_size plumbing (ZLossContext/AuxLossContext.accumulate params, _z_loss_dist_token_count) and the unreferenced all_reduce_autograd/_AllReduce.

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

After the reduce-sum switch, the z-loss global-average branch no longer scales by
world_size and the balancing loss no longer uses all_reduce_autograd, so the
associated plumbing is dead. Remove it to leave one coherent model:

- ZLossContext.accumulate / AuxLossContext.accumulate drop the world_size arg.
- MoE._z_loss_dist_token_count returns just num_tokens_global (no world_size),
  and its call sites in moe.py / qwen3vl_text.py are updated.
- Delete the now-unreferenced all_reduce_autograd / _AllReduce autograd function
  and its all_reduce import from moe_loss.

Pure signature/dead-code cleanup: no change to loss values or gradients.
@HAOCHENYE
HAOCHENYE force-pushed the reduce-sum-03-switch-sum branch from 51c5491 to 590c9e7 Compare July 17, 2026 08:11
@HAOCHENYE
HAOCHENYE force-pushed the reduce-sum-04-remove-world-size branch from 006ac3c to 4f4db55 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