forked from deepseek-ai/FlashMLA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
62 lines (50 loc) · 1.36 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
import os
from pathlib import Path
from datetime import datetime
import subprocess
from setuptools import setup, find_packages
from torch.utils.cpp_extension import (
BuildExtension,
CUDAExtension,
IS_WINDOWS,
)
def get_sources():
sources = [
"csrc/flash_api.cpp",
]
return sources
def get_ixformer_lib_path():
import ixformer
path = os.path.dirname(ixformer.__file__)
return path
cc_flag = []
cc_flag.append("-gencode")
this_dir = os.path.dirname(os.path.abspath(__file__))
if IS_WINDOWS:
raise NotImplementedError()
else:
cxx_args = ["-O3", "-std=c++17", "-DNDEBUG", "-Wno-deprecated-declarations"]
ext_modules = []
ext_modules.append(
CUDAExtension(
name="flash_mla_cuda",
sources=get_sources(),
extra_compile_args={
"cxx": cxx_args,
"nvcc": []
},
extra_link_args=[f"-L{get_ixformer_lib_path()}", '-lixformer']
)
)
def get_local_version() -> str:
LOCAL_VERSION_IDENTIFIER = os.getenv("LOCAL_VERSION_IDENTIFIER", "")
if LOCAL_VERSION_IDENTIFIER:
LOCAL_VERSION_IDENTIFIER = "+" + LOCAL_VERSION_IDENTIFIER
return LOCAL_VERSION_IDENTIFIER
setup(
name="flash_mla",
version="1.0.0" + get_local_version(),
packages=find_packages(include=['flash_mla']),
ext_modules=ext_modules,
cmdclass={"build_ext": BuildExtension},
)