99import importlib .util
1010import importlib .metadata
1111from typing import List , Tuple
12+ from .utils .tools import flagtree_configs as configs
1213
13- extend_backends = []
14- default_backends = ["nvidia" , "amd" ]
15- plugin_backends = ["cambricon" , "ascend" , "aipu" , "tsingmicro" ]
16- ext_sourcedir = "triton/_C/"
17- flagtree_backend = os .getenv ("FLAGTREE_BACKEND" , "" ).lower ()
18- flagtree_plugin = os .getenv ("FLAGTREE_PLUGIN" , "" ).lower ()
19- offline_build = os .getenv ("FLAGTREE_PLUGIN" , "OFF" )
20- device_mapping = {"xpu" : "xpu" , "mthreads" : "musa" , "ascend" : "ascend" }
21- activated_module = utils .activate (flagtree_backend )
2214downloader = utils .tools .DownloadManager ()
15+ configs = configs
16+ flagtree_backend = configs .flagtree_backend
2317
2418set_llvm_env = lambda path : set_env (
2519 {
3327
3428def install_extension (* args , ** kargs ):
3529 try :
36- activated_module .install_extension (* args , ** kargs )
30+ configs . activated_module .install_extension (* args , ** kargs )
3731 except Exception :
3832 pass
3933
4034
4135def get_backend_cmake_args (* args , ** kargs ):
4236 try :
43- return activated_module .get_backend_cmake_args (* args , ** kargs )
37+ return configs . activated_module .get_backend_cmake_args (* args , ** kargs )
4438 except Exception :
4539 return []
4640
4741
4842def get_device_name ():
49- return device_mapping [flagtree_backend ]
43+ return configs . device_alias_map [flagtree_backend ]
5044
5145
5246def get_extra_packages ():
5347 packages = []
5448 try :
55- packages = activated_module .get_extra_install_packages ()
49+ packages = configs . activated_module .get_extra_install_packages ()
5650 except Exception :
5751 packages = []
5852 return packages
@@ -61,7 +55,7 @@ def get_extra_packages():
6155def get_package_data_tools ():
6256 package_data = ["compile.h" , "compile.c" ]
6357 try :
64- package_data += activated_module .get_package_data_tools ()
58+ package_data += configs . activated_module .get_package_data_tools ()
6559 except Exception :
6660 package_data
6761 return package_data
@@ -88,15 +82,15 @@ def download_flagtree_third_party(name, condition, required=False, hock=None):
8882 downloader .download (module = submodule , required = required )
8983 if callable (hock ):
9084 hock (third_party_base_dir = utils .flagtree_submodule_dir , backend = submodule ,
91- default_backends = default_backends )
85+ default_backends = configs . default_backends )
9286
9387 else :
9488 print (f"\033 [1;33m[Note] Skip downloading { name } since USE_{ name .upper ()} is set to OFF\033 [0m" )
9589
9690
9791def post_install ():
9892 try :
99- activated_module .post_install ()
93+ configs . activated_module .post_install ()
10094 except Exception :
10195 pass
10296
@@ -323,14 +317,14 @@ def skip_package_dir(package):
323317 if 'backends' in package or 'profiler' in package :
324318 return True
325319 try :
326- return activated_module .skip_package_dir (package )
320+ return configs . activated_module .skip_package_dir (package )
327321 except Exception :
328322 return False
329323
330324 @staticmethod
331325 def get_package_dir (packages ):
332326 package_dict = {}
333- if flagtree_backend and flagtree_backend not in plugin_backends :
327+ if flagtree_backend and flagtree_backend not in configs . plugin_backends :
334328 connection = []
335329 backend_triton_path = f"../third_party/{ flagtree_backend } /python/"
336330 for package in packages :
@@ -340,7 +334,7 @@ def get_package_dir(packages):
340334 connection .append (pair )
341335 package_dict .update (connection )
342336 try :
343- package_dict .update (activated_module .get_package_dir ())
337+ package_dict .update (configs . activated_module .get_package_dir ())
344338 except Exception :
345339 pass
346340 return package_dict
@@ -350,8 +344,8 @@ def handle_flagtree_backend():
350344 global ext_sourcedir
351345 if flagtree_backend :
352346 print (f"\033 [1;32m[INFO] FlagtreeBackend is { flagtree_backend } \033 [0m" )
353- extend_backends .append (flagtree_backend )
354- if "editable_wheel" in sys .argv and flagtree_backend not in plugin_backends :
347+ configs . extend_backends .append (flagtree_backend )
348+ if "editable_wheel" in sys .argv and flagtree_backend not in configs . plugin_backends :
355349 ext_sourcedir = os .path .abspath (f"../third_party/{ flagtree_backend } /python/{ ext_sourcedir } " ) + "/"
356350
357351
@@ -410,7 +404,7 @@ def uninstall_triton():
410404)
411405
412406cache .store (
413- file = "iluvatarTritonPlugin.so" , condition = ("iluvatar" == flagtree_backend ) and (not flagtree_plugin ), url =
407+ file = "iluvatarTritonPlugin.so" , condition = ("iluvatar" == flagtree_backend ) and (not configs . flagtree_plugin ), url =
414408 "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" ,
415409 copy_dst_path = f"third_party/{ flagtree_backend } " , md5_digest = "015b9af8" )
416410
@@ -449,7 +443,7 @@ def uninstall_triton():
449443)
450444
451445cache .store (
452- file = "mthreadsTritonPlugin.so" , condition = ("mthreads" == flagtree_backend ) and (not flagtree_plugin ), url =
446+ file = "mthreadsTritonPlugin.so" , condition = ("mthreads" == flagtree_backend ) and (not configs . flagtree_plugin ), url =
453447 "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" ,
454448 copy_dst_path = f"third_party/{ flagtree_backend } " , md5_digest = "2a9ca0b8" )
455449
0 commit comments