@@ -35,6 +35,9 @@ def parse_args():
3535 parser .add_argument ("-t" , "--num_threads" ,
3636 type = int , default = 1 ,
3737 help = "number of threads to use per process" )
38+ parser .add_argument ("--mp" ,
39+ type = str , default = "local" ,
40+ help = "memory placement policy, 'local','interleave' or 'none'" )
3841 return parser .parse_args ()
3942
4043
@@ -115,21 +118,40 @@ def main():
115118 logs_dir = os .path .join ("/tmp" , str (uuid .uuid4 ()))
116119 os .mkdir (logs_dir )
117120 current_subprocesses = list ()
121+ if args .mp == "local" :
122+ mem_place = "--localalloc"
123+ elif args .mp == "interleave" :
124+ mem_place = "--interleave=all"
125+ else :
126+ mem_place = "none"
127+
118128 for n in range (args .num_processes ):
119129 logfile = f"{ logs_dir } /log_{ n } "
120130 if os .path .exists ("/llm/batched-bench" ):
121131 # command-line for v1
122- cmd = ["numactl" , f"--physcpubind={ gen_threads_config (args .num_threads , n )} " , "--localalloc" ,
123- "/llm/batched-bench" , args .model , str (args .kv_cache ), "2048" , "512" , "0" , "0" , "0" , str (args .prompt_size ), str (TOKENS ),
124- str (args .batch_size ), str (args .num_threads )]
132+ if mem_place == "none" :
133+ cmd = ["numactl" , f"--physcpubind={ gen_threads_config (args .num_threads , n )} " ,
134+ "/llm/batched-bench" , args .model , str (args .kv_cache ), "2048" , "512" , "0" , "0" , "0" , str (args .prompt_size ), str (TOKENS ),
135+ str (args .batch_size ), str (args .num_threads )]
136+ else :
137+ cmd = ["numactl" , f"--physcpubind={ gen_threads_config (args .num_threads , n )} " , str (mem_place ),
138+ "/llm/batched-bench" , args .model , str (args .kv_cache ), "2048" , "512" , "0" , "0" , "0" , str (args .prompt_size ), str (TOKENS ),
139+ str (args .batch_size ), str (args .num_threads )]
125140 elif os .path .exists ("/llm/llama-batched-bench" ):
126141 # command-line for v2
127- cmd = ["numactl" , f"--physcpubind={ gen_threads_config (args .num_threads , n )} " , "--localalloc" ,
128- "/llm/llama-batched-bench" , "-m" , args .model , "-c" , str (args .kv_cache ), "-b" , "2048" , "-ub" , "512" , "-npp" , str (args .prompt_size ), "-ntg" , str (TOKENS ),
129- "-npl" , str (args .batch_size ), "-t" , str (args .num_threads ), "-tb" , str (args .num_threads ), "-td" , str (args .num_threads )]
142+ if mem_place == "none" :
143+ cmd = ["numactl" , f"--physcpubind={ gen_threads_config (args .num_threads , n )} " ,
144+ "/llm/llama-batched-bench" , "-m" , args .model , "-c" , str (args .kv_cache ), "-b" , "2048" , "-ub" , "512" , "-npp" , str (args .prompt_size ), "-ntg" , str (TOKENS ),
145+ "-npl" , str (args .batch_size ), "-t" , str (args .num_threads ), "-tb" , str (args .num_threads ), "-td" , str (args .num_threads )]
146+ else :
147+ cmd = ["numactl" , f"--physcpubind={ gen_threads_config (args .num_threads , n )} " ,str (mem_place ),
148+ "/llm/llama-batched-bench" , "-m" , args .model , "-c" , str (args .kv_cache ), "-b" , "2048" , "-ub" , "512" , "-npp" , str (args .prompt_size ), "-ntg" , str (TOKENS ),
149+ "-npl" , str (args .batch_size ), "-t" , str (args .num_threads ), "-tb" , str (args .num_threads ), "-td" , str (args .num_threads )]
150+
130151 else :
131152 print ("FAIL: batched-bench not found!" )
132153 sys .exit (1 )
154+
133155 current_subprocesses .append (
134156 subprocess .Popen (cmd , stdout = open (logfile , 'wb' ), stderr = open (logfile , 'wb' )))
135157 start = time .time ()
0 commit comments