okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
ef8071303
main
1#!/usr/bin/env python3 2"""bench_report.py — community-report battery for the V100+P100 helper rig. 3 4Fresh salted prompts (no prefix reuse), output cap 256 tokens, greedy, 5reasoning_effort none (matches other community reports), streaming TTFT. 6Sizes: ~550 / ~13.5K / ~33K x3 runs; ~90K x1 (single run, marked). 7Saves per-run results to /root/benchpr-results.json and prints them. 8""" 9import json ,sys ,time ,urllib .request 10 11BASE = "http://127.0.0.1:8082" 12OUT = "/root/benchpr-results.json" 13unit = "The following is a technical report excerpt that must be summarized. " 14 15TASK = ("\n\nTask: using general knowledge (the excerpt above is filler), explain in " 16"about 220 words how TCP congestion control works, covering slow start, congestion " 17"avoidance, fast retransmit and fast recovery, with rough numbers. Plain text." ) 18 19def run (tag ,rep ,n = 256 ,timeout = 2400 ): 20salt = f"[ { tag } - { time . time_ns () } ] " 21prompt = salt + unit * rep + TASK 22body = json .dumps ({ 23"model" :"q" , 24"messages" : [{"role" :"user" ,"content" :prompt }], 25"max_tokens" :n ,"temperature" :0 ,"stream" :True , 26"reasoning_effort" :"none" , 27 }).encode () 28req = urllib .request .Request (BASE + "/v1/chat/completions" ,data = body , 29headers = {"Content-Type" :"application/json" }) 30t0 = time .time () 31ttft = None 32content = "" 33timings = None 34usage = None 35with urllib .request .urlopen (req ,timeout = timeout )as r : 36for raw in r : 37line = raw .decode ("utf-8" ,"ignore" ).strip () 38if not line .startswith ("data:" ): 39continue 40payload = line [5 :].strip () 41if payload == "[DONE]" : 42break 43try : 44d = json .loads (payload ) 45except Exception : 46continue 47ch = d .get ("choices" )or [] 48if ch : 49delta = ch [0 ].get ("delta" )or {} 50txt = delta .get ("content" ) 51if txt : 52if ttft is None : 53ttft = time .time ()- t0 54content += txt 55if d .get ("timings" ): 56timings = d ["timings" ] 57if d .get ("usage" ): 58usage = d ["usage" ] 59wall = time .time ()- t0 60res = { 61"tag" :tag ,"rep" :rep , 62"ttft_s" :round (ttft ,3 )if ttft is not None else None , 63"wall_s" :round (wall ,2 ), 64"ttft_is_first_content_delta" :True , 65"timings" :timings ,"usage" :usage , 66"out_chars" :len (content ), 67"out_head" :content [:120 ], 68 } 69json .dumps ({k :res [k ]for k in ("tag" ,"ttft_s" ,"wall_s" )} 70| {"pn" : (timings or {}).get ("prompt_n" ), 71"reused" : (timings or {}).get ("cache_n" ), 72"gen" : (timings or {}).get ("predicted_n" ), 73"ptps" :round ((timings or {}).get ("prompt_per_second" ,0 ),1 ), 74"dtps" :round ((timings or {}).get ("predicted_per_second" ,0 ),1 )}),flush = True ) 75return res 76 77def main (): 78f"=== BENCH REPORT START { time . strftime ( '%Y-%m-%d %H:%M:%S' ) } ===" ,flush = True ) 79results = [] 80 81# warm-up (not part of results) 82w = run ("warmup" ,60 ,n = 64 ) 83"warmup done" ,flush = True ) 84results .append (dict (w ,tag = "warmup" ,counted = False )) 85 86sizes = [("tokens550" ,60 ,3 ), ("tokens13500" ,1490 ,3 ), ("tokens33000" ,3660 ,3 ), ("tokens90000" ,9970 ,1 )] 87for name ,rep ,reps in sizes : 88for i in range (reps ): 89r = run (f" { name } -run { i + 1 } " ,rep ) 90r ["counted" ]= True 91results .append (r ) 92 93with open (OUT ,"w" )as f : 94json .dump (results ,f ,indent = 1 ) 95f"=== BENCH REPORT DONE { time . strftime ( '%Y-%m-%d %H:%M:%S' ) } -> { OUT } ===" ,flush = True ) 96 97if __name__ == "__main__" : 98main ()