66import hashlib
77from distutils .sysconfig import get_python_lib
88from . import utils
9+ from .utils .tools import flagtree_configs as configs
910
10- extend_backends = []
11- default_backends = ["nvidia" , "amd" ]
12- plugin_backends = ["cambricon" , "ascend" , "aipu" , "tsingmicro" , "enflame" ]
13- ext_sourcedir = "triton/_C/"
14- flagtree_backend = os .getenv ("FLAGTREE_BACKEND" , "" ).lower ()
15- flagtree_plugin = os .getenv ("FLAGTREE_PLUGIN" , "" ).lower ()
16- offline_build = os .getenv ("FLAGTREE_PLUGIN" , "OFF" )
17- device_mapping = {"xpu" : "xpu" , "mthreads" : "musa" , "ascend" : "ascend" }
18- activated_module = utils .activate (flagtree_backend )
1911downloader = utils .tools .DownloadManager ()
12+ configs = configs
13+ flagtree_backend = configs .flagtree_backend
2014
2115set_llvm_env = lambda path : set_env ({
2216 'LLVM_INCLUDE_DIRS' : Path (path ) / "include" ,
2721
2822def install_extension (* args , ** kargs ):
2923 try :
30- activated_module .install_extension (* args , ** kargs )
24+ configs . activated_module .install_extension (* args , ** kargs )
3125 except Exception :
3226 pass
3327
3428
3529def get_backend_cmake_args (* args , ** kargs ):
3630 try :
37- return activated_module .get_backend_cmake_args (* args , ** kargs )
31+ return configs . activated_module .get_backend_cmake_args (* args , ** kargs )
3832 except Exception :
3933 return []
4034
4135
4236def get_device_name ():
43- return device_mapping [flagtree_backend ]
37+ return configs . device_alias [flagtree_backend ]
4438
4539
4640def get_extra_packages ():
4741 packages = []
4842 try :
49- packages = activated_module .get_extra_install_packages ()
43+ packages = configs . activated_module .get_extra_install_packages ()
5044 except Exception :
5145 packages = []
5246 return packages
@@ -55,7 +49,7 @@ def get_extra_packages():
5549def get_package_data_tools ():
5650 package_data = ["compile.h" , "compile.c" ]
5751 try :
58- package_data += activated_module .get_package_data_tools ()
52+ package_data += configs . activated_module .get_package_data_tools ()
5953 except Exception :
6054 package_data
6155 return package_data
@@ -81,15 +75,15 @@ def download_flagtree_third_party(name, condition, required=False, hock=None):
8175 submodule = utils .flagtree_submodules [name ]
8276 downloader .download (module = submodule , required = required )
8377 if callable (hock ):
84- hock (third_party_base_dir = utils .flagtree_submodule_dir , backend = submodule ,
85- default_backends = default_backends )
78+ configs . default_backends = hock (third_party_base_dir = configs .flagtree_submodule_dir , backend = submodule ,
79+ default_backends = configs . default_backends )
8680 else :
8781 print (f"\033 [1;33m[Note] Skip downloading { name } since USE_{ name .upper ()} is set to OFF\033 [0m" )
8882
8983
9084def post_install ():
9185 try :
92- activated_module .post_install ()
86+ configs . activated_module .post_install ()
9387 except Exception :
9488 pass
9589
@@ -250,14 +244,14 @@ def skip_package_dir(package):
250244 if 'backends' in package or 'profiler' in package :
251245 return True
252246 try :
253- return activated_module .skip_package_dir (package )
247+ return configs . activated_module .skip_package_dir (package )
254248 except Exception :
255249 return False
256250
257251 @staticmethod
258252 def get_package_dir (packages ):
259253 package_dict = {}
260- if flagtree_backend and flagtree_backend not in plugin_backends :
254+ if flagtree_backend and flagtree_backend not in configs . plugin_backends :
261255 connection = []
262256 backend_triton_path = f"../third_party/{ flagtree_backend } /python/"
263257 for package in packages :
@@ -267,7 +261,7 @@ def get_package_dir(packages):
267261 connection .append (pair )
268262 package_dict .update (connection )
269263 try :
270- package_dict .update (activated_module .get_package_dir ())
264+ package_dict .update (configs . activated_module .get_package_dir ())
271265 except Exception :
272266 pass
273267 return package_dict
@@ -277,8 +271,8 @@ def handle_flagtree_backend():
277271 global ext_sourcedir
278272 if flagtree_backend :
279273 print (f"\033 [1;32m[INFO] FlagtreeBackend is { flagtree_backend } \033 [0m" )
280- extend_backends .append (flagtree_backend )
281- if "editable_wheel" in sys .argv and flagtree_backend not in plugin_backends :
274+ configs . extend_backends .append (flagtree_backend )
275+ if "editable_wheel" in sys .argv and flagtree_backend not in configs . plugin_backends :
282276 ext_sourcedir = os .path .abspath (f"../third_party/{ flagtree_backend } /python/{ ext_sourcedir } " ) + "/"
283277
284278
@@ -337,7 +331,7 @@ def uninstall_triton():
337331)
338332
339333cache .store (
340- file = "iluvatarTritonPlugin.so" , condition = ("iluvatar" == flagtree_backend ) and (not flagtree_plugin ), url =
334+ file = "iluvatarTritonPlugin.so" , condition = ("iluvatar" == flagtree_backend ) and (not configs . flagtree_plugin ), url =
341335 "https://baai-cp-web.ks3-cn-beijing.ksyuncs.com/trans/iluvatarTritonPlugin-cpython3.10-glibc2.30-glibcxx3.4.28-cxxabi1.3.12-ubuntu-x86_64_v0.3.0.tar.gz" ,
342336 copy_dst_path = f"third_party/{ flagtree_backend } " , md5_digest = "015b9af8" )
343337
@@ -376,7 +370,7 @@ def uninstall_triton():
376370)
377371
378372cache .store (
379- file = "mthreadsTritonPlugin.so" , condition = ("mthreads" == flagtree_backend ) and (not flagtree_plugin ), url =
373+ file = "mthreadsTritonPlugin.so" , condition = ("mthreads" == flagtree_backend ) and (not configs . flagtree_plugin ), url =
380374 "https://baai-cp-web.ks3-cn-beijing.ksyuncs.com/trans/mthreadsTritonPlugin-cpython3.10-glibc2.35-glibcxx3.4.30-cxxabi1.3.13-ubuntu-x86_64_v0.3.0.tar.gz" ,
381375 copy_dst_path = f"third_party/{ flagtree_backend } " , md5_digest = "2a9ca0b8" )
382376
0 commit comments