Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
372505be
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
372505be
编写于
9月 22, 2022
作者:
H
Haohongxiang
提交者:
GitHub
9月 22, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Dygraph] Fix bugs of mp in eager mode (#46303) (#46396)
* fix bugs of mp * fix bugs of mp * update * update * fix bug
上级
083853cd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
22 addition
and
3 deletion
+22
-3
paddle/fluid/operators/collective/c_softmax_with_cross_entropy_op.cu
...d/operators/collective/c_softmax_with_cross_entropy_op.cu
+3
-1
python/paddle/distributed/fleet/utils/hybrid_parallel_util.py
...on/paddle/distributed/fleet/utils/hybrid_parallel_util.py
+19
-2
未找到文件。
paddle/fluid/operators/collective/c_softmax_with_cross_entropy_op.cu
浏览文件 @
372505be
...
...
@@ -265,7 +265,7 @@ struct CSoftmaxWithCrossEntropyProcessGroupFunctor<phi::GPUContext, T> {
auto
map
=
distributed
::
ProcessGroupMapFromGid
::
getInstance
();
distributed
::
ProcessGroup
*
pg
=
map
->
get
(
rid
);
distributed
::
AllreduceOptions
opts
;
opts
.
reduce_op
=
distributed
::
ReduceOp
::
SUM
;
opts
.
reduce_op
=
distributed
::
ReduceOp
::
MAX
;
// allocate memory on device.
softmax
->
mutable_data
<
T
>
(
place
);
...
...
@@ -348,6 +348,7 @@ struct CSoftmaxWithCrossEntropyProcessGroupFunctor<phi::GPUContext, T> {
in_out
.
clear
();
in_out
.
push_back
(
predicted_logits
);
opts
.
reduce_op
=
distributed
::
ReduceOp
::
SUM
;
pg
->
AllReduce
(
in_out
,
in_out
,
opts
)
->
Synchronize
();
// step 4, obtain exp(logit)
...
...
@@ -364,6 +365,7 @@ struct CSoftmaxWithCrossEntropyProcessGroupFunctor<phi::GPUContext, T> {
in_out
.
clear
();
in_out
.
push_back
(
sum_exp_logits
);
opts
.
reduce_op
=
distributed
::
ReduceOp
::
SUM
;
pg
->
AllReduce
(
in_out
,
in_out
,
opts
)
->
Synchronize
();
auto
eigen_loss
=
math
::
EigenMatrix
<
T
>::
From
(
loss_2d
);
...
...
python/paddle/distributed/fleet/utils/hybrid_parallel_util.py
浏览文件 @
372505be
...
...
@@ -107,13 +107,26 @@ def _broadcast_data_help(data, shape, dtype, hcg):
group
=
model_parallel_group
,
use_calc_stream
=
True
)
if
mp_rank
!=
0
:
if
in_dygraph_mode
():
data
.
_clear_data
()
input_data
.
_share_buffer_to
(
data
)
else
:
data
.
value
().
get_tensor
().
_clear
()
data
.
value
().
get_tensor
().
_share_data_with
(
input_data
.
value
().
get_tensor
())
def
broadcast_input_data
(
hcg
,
*
inputs
,
**
kwargs
):
cur_device
=
paddle
.
get_device
()
for
v
in
inputs
:
if
isinstance
(
v
,
(
core
.
VarBase
,
core
.
eager
.
Tensor
)):
with
framework
.
no_grad
():
v
=
v
.
cuda
()
if
"gpu"
in
cur_device
else
v
if
"gpu"
in
cur_device
and
in_dygraph_mode
()
\
and
not
v
.
place
.
is_gpu_place
():
v_gpu
=
v
.
cuda
(
int
(
cur_device
.
split
(
":"
)[
1
]))
v
.
_clear_data
()
v_gpu
.
_share_buffer_to
(
v
)
_broadcast_data_help
(
v
,
v
.
shape
,
v
.
dtype
,
hcg
)
else
:
logger
.
error
(
"it doesn't support data type {}"
.
format
(
type
(
v
)))
...
...
@@ -121,7 +134,11 @@ def broadcast_input_data(hcg, *inputs, **kwargs):
for
k
,
v
in
kwargs
.
items
():
if
isinstance
(
v
,
(
core
.
VarBase
,
core
.
eager
.
Tensor
)):
with
framework
.
no_grad
():
v
=
v
.
cuda
()
if
"gpu"
in
cur_device
else
v
if
"gpu"
in
cur_device
and
in_dygraph_mode
()
\
and
not
v
.
place
.
is_gpu_place
():
v_gpu
=
v
.
cuda
(
int
(
cur_device
.
split
(
":"
)[
1
]))
v
.
_clear_data
()
v_gpu
.
_share_buffer_to
(
v
)
_broadcast_data_help
(
v
,
v
.
shape
,
v
.
dtype
,
hcg
)
kwargs
[
k
]
=
v
else
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录