fused_lamb.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. """
  2. Copyright 2020 The Microsoft DeepSpeed Team
  3. """
  4. from .builder import CUDAOpBuilder
  5. import sys
  6. class FusedLambBuilder(CUDAOpBuilder):
  7. BUILD_VAR = 'DS_BUILD_FUSED_LAMB'
  8. NAME = "fused_lamb"
  9. def __init__(self):
  10. super().__init__(name=self.NAME)
  11. def absolute_name(self):
  12. return f'deepspeed.ops.lamb.{self.NAME}_op'
  13. def sources(self):
  14. return ['csrc/lamb/fused_lamb_cuda.cpp', 'csrc/lamb/fused_lamb_cuda_kernel.cu']
  15. def include_paths(self):
  16. return ['csrc/includes']
  17. def cxx_args(self):
  18. args = super().cxx_args()
  19. return args + self.version_dependent_macros()
  20. def nvcc_args(self):
  21. nvcc_flags = ['-O3'] + self.version_dependent_macros()
  22. if self.is_rocm_pytorch():
  23. ROCM_MAJOR, ROCM_MINOR = self.installed_rocm_version()
  24. nvcc_flags += [
  25. '-DROCM_VERSION_MAJOR=%s' % ROCM_MAJOR,
  26. '-DROCM_VERSION_MINOR=%s' % ROCM_MINOR
  27. ]
  28. else:
  29. nvcc_flags.extend([
  30. '-allow-unsupported-compiler' if sys.platform == "win32" else '',
  31. '-lineinfo',
  32. '--use_fast_math'
  33. ] + self.compute_capability_args())
  34. return nvcc_flags