Skip to content

Commit

Permalink
change the order of dp and sp all-reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
yingtongxiong committed Oct 25, 2023
1 parent 1655a90 commit 1bc3c33
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions internlm/solver/optimizer/hybrid_zero_optim.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,13 @@ def reduce_grad_hook_sp(*args):
if self.skip_grad_reduce is False:
reduction_sp_func()


accum_grad_obj.register_hook(reduce_grad_hook)

# if sequence_parallel is True, the grad of norm should be all-reduce across the tp process group
if gpc.config.parallel.sequence_parallel is True:
if hasattr(param, IS_SEQUENCE_PARALLEL) and getattr(param, IS_SEQUENCE_PARALLEL) is True:
accum_grad_obj_sp = get_grad_accumulate_object(param)
accum_grad_obj_sp.register_hook(reduce_grad_hook_sp)

accum_grad_obj.register_hook(reduce_grad_hook)

_define_and_attach(param, reduce_rank)

Expand Down

0 comments on commit 1bc3c33

Please sign in to comment.