@@ -20,7 +20,7 @@ def to_int(x):
2020 rows .append (row )
2121
2222# normalize numeric fields
23- num_fields = ["cl " ,"pp" ,"tg" ,"threads" ,"ttft_ms" ,"prefill_ms" ,"decode_ms" ,"decode_ms_per_tok" ,"peak_rss_kb" ,"kv_est_kb" ]
23+ num_fields = ["ctx_len " ,"pp" ,"tg" ,"threads" ,"ttft_ms" ,"prefill_ms" ,"decode_ms" ,"decode_ms_per_tok" ,"peak_rss_kb" ,"kv_est_kb" ]
2424for row in rows :
2525 for k in num_fields :
2626 if k in row :
@@ -29,13 +29,13 @@ def to_int(x):
2929# write summary
3030stamp = os .path .splitext (os .path .basename (csv_path ))[0 ]
3131summary_path = os .path .join (out_dir , f"{ stamp } .summary.csv" )
32- fieldnames = ["ts" ,"git" ,"arch" ,"model" ,"mode" ,"cl " ,"pp" ,"tg" ,"threads" ,
32+ fieldnames = ["ts" ,"git" ,"arch" ,"model" ,"mode" ,"ctx_len " ,"pp" ,"tg" ,"threads" ,
3333 "ttft_ms" ,"prefill_ms" ,"decode_ms" ,"decode_ms_per_tok" ,
3434 "peak_rss_kb" ,"kv_est_kb" ,"peak_rss_gb" ,"kv_est_mb" ]
3535with open (summary_path , "w" , newline = "" ) as f :
3636 w = csv .DictWriter (f , fieldnames = fieldnames )
3737 w .writeheader ()
38- for row in sorted (rows , key = lambda x : (x .get ("mode" ,"" ), x .get ("cl " ,0 ))):
38+ for row in sorted (rows , key = lambda x : (x .get ("mode" ,"" ), x .get ("ctx_len " ,0 ))):
3939 peak_rss_kb = row .get ("peak_rss_kb" , float ("nan" ))
4040 kv_est_kb = row .get ("kv_est_kb" , float ("nan" ))
4141 out = {k : row .get (k , "" ) for k in fieldnames }
@@ -67,32 +67,32 @@ def plot_mode(mode, xkey, ykey, ylabel, fname):
6767 plt .savefig (os .path .join (out_dir , fname ), dpi = 180 )
6868 plt .close ()
6969
70- plot_mode ("prefill_ttft" , "cl " , "ttft_ms" , "TTFT (ms)" , f"{ stamp } .prefill_ttft.ttft_ms.png" )
71- plot_mode ("prefill_ttft" , "cl " , "prefill_ms" , "Prefill latency (ms)" , f"{ stamp } .prefill_ttft.prefill_ms.png" )
72- plot_mode ("decode_heavy" , "cl " , "decode_ms_per_tok" , "Decode latency per token (ms)" , f"{ stamp } .decode_heavy.decode_ms_per_tok.png" )
73- plot_mode ("decode_heavy" , "cl " , "decode_ms" , "Decode latency total (ms)" , f"{ stamp } .decode_heavy.decode_ms.png" )
70+ plot_mode ("prefill_ttft" , "ctx_len " , "ttft_ms" , "TTFT (ms)" , f"{ stamp } .prefill_ttft.ttft_ms.png" )
71+ plot_mode ("prefill_ttft" , "ctx_len " , "prefill_ms" , "Prefill latency (ms)" , f"{ stamp } .prefill_ttft.prefill_ms.png" )
72+ plot_mode ("decode_heavy" , "ctx_len " , "decode_ms_per_tok" , "Decode latency per token (ms)" , f"{ stamp } .decode_heavy.decode_ms_per_tok.png" )
73+ plot_mode ("decode_heavy" , "ctx_len " , "decode_ms" , "Decode latency total (ms)" , f"{ stamp } .decode_heavy.decode_ms.png" )
7474
7575# memory plots
7676mem = {}
7777for row in rows :
78- cl = row .get ("cl " , float ("nan" ))
79- if cl != cl :
78+ ctx_len = row .get ("ctx_len " , float ("nan" ))
79+ if ctx_len != ctx_len :
8080 continue
81- cl = int (cl )
81+ ctx_len = int (ctx_len )
8282 peak = row .get ("peak_rss_kb" , float ("nan" ))
8383 kv = row .get ("kv_est_kb" , float ("nan" ))
84- cur = mem .get (cl , {"peak" : float ("nan" ), "kv" : float ("nan" )})
84+ cur = mem .get (ctx_len , {"peak" : float ("nan" ), "kv" : float ("nan" )})
8585 if peak == peak and (cur ["peak" ]!= cur ["peak" ] or peak > cur ["peak" ]): cur ["peak" ]= peak
8686 if kv == kv and (cur ["kv" ]!= cur ["kv" ] or kv > cur ["kv" ]): cur ["kv" ]= kv
87- mem [cl ]= cur
87+ mem [ctx_len ]= cur
8888
89- cls = sorted (mem .keys ())
90- peak_gb = [(mem [c ]["peak" ]/ (1024 * 1024 )) if mem [c ]["peak" ]== mem [c ]["peak" ] else float ("nan" ) for c in cls ]
91- kv_mb = [(mem [c ]["kv" ]/ 1024 ) if mem [c ]["kv" ]== mem [c ]["kv" ] else float ("nan" ) for c in cls ]
89+ ctx_lens = sorted (mem .keys ())
90+ peak_gb = [(mem [c ]["peak" ]/ (1024 * 1024 )) if mem [c ]["peak" ]== mem [c ]["peak" ] else float ("nan" ) for c in ctx_lens ]
91+ kv_mb = [(mem [c ]["kv" ]/ 1024 ) if mem [c ]["kv" ]== mem [c ]["kv" ] else float ("nan" ) for c in ctx_lens ]
9292
9393plt .figure ()
94- plt .plot (cls , peak_gb , marker = "o" )
95- plt .xlabel ("cl " )
94+ plt .plot (ctx_lens , peak_gb , marker = "o" )
95+ plt .xlabel ("ctx_len " )
9696plt .ylabel ("Peak RSS (GB)" )
9797plt .xscale ("log" , base = 2 )
9898plt .grid (True , which = "both" , linestyle = "--" , linewidth = 0.5 )
@@ -101,8 +101,8 @@ def plot_mode(mode, xkey, ykey, ylabel, fname):
101101plt .close ()
102102
103103plt .figure ()
104- plt .plot (cls , kv_mb , marker = "o" )
105- plt .xlabel ("cl " )
104+ plt .plot (ctx_lens , kv_mb , marker = "o" )
105+ plt .xlabel ("ctx_len " )
106106plt .ylabel ("KV estimate (MB)" )
107107plt .xscale ("log" , base = 2 )
108108plt .grid (True , which = "both" , linestyle = "--" , linewidth = 0.5 )
0 commit comments