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
Hide 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):
@
staticmethod
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
)
variables
=
(
global_input_buf
,
weight
,
fwd_expert_count
)
...
...
@@ -121,7 +121,7 @@ class MOELinear(Function):
@
staticmethod
def
backward
(
ctx
,
grad_out
):
(
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
)
return
grad_inp_buf
,
grad_weight
,
None
...
...
setup.py
View file @
bb3c8966
...
...
@@ -7,7 +7,7 @@ cxx_flags = []
ext_libs
=
[]
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'
)
...
...
@@ -25,11 +25,11 @@ if __name__ == '__main__':
CUDAExtension
(
name
=
'fmoe_cuda'
,
sources
=
[
'cuda/
moe
.cpp'
,
'cuda/
cuda_stream_m
an
a
ge
r
.c
pp
'
,
'cuda/
moe_compute_kernel.cu
'
,
'cuda/
moe_comm_kernel.cu
'
,
'cuda/moe_
fused_kernel.cu
'
,
'cuda/
stream_manager
.cpp'
,
'cuda/
local_exch
ange.c
u
'
,
'cuda/
global_exchange.cpp
'
,
'cuda/
parallel_linear.cpp
'
,
'cuda/
f
moe_
cuda.cpp
'
,
],
extra_compile_args
=
{
'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