okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
6e1085c1d
main
1"""Strata community bench driver: sends prompts.jsonl (from gen.py) one at a time, records engine timings. 2 3usage: bench.py prompts.jsonl OUT.jsonl 4Streaming chat completions, temperature 0 (greedy), reasoning_effort none, 256-token cap. After each 5request the engine's own timings are read from /v1/status (last_timings), with RAM and VRAM use. 6""" 7 8import json 9import sys 10import time 11import urllib .request 12 13URL = "http://127.0.0.1:8086" 14MODEL = "strata-ista-iq3s" 15CAP = 256 16 17 18def status ()-> dict : 19with urllib .request .urlopen (URL + "/v1/status" ,timeout = 30 )as r : 20return json .load (r ) 21 22 23def request (content :str )-> dict : 24body = { 25"model" :MODEL , 26"stream" :True , 27"stream_options" : {"include_usage" :True }, 28"temperature" :0 , 29"reasoning_effort" :"none" , 30"max_tokens" :CAP , 31"messages" : [{"role" :"user" ,"content" :content }], 32 } 33req = urllib .request .Request (URL + "/v1/chat/completions" ,data = json .dumps (body ).encode (), 34headers = {"Content-Type" :"application/json" }) 35t0_wall ,t0 = time .time (),time .perf_counter () 36t_first = None 37usage ,finish ,reasoning_chars ,answer_chars = {},None ,0 ,0 38with urllib .request .urlopen (req ,timeout = 1800 )as resp : 39for raw in resp : 40line = raw .decode ().strip () 41if not line .startswith ("data:" )or line == "data: [DONE]" : 42continue 43ev = json .loads (line [5 :]) 44usage = ev .get ("usage" )or usage 45for ch in ev .get ("choices" )or []: 46d = ch .get ("delta" )or {} 47a ,r = d .get ("content" )or "" ,d .get ("reasoning_content" )or "" 48if (a or r )and t_first is None : 49t_first = time .perf_counter () 50answer_chars += len (a ) 51reasoning_chars += len (r ) 52finish = ch .get ("finish_reason" )or finish 53t1 = time .perf_counter () 54st = status () 55lt = st .get ("last_timings" )or {} 56machine = st .get ("machine" )or {} 57return { 58"t_start" :round (t0_wall ,3 ),"t_end" :round (time .time (),3 ), 59"prompt_tokens" :usage .get ("prompt_tokens" ),"completion_tokens" :usage .get ("completion_tokens" ), 60"finish_reason" :finish ,"answer_chars" :answer_chars ,"reasoning_chars" :reasoning_chars , 61"ttft_s" :round (t_first - t0 ,3 )if t_first else None ,"total_s" :round (t1 - t0 ,3 ), 62"engine" : {k :lt .get (k )for k in ("cache_n" ,"prompt_n" ,"prompt_ms" ,"prompt_per_second" , 63"predicted_n" ,"predicted_ms" ,"predicted_per_second" , 64"draft_n" ,"draft_n_accepted" )}, 65"ram_used_gib" :machine .get ("ram" , {}).get ("used_gib" ), 66"gpu_used_mib" :machine .get ("gpu" , {}).get ("used_mib" ), 67 } 68 69 70prompts = [json .loads (line )for line in open (sys .argv [1 ])] 71with open (sys .argv [2 ],"a" )as out : 72for p in prompts : 73rec = {k :p [k ]for k in ("label" ,"target" ,"counted" ,"offset" ,"content_tokens" )} 74rec .update (request (p ["content" ])) 75json .dumps (rec ),flush = True ) 76out .write (json .dumps (rec )+ "\n" ) 77"BENCH_DONE" ,flush = True )