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
bb3c8966
Commit
bb3c8966
authored
Apr 26, 2021
by
Rick Ho
Browse files
reconstruct fmoe cuda code
parent
4c90e6e8
Changes
22
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
fmoe/functions.py
fmoe/functions.py
+2
-2
setup.py
setup.py
+6
-6
No files found.
fmoe/functions.py
View file @
bb3c8966
...
@@ -111,7 +111,7 @@ class MOELinear(Function):
...
@@ -111,7 +111,7 @@ class MOELinear(Function):
@
staticmethod
@
staticmethod
def
forward
(
ctx
,
global_input_buf
,
weight
,
fwd_expert_count
):
def
forward
(
ctx
,
global_input_buf
,
weight
,
fwd_expert_count
):
(
global_output_buf
,)
=
fmoe_cuda
.
forward
(
(
global_output_buf
,)
=
fmoe_cuda
.
linear_
forward
(
global_input_buf
,
weight
,
fwd_expert_count
global_input_buf
,
weight
,
fwd_expert_count
)
)
variables
=
(
global_input_buf
,
weight
,
fwd_expert_count
)
variables
=
(
global_input_buf
,
weight
,
fwd_expert_count
)
...
@@ -121,7 +121,7 @@ class MOELinear(Function):
...
@@ -121,7 +121,7 @@ class MOELinear(Function):
@
staticmethod
@
staticmethod
def
backward
(
ctx
,
grad_out
):
def
backward
(
ctx
,
grad_out
):
(
input_buf
,
weight
,
fwd_expert_count
)
=
ctx
.
saved_tensors
(
input_buf
,
weight
,
fwd_expert_count
)
=
ctx
.
saved_tensors
grad_inp_buf
,
grad_weight
=
fmoe_cuda
.
backward
(
grad_inp_buf
,
grad_weight
=
fmoe_cuda
.
linear_
backward
(
grad_out
,
input_buf
,
weight
,
fwd_expert_count
grad_out
,
input_buf
,
weight
,
fwd_expert_count
)
)
return
grad_inp_buf
,
grad_weight
,
None
return
grad_inp_buf
,
grad_weight
,
None
...
...
setup.py
View file @
bb3c8966
...
@@ -7,7 +7,7 @@ cxx_flags = []
...
@@ -7,7 +7,7 @@ cxx_flags = []
ext_libs
=
[]
ext_libs
=
[]
if
os
.
environ
.
get
(
'USE_NCCL'
,
'0'
)
==
'1'
:
if
os
.
environ
.
get
(
'USE_NCCL'
,
'0'
)
==
'1'
:
cxx_flags
.
append
(
'-DMOE_USE_NCCL'
)
cxx_flags
.
append
(
'-D
F
MOE_USE_NCCL'
)
ext_libs
.
append
(
'nccl'
)
ext_libs
.
append
(
'nccl'
)
...
@@ -25,11 +25,11 @@ if __name__ == '__main__':
...
@@ -25,11 +25,11 @@ if __name__ == '__main__':
CUDAExtension
(
CUDAExtension
(
name
=
'fmoe_cuda'
,
name
=
'fmoe_cuda'
,
sources
=
[
sources
=
[
'cuda/
moe
.cpp'
,
'cuda/
stream_manager
.cpp'
,
'cuda/
cuda_stream_m
an
a
ge
r
.c
pp
'
,
'cuda/
local_exch
ange.c
u
'
,
'cuda/
moe_compute_kernel.cu
'
,
'cuda/
global_exchange.cpp
'
,
'cuda/
moe_comm_kernel.cu
'
,
'cuda/
parallel_linear.cpp
'
,
'cuda/moe_
fused_kernel.cu
'
,
'cuda/
f
moe_
cuda.cpp
'
,
],
],
extra_compile_args
=
{
extra_compile_args
=
{
'cxx'
:
cxx_flags
,
'cxx'
:
cxx_flags
,
...
...
Prev
1
2
Next
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