Skip to content

Commit

Permalink
rm unused lines
Browse files Browse the repository at this point in the history
  • Loading branch information
sljlp committed Jan 7, 2022
1 parent 6ab7dbb commit 76f7556
Showing 1 changed file with 0 additions and 49 deletions.
49 changes: 0 additions & 49 deletions python/paddle/distributed/model/moe/grad_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from paddle.fluid.dygraph import base as imperative_base
from paddle.fluid import core, layers, framework
from paddle.distributed import collective

import six
import warnings
import copy
Expand Down Expand Up @@ -113,7 +112,6 @@ def get_l2_norm_pow(params_grads, sum_dtype=None):
if g.type == core.VarDesc.VarType.SELECTED_ROWS:
merge_grad = layers.merge_selected_rows(g)
merge_grad = layers.get_tensor_from_selected_rows(merge_grad)

sum_square = _squared_l2_norm(merge_grad)
if sum_square.dtype == core.VarDesc.VarType.FP16:
sum_square_list_fp16.append(sum_square)
Expand Down Expand Up @@ -168,8 +166,6 @@ def _dygraph_clip(self, params_grads):

# why to return sum_dtype?
# we will call `get_l2_norm_pow` twice and the precisions may be different.
# For example, the first dtype is float64 while the second is float32
# So we shuold give the first retuned dtype to the second calling to keep a higher precision.
# For convenience and simplification, we use sum_dtype directly instead of global_norm_var_normal.dtype
global_norm_var_normal, sum_dtype \
= self.get_l2_norm_pow(normal_params_grads)
Expand Down Expand Up @@ -216,53 +212,8 @@ def _dygraph_clip(self, params_grads):
if g.dtype == core.VarDesc.VarType.FP16 else clip_var)
new_grad = layers.elementwise_mul(x=g, y=clip_input)
params_and_grads.append((p, new_grad))

return params_and_grads

def _process_context(self, context, param, grad):
if self.group_name not in context:
context[self.group_name] = []
context[self.group_name + "_clip_value"] = self.clip_norm
context[self.group_name + "_clip"] = layers.fill_constant(
shape=[1], dtype=grad.dtype, value=self.clip_norm)
else:
if not self.clip_norm == context[self.group_name + "_clip_value"]:
raise ValueError(
"All parameters' 'clip_norm' of a same group should be the same"
)

merge_grad = grad
if grad.type == core.VarDesc.VarType.SELECTED_ROWS:
merge_grad = layers.merge_selected_rows(grad)
merge_grad = layers.get_tensor_from_selected_rows(merge_grad)

local_norm_var = _squared_l2_norm(merge_grad)
context[self.group_name].append(local_norm_var)

self.context = context

def _create_operators(self, param, grad):
group_scale_name = self.group_name + "_scale"
if group_scale_name not in self.context:
group_norm_var = layers.sums(input=self.context[self.group_name])
group_norm_var = layers.sqrt(x=group_norm_var)
clip_var = self.context[self.group_name + "_clip"]
group_scale_var = layers.elementwise_div(
x=clip_var,
y=layers.elementwise_max(
x=clip_var, y=group_norm_var))
assert group_scale_var.shape == (1, )
self.context[group_scale_name] = group_scale_var

# inplace
param.block.append_op(
type='elementwise_mul',
inputs={'X': grad,
'Y': self.context[group_scale_name]},
outputs={'Out': grad})

return param, grad


ClipGradByGlobalNorm = ClipGradForMOEByGlobalNorm

Expand Down

3 comments on commit 76f7556

@paddle-bot-old
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵️ CI failures summary

🔍 PR: #34 Commit ID: 76f7556 contains failed CI.

🔹 Failed: PR-CI-Coverage

