Skip to content

Commit

Permalink
part-2 cherry from: Make FLAGS_force_align_vpp_grad_sum_order default…
Browse files Browse the repository at this point in the history
… to false (PaddlePaddle#54937)

* make FLAGS_force_align_vpp_grad_sum_order default to false

* polish code
  • Loading branch information
sneaxiy authored and wentaoyu committed Nov 28, 2023
1 parent 71fb1a0 commit f457774
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, clip, hcg):
self.not_sharding_stage1 = True
self._vpp_chunk_num = None
self._force_align_vpp_grad_sum_order = distutils.util.strtobool(
os.getenv('FLAGS_force_align_vpp_grad_sum_order', '1')
os.getenv('FLAGS_force_align_vpp_grad_sum_order', '0')
)

def _get_vpp_chunk_num(self, params_grads):
Expand Down Expand Up @@ -220,9 +220,10 @@ def _global_norm(self, global_norm_var_dist, global_norm_var_not_dist):

@no_grad()
def _dygraph_clip(self, params_grads):
chunk_num = self._get_vpp_chunk_num(params_grads)
if chunk_num > 0 and self._force_align_vpp_grad_sum_order:
return self._vpp_dygraph_clip(params_grads, chunk_num)
if self._force_align_vpp_grad_sum_order:
chunk_num = self._get_vpp_chunk_num(params_grads)
if chunk_num > 0:
return self._vpp_dygraph_clip(params_grads, chunk_num)

sum_square_dist_fp16 = []
sum_square_dist_bf16 = []
Expand Down

0 comments on commit f457774

Please sign in to comment.