Skip to content

Commit

Permalink
cherry-pick from (PaddlePaddle#54937
Browse files Browse the repository at this point in the history
Make FLAGS_force_align_vpp_grad_sum_order default 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 7, 2023
1 parent bb7a5bd commit 0b4c357
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,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 @@ -219,9 +219,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 0b4c357

Please sign in to comment.