-
Notifications
You must be signed in to change notification settings - Fork 191
/
setup.py
73 lines (65 loc) · 2.06 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import setuptools
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
import os
import torch
cxx_flags = []
ext_libs = []
authors = [
'Jiaao He',
'Jiezhong Qiu',
'Aohan Zeng',
'Tiago Antunes',
'Jinjun Peng',
'Qin Li',
'Mingshu Zhai'
]
is_rocm_pytorch = False
if torch.__version__ >= '1.5':
from torch.utils.cpp_extension import ROCM_HOME
is_rocm_pytorch = True if ((torch.version.hip is not None) and (ROCM_HOME is not None)) else False
if os.environ.get('USE_NCCL', '1') == '1':
cxx_flags.append('-DFMOE_USE_NCCL')
cxx_flags.append('-DUSE_C10D_NCCL')
if is_rocm_pytorch:
ext_libs.append('rccl')
else:
ext_libs.append('nccl')
if os.environ.get('MOE_DEBUG', '0') == '1':
cxx_flags.append('-DMOE_DEBUG')
if is_rocm_pytorch:
define_macros=[('FMOE_USE_HIP', None)]
else:
define_macros=[]
if __name__ == '__main__':
setuptools.setup(
name='fastmoe',
version='1.1.0',
description='An efficient Mixture-of-Experts system for PyTorch',
author=', '.join(authors),
author_email='hja20@mails.tsinghua.edu.cn',
license='Apache-2',
url='https://github.com/laekov/fastmoe',
packages=['fmoe', 'fmoe.megatron', 'fmoe.gates', 'fmoe.fastermoe'],
ext_modules=[
CUDAExtension(
name='fmoe_cuda',
sources=[
'cuda/stream_manager.cpp',
'cuda/local_exchange.cu',
'cuda/balancing.cu',
'cuda/global_exchange.cpp',
'cuda/parallel_linear.cu',
'cuda/fmoe_cuda.cpp',
'cuda/fastermoe/smart_schedule.cpp',
],
define_macros=define_macros,
extra_compile_args={
'cxx': cxx_flags,
'nvcc': cxx_flags
},
libraries=ext_libs
)
],
cmdclass={
'build_ext': BuildExtension
})