File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed
script/add-custom-nvidia-system Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change 22from utils import *
33import os
44import shutil
5-
5+ import importlib .util
6+ import json
67
78def preprocess (i ):
89
@@ -43,6 +44,26 @@ def postprocess(i):
4344 src_file = os .path .join (tmp_script_path , "dummy_config.py" )
4445
4546 dest_file = os .path .join (target_dir , f"{ mlc_model } .py" )
46- shutil .copy (src_file , dest_file )
47+
48+ dummy_config_path = os .path .join (tmp_script_path , "dummy_config.py" )
49+ spec = importlib .util .spec_from_file_location ("dummy_config" , dummy_config_path )
50+ dummy_module = importlib .util .module_from_spec (spec )
51+ spec .loader .exec_module (dummy_module )
52+
53+ EXPORTS = dummy_module .EXPORTS
54+
55+ # --- Example dynamic insertion ---
56+ if mlc_model == "llama2-70b" :
57+ for k , v in EXPORTS .items ():
58+ if isinstance (v , dict ):
59+ v .setdefault ('llm_fields.llm_gen_config_path' ,
60+ 'code/llama2-70b/tensorrt/generation_config.json' )
61+
62+ # --- Write modified config to destination ---
63+ with open (dest_file , "w" ) as f :
64+ f .write ("# Auto-generated config\n \n " )
65+ f .write ("EXPORTS = " )
66+ f .write (repr (EXPORTS ))
67+ f .write ("\n " )
4768
4869 return {'return' : 0 }
You can’t perform that action at this time.
0 commit comments