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
43af1522
Commit
43af1522
authored
Mar 13, 2021
by
Rick Ho
Browse files
manually broadcast nccl unique id
parent
4d48209d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
6 deletions
+24
-6
.gitignore
.gitignore
+1
-0
cuda/moe.cpp
cuda/moe.cpp
+16
-2
tests/benchmark_mlp.py
tests/benchmark_mlp.py
+2
-2
tests/test.sh
tests/test.sh
+5
-2
No files found.
.gitignore
View file @
43af1522
...
@@ -10,3 +10,4 @@ a.out
...
@@ -10,3 +10,4 @@ a.out
build
build
*swp
*swp
logs
logs
dist
cuda/moe.cpp
View file @
43af1522
...
@@ -117,15 +117,29 @@ public:
...
@@ -117,15 +117,29 @@ public:
ncclComm_t
getcomm
(
at
::
Device
dev
)
{
ncclComm_t
getcomm
(
at
::
Device
dev
)
{
auto
key
=
std
::
to_string
(
dev
.
index
());
auto
key
=
std
::
to_string
(
dev
.
index
());
#ifdef ENABLE_NCCL_P2P_SUPPORT
#ifdef ENABLE_NCCL_P2P_SUPPORT
auto
v
=
getNCCLComm
(
key
,
{
dev
},
c10d
::
OpType
::
ALLTOALL
);
ncclUniqueId
ncclID
;
int
rank
=
getRank
();
if
(
rank
==
0
)
{
ncclGetUniqueId
(
&
ncclID
);
}
broadcastUniqueNCCLID
(
&
ncclID
,
c10d
::
OpType
::
SEND
,
"fastmoe_nccl_comm"
,
rank
);
ncclComm_t
comm
;
ncclCommInitRank
(
&
comm
,
getSize
(),
ncclID
,
rank
);
return
comm
;
#else
#else
auto
v
=
getNCCLComm
(
key
,
{
dev
});
auto
v
=
getNCCLComm
(
key
,
{
dev
});
#endif
if
(
v
.
size
()
==
0
)
{
if
(
v
.
size
()
==
0
)
{
std
::
cerr
<<
"PyTorch has nothing
\n
"
;
std
::
cerr
<<
"PyTorch has nothing
\n
"
;
return
0
;
return
0
;
}
}
int
count
;
ncclCommCount
(
v
[
0
]
->
getNcclComm
(),
&
count
);
std
::
cerr
<<
"PyTorch has "
<<
v
.
size
()
<<
" comms, comm 0 size "
<<
count
<<
"
\n
"
;
return
v
[
0
]
->
getNcclComm
();
return
v
[
0
]
->
getNcclComm
();
#endif
}
}
};
};
...
...
tests/benchmark_mlp.py
View file @
43af1522
import
torch
import
torch.nn
as
nn
from
fmoe
import
FMoETransformerMLP
from
fmoe
import
FMoETransformerMLP
from
fmoe.gates
import
NaiveGate
from
fmoe.gates
import
NaiveGate
from
moe
import
BruteForceMoELinear
from
moe
import
BruteForceMoELinear
import
torch
import
torch.nn
as
nn
import
time
import
time
import
sys
import
sys
import
os
import
os
...
...
tests/test.sh
View file @
43af1522
...
@@ -25,7 +25,10 @@ PYTHON_VERSION=$($PYTHON_EXEC --version)
...
@@ -25,7 +25,10 @@ PYTHON_VERSION=$($PYTHON_EXEC --version)
PYTHON_REVISION
=
${
PYTHON_VERSION
:7:3
}
PYTHON_REVISION
=
${
PYTHON_VERSION
:7:3
}
SCRIPT_PATH
=
$(
dirname
$(
dirname
$(
realpath
$0
)))
SCRIPT_PATH
=
$(
dirname
$(
dirname
$(
realpath
$0
)))
source
~/scripts/torch.env
export
PYTHONPATH
=
$SCRIPT_PATH
:
$SCRIPT_PATH
/build/lib.linux-x86_64-
$PYTHON_REVISION
:
$PYTHONPATH
export
PYTHONPATH
=
$SCRIPT_PATH
:
$SCRIPT_PATH
/build/lib.linux-x86_64-
$PYTHON_REVISION
:
$PYTHONPATH
export
LD_LIBRARY_PATH
=
/home/laekov/.local/lib/python
$PYTHON_REVISION
/site-packages/torch/lib:
$LD_LIBRARY_PATH
exec
$PYTHON_EXEC
$@
2>logs/
$RANK
.log
core0
=
$(
expr
$OMPI_COMM_WORLD_LOCAL_RANK
\*
4
)
cores
=
$core0
-
$(
expr
$core0
+ 3
)
exec
numactl
-C
$cores
$PYTHON_EXEC
$@
2>logs/
$RANK
.log
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