Unknown Failed
2022-01-07 17:22:11 + CURL_OPTS='-s --connect-timeout 600 --retry 10 --retry-delay 10'
2022-01-07 17:22:11 ++ uuid
2022-01-07 17:22:11 ++ curl -s --connect-timeout 600 --retry 10 --retry-delay 10 -u paddle:915eedab953b6f51151f50eb https://xly.bce.baidu.com/ipipe/ipipe-report/uuid
2022-01-07 17:22:11 + UPLOAD_FILE=/tmp/upload-8ca4ff90-bb5f-4162-941e-8ad9063b3d79.tar.gz
2022-01-07 17:22:11 + echo Archiving
2022-01-07 17:22:11 Archiving
2022-01-07 17:22:11 + tar -czvf /tmp/upload-8ca4ff90-bb5f-4162-941e-8ad9063b3d79.tar.gz .
2022-01-07 17:22:11 ./
2022-01-07 17:22:11 + du -hs /tmp/upload-8ca4ff90-bb5f-4162-941e-8ad9063b3d79.tar.gz
2022-01-07 17:22:11 4.0K /tmp/upload-8ca4ff90-bb5f-4162-941e-8ad9063b3d79.tar.gz
2022-01-07 17:22:11 + curl -s --connect-timeout 600 --retry 10 --retry-delay 10 -u paddle:915eedab953b6f51151f50eb -F buildId=10813525 -F path=python-coverage -F file=@/tmp/upload-8ca4ff90-bb5f-4162-941e-8ad9063b3d79.tar.gz https://xly.bce.baidu.com/ipipe/ipipe-report/upload
2022-01-07 17:22:11 + rm -f /tmp/upload-8ca4ff90-bb5f-4162-941e-8ad9063b3d79.tar.gz
2022-01-07 17:22:11 report uploaded
2022-01-07 17:22:11 0
2022-01-07 17:22:11 ipipe_log_param_EXCODE: 0
2022-01-07 17:22:11 Congratulations! Your PR passed the CI.
2022-01-07 17:22:11 + exit 0
2022-01-07 17:22:11 {build code state=0}
2022-01-07 17:22:11 build Paddle success!

@paddle-bot-old
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵️ CI failures summary

🔍 PR: #34 Commit ID: 76f7556 contains failed CI.

🔹 Failed: PR-CI-GpuPS

Unknown Failed
2022-01-07 15:36:59 ipipe_log_param_PR_whl_Size: 125M
2022-01-07 15:36:59 ipipe_log_param_Build_Time: 1137s
2022-01-07 15:36:59 ========================================================
2022-01-07 15:36:59 paddle_build script finished as expected
2022-01-07 15:36:59 + EXCODE=0
2022-01-07 15:36:59 + '[' 0 -eq 0 ']'
2022-01-07 15:36:59 + cd /workspace
2022-01-07 15:36:59 + tar '--use-compress-program=pigz -1' -cpPf build.tar.gz /workspace/Paddle --exclude=/workspace/Paddle/build/paddle --exclude=/workspace/Paddle/build/third_party
2022-01-07 15:37:01 + set +x
2022-01-07 15:37:02 + python BosClient.py build.tar.gz xly-devops/PR/gpubox/38755/76f7556620eb69cc0974275832c88644d1e07ad9
2022-01-07 15:37:41 Upload success!
2022-01-07 15:37:41 + '[' '' == ON ']'
2022-01-07 15:37:41 + [[ 0 -eq 0 ]]
2022-01-07 15:37:41 + echo 'Congratulations! Your PR passed the paddle-build.'
2022-01-07 15:37:41 Congratulations! Your PR passed the paddle-build.
2022-01-07 15:37:41 + set -x
2022-01-07 15:37:41 + exit 0
2022-01-07 15:37:41 {build code state=0}
2022-01-07 15:37:41 build Paddle success!

@paddle-bot-old
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵️ CI failures summary

🔍 PR: #34 Commit ID: 76f7556 contains failed CI.

🔹 Failed: PR-CE-Framework

Unknown Failed
2022-01-07 16:03:00 ============ failed cases =============
2022-01-07 16:03:00 total bugs: 0
2022-01-07 16:03:00 [linalg cases result]
2022-01-07 16:03:00 ============ failed cases =============
2022-01-07 16:03:00 total bugs: 0
2022-01-07 16:03:00 [paddlebase cases result]
2022-01-07 16:03:00 ============ failed cases =============
2022-01-07 16:03:00 total bugs: 0
2022-01-07 16:03:00 [loss cases result]
2022-01-07 16:03:00 ============ failed cases =============
2022-01-07 16:03:00 total bugs: 0
2022-01-07 16:03:00 [nn cases result]
2022-01-07 16:03:00 ============ failed cases =============
2022-01-07 16:03:00 total bugs: 0
2022-01-07 16:03:00 [optimizer cases result]
2022-01-07 16:03:00 ============ failed cases =============
2022-01-07 16:03:00 total bugs: 0
2022-01-07 16:03:00 {build code state=0}
2022-01-07 16:03:00 build Paddle success!

Please sign in to comment.