Repository navigation
Fix reduce-scatter bandwidth in the comms logger - #8695
Open
Arthur031221 wants to merge 1 commit into
Open
Arthur031221 wants to merge 1 commit into
Arthur031221 wants to merge 1 commit into
Conversation
calc_bw_log multiplied the message size by the world size for reduce_scatter and reduce_scatter_tensor, the same as for the all-gather ops. That scaling is right for all-gather, whose logged size is the per-rank input, but the logged size of a reduce-scatter is its input, which already spans every rank. Both algbw and busbw for reduce-scatter were therefore reported world_size times too high. Keep the scaling for the all-gather ops only, so both follow the nccl-tests definition, where S is the size of the whole array. Signed-off-by: Arthur031221 <[email protected]>
Arthur031221
requested review from
loadams,
tjruwase and
tohtana
as code owners
September 28, 2026 18:03
This branch has not been deployed
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.
calc_bw_logputsreduce_scatterandreduce_scatter_tensorin the same branch as the all-gather ops, which multiplies the logged message size by the world size before computing algbw and busbw. That is right for all-gather, but not for reduce-scatter, becausetimed_oplogs a different tensor for each:all_gather_into_tensor(output_tensor, tensor)andall_gather(tensor_list, tensor)logtensor, the per-rank input, so scaling byngives the size of the whole array.reduce_scatter_tensor(output_tensor, tensor)logstensor, the full input, andreduce_scatter(output, input_list)logs the sum ofinput_list. That size already covers every rank, and scaling it bynagain reports both bandwidthsntimes too high.With the default
reduce_scatter: true, ZeRO-3 reduces gradients throughreduce_scatter_coalesced, except for the tensors that the quantized all-to-all path (multi-node only) handles itself. That function passes the full flattened gradient buffer toreduce_scatter_fn, which callsreduce_scatter_tensor(orreduce_scatterwhere that is unavailable). When the comms logger profiles those calls, the reduce-scatter algbw and busbw it reports inlog_summaryare world size times too high.The nccl-tests performance notes that the function cites use S, the size of the whole array, for both ops, with busbw = algbw * (n-1)/n.
With a world size of 4, a 1 ms duration, 1024-byte shards and a 4096-byte full array, feeding each op's logged size through
calc_bw_loggives:The list forms
all_gatherandreduce_scattergive the same numbers as their tensor forms. The nccl-tests formulas for S = 4096 bytes in 1 ms give 0.032768 and 0.024576.The fix moves the two reduce-scatter ops into their own branch without the
size *= n. The new test intests/unit/comm/test_comms_logger.pycalls all four ops throughtimed_opwith a mocked backend at world size 4 and checks the recorded algbw and busbw against the nccl-tests formulas. On master the two reduce-scatter cases fail with 4x the expected value, and all 56 tests in the file pass with the fix.pre-commit runpasses on both changed files.