Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
54 lines (50 loc) · 1.36 KB
/
Copy pathsetup.py
File metadata and controls
54 lines (50 loc) · 1.36 KB
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
import os
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
from config import kernels
this_dir = os.getcwd()
tk_include_dir = os.path.join(this_dir, 'ThunderKittens', 'include')
tk_prototype_dir = os.path.join(this_dir, 'ThunderKittens', 'prototype')
cuda_flags = [
'-DNDEBUG',
'-Xcompiler=-Wno-psabi',
'-Xcompiler=-fno-strict-aliasing',
'--expt-extended-lambda',
'--expt-relaxed-constexpr',
'-forward-unknown-to-host-compiler',
'--use_fast_math',
'-O3',
'-Xcompiler=-fopenmp',
'-std=c++20',
'-DKITTENS_HOPPER',
'-DTORCH_COMPILE',
'-arch=sm_90a',
f'-I{tk_include_dir}',
f'-I{tk_prototype_dir}',
]
cpp_flags = [
'-std=c++20',
'-O3'
]
source_files = ['bindings.cpp']
for kernel_name in kernels:
kernel_file = f'kernels/{kernel_name}/h100.cu'
if not os.path.exists(kernel_file):
raise FileNotFoundError(f"Kernel file not found: {kernel_file}")
source_files.append(kernel_file)
cpp_flags.append(f'-DCOMPILE_{kernel_name.upper()}')
setup(
name='kp',
ext_modules=[
CUDAExtension(
'kp',
sources=source_files,
extra_compile_args={
'cxx': cpp_flags,
'nvcc': cuda_flags
},
libraries=['cuda']
)
],
cmdclass={'build_ext': BuildExtension},
)