DeepSpeed
c442e3f7 - Apply the ZeRO-1/2 predivide postscale under sequence parallelism (#8687)

Commit
5 days ago
Apply the ZeRO-1/2 predivide postscale under sequence parallelism (#8687) With sequence parallelism, ZeRO-1/2 averages gradients over `dp_world_size / sequence_parallel_size`, but `gradient_reduction_w_predivide` skips the postscale when `gradient_predivide_factor == dp_world_size`. With `sequence_parallel_size > 1` the skipped multiply is not 1, so gradients come out `sequence_parallel_size` times too small, with no error. The pre-scale path and predivide 1.0 give the right value. The fix compares the factor against the averaging size, like `engine.allreduce_bucket` does. Behavior with `sequence_parallel_size == 1` is unchanged. Added `TestZeroPredivideWithSequenceParallel`. `DistributedTest` skips on CPU, so I ran its body in 2- and 4-rank gloo: before, predivide 2 of 2 ranks gave 1.5 (expected 3.0) and 4 of 4 gave 2.5 (expected 5.0); after, 7/7 match. yapf and flake8 clean. Executed on Apple M2 Pro CPU. Signed-off-by: Vineeth Sai <vineethsai4444@gmail.com>
Author
Parents
Loading