Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
FastMoE
Commits
184b0404
Commit
184b0404
authored
Feb 08, 2021
by
Sengxian
Browse files
Fix bug in DDP test
parent
5ead59db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
tests/test_numerical.py
tests/test_numerical.py
+8
-8
No files found.
tests/test_numerical.py
View file @
184b0404
...
...
@@ -157,12 +157,12 @@ def test_fmoe(
)
para_array
=
[
torch
.
empty_like
(
para_tensor
)
for
_
in
range
(
world_size
)]
torch
.
distributed
.
all_gather
(
para_array
,
para_tensor
)
para_te
s
nor_gathered
=
torch
.
cat
(
para_array
,
dim
=
0
)
assert
len
(
para_
array
)
==
len
(
moe_raw
.
experts
)
for
expertID
in
range
(
para_te
s
nor_gathered
.
shape
[
0
]):
list
(
moe_raw
.
experts
[
expertID
].
parameters
())[
idx
].
data
=
para_tensor
[
expertID
]
para_ten
s
or_gathered
=
torch
.
cat
(
para_array
,
dim
=
0
)
assert
para_
tensor_gathered
.
shape
[
0
]
==
len
(
moe_raw
.
experts
)
for
expertID
in
range
(
para_ten
s
or_gathered
.
shape
[
0
]):
list
(
moe_raw
.
experts
[
expertID
].
parameters
())[
idx
]
.
data
=
para_tensor_gathered
[
expertID
]
moe_out
,
raw_out
=
_perform_forward
(
moe
,
moe_raw
,
batch_size
,
d_model
,
top_k
)
...
...
@@ -202,10 +202,10 @@ def _run_distributed(func: Callable, args: Dict):
ps
,
n
=
[],
2
os
.
environ
[
"MASTER_ADDR"
]
=
"localhost"
os
.
environ
[
"MASTER_PORT"
]
=
"36666"
os
.
environ
[
"WORLD_SIZE"
]
=
str
(
n
)
os
.
environ
[
"
OMPI_COMM_
WORLD_SIZE"
]
=
str
(
n
)
for
i
in
range
(
n
):
os
.
environ
[
"RANK"
]
=
str
(
i
)
os
.
environ
[
"
OMPI_COMM_WORLD_
RANK"
]
=
str
(
i
)
os
.
environ
[
"CUDA_VISIBLE_DEVICES"
]
=
str
(
i
)
p
=
subprocess
.
Popen
(
[
sys
.
executable
,
__file__
,
func
.
__name__
,
json
.
dumps
(
args
)],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment