mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-04-28 03:43:01 +00:00
* Support FP16/BF16 Flash Attention 2 * fix bugs in test_kv_cache_memcpy.py * add context_kv_cache_memcpy_kernel.cu * rm typename MT * add tail process * add high_precision * add high_precision to config.py * rm unused code * change the comment for the high_precision parameter * update test_rotary_embdding_unpad.py * fix vector_copy_utils.h * add comment for self.high_precision when using float32
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
from ..cuda_extension import _CudaExtension
|
|
from ..utils import get_cuda_cc_flag
|
|
|
|
|
|
class InferenceOpsCudaExtension(_CudaExtension):
|
|
def __init__(self):
|
|
super().__init__(name="inference_ops_cuda")
|
|
|
|
def sources_files(self):
|
|
ret = [
|
|
self.csrc_abs_path(fname)
|
|
for fname in [
|
|
"cuda/pybind/inference.cpp",
|
|
"cuda/decode_kv_cache_memcpy_kernel.cu",
|
|
"cuda/context_kv_cache_memcpy_kernel.cu",
|
|
"cuda/fused_rotary_emb_and_cache_kernel.cu",
|
|
"cuda/activation_kernel.cu",
|
|
"cuda/rms_layernorm_kernel.cu",
|
|
]
|
|
]
|
|
return ret
|
|
|
|
def include_dirs(self):
|
|
ret = [self.csrc_abs_path("cuda/include"), self.get_cuda_home_include()]
|
|
return ret
|
|
|
|
def cxx_flags(self):
|
|
version_dependent_macros = ["-DVERSION_GE_1_1", "-DVERSION_GE_1_3", "-DVERSION_GE_1_5"]
|
|
return ["-O3"] + version_dependent_macros
|
|
|
|
def nvcc_flags(self):
|
|
extra_cuda_flags = ["-lineinfo"]
|
|
extra_cuda_flags.extend(get_cuda_cc_flag())
|
|
return ["-O3", "--use_fast_math"] + extra_cuda_flags
|