Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
0c7f3575
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
0c7f3575
编写于
12月 06, 2022
作者:
L
LiYuRio
提交者:
GitHub
12月 06, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix global gather (#48736)
上级
c5a45cc6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
15 deletion
+18
-15
python/paddle/fluid/tests/unittests/collective/collective_global_gather.py
...id/tests/unittests/collective/collective_global_gather.py
+18
-15
未找到文件。
python/paddle/fluid/tests/unittests/collective/collective_global_gather.py
浏览文件 @
0c7f3575
...
...
@@ -22,7 +22,6 @@ from test_collective_api_base import TestCollectiveAPIRunnerBase, runtime_main
import
paddle
import
paddle.distributed.utils.moe_utils
as
moe_utils
import
paddle.fluid
as
fluid
from
paddle.fluid.framework
import
_enable_legacy_dygraph
paddle
.
enable_static
()
...
...
@@ -61,8 +60,8 @@ class TestCollectiveGlobalGatherAPI(TestCollectiveAPIRunnerBase):
endpoints
=
args
[
"endpoints"
].
split
(
","
)
rank
=
args
[
"trainerid"
]
current_endpoint
=
args
[
"currentendpoint"
]
nranks
=
2
paddle
.
distributed
.
init_parallel_env
()
nranks
=
2
if
args
[
'backend'
]
==
'nccl'
:
device_id
=
int
(
os
.
getenv
(
"FLAGS_selected_gpus"
,
"0"
))
place
=
fluid
.
CUDAPlace
(
...
...
@@ -78,33 +77,37 @@ class TestCollectiveGlobalGatherAPI(TestCollectiveAPIRunnerBase):
n_expert
=
2
world_size
=
2
tot_expert
=
n_expert
*
world_size
paddle
.
disable_static
()
# Call paddle.distributed.alltoall() under legacy dygraph
_enable_legacy_dygraph
()
tmp_main_prog
=
fluid
.
Program
()
with
fluid
.
program_guard
(
tmp_main_prog
,
fluid
.
Program
()):
local_expert_count
=
paddle
.
static
.
data
(
name
=
"local_expert_count"
,
shape
=
[
tot_expert
],
dtype
=
"int64"
)
global_expert_count
=
[]
paddle
.
distributed
.
alltoall
(
paddle
.
split
(
local_expert_count
,
2
,
axis
=
0
),
global_expert_count
)
global_expert_count
=
paddle
.
concat
(
global_expert_count
,
axis
=
0
)
exe
=
fluid
.
Executor
(
place
)
exe
.
run
(
startup_prog
)
np
.
random
.
seed
(
os
.
getpid
())
local_expert_count
=
np
.
random
.
randint
(
1
,
4
,
size
=
tot_expert
).
astype
(
"int64"
)
local_expert_count
=
paddle
.
to_tensor
(
local_expert_count
)
global_expert_count
=
[]
paddle
.
distributed
.
alltoall
(
paddle
.
split
(
local_expert_count
,
2
,
axis
=
0
),
global_expert_count
(
global_expert_count
,)
=
exe
.
run
(
tmp_main_prog
,
feed
=
{
"local_expert_count"
:
local_expert_count
},
fetch_list
=
[
global_expert_count
.
name
],
)
global_expert_count
=
paddle
.
concat
(
global_expert_count
,
axis
=
0
)
global_expert_count
=
global_expert_count
.
numpy
()
local_expert_count
=
local_expert_count
.
numpy
()
fwd_expert_count
=
sum
(
global_expert_count
)
np
.
random
.
seed
(
os
.
getpid
())
local_input_buf
=
np
.
random
.
rand
(
fwd_expert_count
,
in_feat
).
astype
(
"float32"
)
paddle
.
enable_static
()
if
args
[
'static_mode'
]:
result
=
self
.
get_model
(
train_prog
,
startup_prog
,
rank
)
exe
=
fluid
.
Executor
(
place
)
exe
.
run
(
startup_prog
)
fetch_list
=
[]
for
elem
in
result
:
fetch_list
.
append
(
elem
.
name
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录