mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2026-07-13 20:39:59 +00:00
* feat flash decoding for paged attention * refactor flashdecodingattention * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
37 lines
1.2 KiB
Python
37 lines
1.2 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",
|
|
"cuda/get_cos_and_sin_kernel.cu",
|
|
"cuda/flash_decoding_attention_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
|