@@ -109,7 +109,7 @@ def set_npu_envs():
109109 os .environ ["PYTHON_INCLUDE_PATH" ] = get_python_include_path ()
110110 os .environ ["PYTHON_LIB_PATH" ] = get_torch_root_path ()
111111 os .environ ["LIBTORCH_ROOT" ] = get_torch_root_path ()
112-
112+ os . environ [ "INSTALL_XLLM_KERNELS" ] = "ON" if install_kernels else "OFF"
113113 NPU_TOOLKIT_HOME = os .getenv ("NPU_TOOLKIT_HOME" )
114114 if not NPU_TOOLKIT_HOME :
115115 os .environ ["NPU_TOOLKIT_HOME" ] = "/usr/local/Ascend/ascend-toolkit/latest"
@@ -204,13 +204,15 @@ class ExtBuild(build_ext):
204204 ("base-dir=" , None , "base directory of xLLM project" ),
205205 ("device=" , None , "target device type (a3 or a2 or mlu)" ),
206206 ("arch=" , None , "target arch type (x86 or arm)" ),
207+ ("install-xllm-kernels=" , None , "install xllm_kernels RPM package (true/false)" ),
207208 ]
208209
209210 def initialize_options (self ):
210211 build_ext .initialize_options (self )
211212 self .base_dir = get_base_dir ()
212213 self .device = "a2"
213214 self .arch = "x86"
215+ self .install_xllm_kernels = "true"
214216
215217 def finalize_options (self ):
216218 build_ext .finalize_options (self )
@@ -278,6 +280,7 @@ def build_extension(self, ext: CMakeExtension):
278280 f"-DBUILD_SHARED_LIBS=OFF" ,
279281 f"-DDEVICE_TYPE=USE_{ self .device .upper ()} " ,
280282 f"-DDEVICE_ARCH={ self .arch .upper ()} " ,
283+ f"-DINSTALL_XLLM_KERNELS={ 'ON' if self .install_xllm_kernels else 'OFF' } " ,
281284 ]
282285
283286 if self .device == "a2" or self .device == "a3" :
@@ -346,6 +349,7 @@ def initialize_options(self):
346349 super ().initialize_options ()
347350 self .device = None
348351 self .arch = None
352+ self .install_xllm_kernels = "true"
349353
350354 def finalize_options (self ):
351355 super ().finalize_options ()
@@ -512,6 +516,7 @@ def apply_patch():
512516if __name__ == "__main__" :
513517 device = 'a2' # default
514518 arch = "x86" # default
519+ install_kernels = True
515520 if '--device' in sys .argv :
516521 idx = sys .argv .index ('--device' )
517522 if idx + 1 < len (sys .argv ):
@@ -536,7 +541,19 @@ def apply_patch():
536541 apply_patch ()
537542 else :
538543 sys .argv .remove ("--dry_run" )
539-
544+ if '--install-xllm-kernels' in sys .argv :
545+ idx = sys .argv .index ('--install-xllm-kernels' )
546+ if idx + 1 < len (sys .argv ):
547+ install_kernels = sys .argv [idx + 1 ].lower ()
548+ if install_kernels in ('true' , '1' , 'yes' , 'y' , 'on' ):
549+ install_kernels = True
550+ elif install_kernels in ('false' , '0' , 'no' , 'n' , 'off' ):
551+ install_kernels = False
552+ else :
553+ print ("Error: --install-xllm-kernels must be true or false" )
554+ sys .exit (1 )
555+ sys .argv .pop (idx )
556+ sys .argv .pop (idx )
540557
541558 version = get_version ()
542559
@@ -577,7 +594,12 @@ def apply_patch():
577594 cmdclass = {"build_ext" : ExtBuild ,
578595 "test" : TestUT ,
579596 'bdist_wheel' : BuildDistWheel },
580- options = {'build_ext' : {'device' : device ,'arch' : arch }},
597+ options = {'build_ext' : {
598+ 'device' : device ,
599+ 'arch' : arch ,
600+ 'install_xllm_kernels' : install_kernels if install_kernels is not None else "false"
601+ }
602+ },
581603 zip_safe = False ,
582604 py_modules = ["xllm/launch_xllm" , "xllm/__init__" ,
583605 "xllm/pybind/llm" , "xllm/pybind/args" ],
0 commit comments