/
githubmirror
/
ColossalAI
Обзор
Документация
Войти
/
githubmirror
/
ColossalAI
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v0.3.4
op_builder/smoothquant.py
52 строки
2 KB
Xu Kai
[inference] Add smmoothquant for llama (#4904)
16 окт 2023, 06:28
Не верифицирован
16 окт 2023, 06:28
611a5a8
Код
Авторство
О чём код?
import torch from .builder import Builder from .utils import append_nvcc_threads class SmoothquantBuilder(Builder): NAME = "cu_smoothquant" PREBUILT_IMPORT_PATH = "colossalai._C.cu_smoothquant" def __init__(self): super().__init__(name=SmoothquantBuilder.NAME, prebuilt_import_path=SmoothquantBuilder.PREBUILT_IMPORT_PATH) def include_dirs(self): ret = [self.csrc_abs_path("smoothquant"), self.get_cuda_home_include()] return ret def sources_files(self): ret = [ self.csrc_abs_path(fname) for fname in [ "smoothquant/binding.cpp", "smoothquant/linear.cu", ] ] return ret def cxx_flags(self): return ["-O3"] + self.version_dependent_macros def nvcc_flags(self): compute_capability = torch.cuda.get_device_capability() cuda_arch = compute_capability[0] * 100 + compute_capability[1] * 10 extra_cuda_flags = [ "-v", f"-DCUDA_ARCH={cuda_arch}", "-std=c++17", "-U__CUDA_NO_HALF_OPERATORS__", "-U__CUDA_NO_HALF_CONVERSIONS__", "-U__CUDA_NO_HALF2_OPERATORS__", "-DTHRUST_IGNORE_CUB_VERSION_CHECK", ] ret = ["-O3", "--use_fast_math"] + self.version_dependent_macros + extra_cuda_flags return append_nvcc_threads(ret) def builder(self): try: super().builder() except: warnings.warn("build smoothquant lib not successful")