okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
2b36e8a02
main
1#!/usr/bin/env python3 2"""b.py (ARC-W): one engine load on the Arc B65 box, a list of solo requests over the engine's line protocol. 3 4b.py --engine E --tag T --plan "short:128:2,p1k:8:3,p4k:8:2,p16k:8:2" [--env K=V ...] [--extra "--spec 2 ..."] 5 6plan item = case:max_new:repeat (cases are the token-id files in /mnt/models/strata-test/prompts). Output: out/<tag>.json 7with per-request prompt tok/s, decode tok/s and the tokens; one summary line per request on stderr. A new first token per 8repeat keeps the prompt from being served out of the conversation cache (the case then differs by 1 token, same for every arm). 9""" 10import argparse ,json ,os ,queue ,shlex ,subprocess ,sys ,threading ,time 11 12ROOT = "/mnt/models/strata-test" 13W = f" { ROOT } /arc037" 14M = "/mnt/models/llama/Qwen3.8-Flash-Next-GSQ-RCO-ISTA-DASLab" 15S1 = f" { M } /Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00001-of-00002.gguf" 16S2 = f" { M } /Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00002-of-00002.gguf" 17 18 19def main (): 20ap = argparse .ArgumentParser () 21ap .add_argument ("--engine" ,required = True ) 22ap .add_argument ("--tag" ,required = True ) 23ap .add_argument ("--plan" ,default = "short:128:2,p1k:8:3,p4k:8:2,p16k:8:2" ) 24ap .add_argument ("--env" ,action = "append" ,default = []) 25ap .add_argument ("--extra" ,default = "--spec 2 --spec-min-p 0.5 --pipeline-windows 2 --mtp-draft-vocab " + f" { W } /src/data/draft_vocab_en.bin" ) 26ap .add_argument ("--layer-split" ,default = "auto" ) 27ap .add_argument ("--gpus" ,default = "" ) 28ap .add_argument ("--max-context" ,type = int ,default = 32768 ) 29ap .add_argument ("--timeout" ,type = float ,default = 1800 ) 30a = ap .parse_args () 31os .makedirs (f" { W } /out" ,exist_ok = True ) 32env = dict (os .environ ) 33env .update ({"ONEAPI_DEVICE_SELECTOR" :"level_zero:*" ,"SYCL_CACHE_PERSISTENT" :"0" ,"ZES_ENABLE_SYSMAN" :"1" , 34"STRATA_VERIFY_NO_HOST" :"1" }) 35if a .gpus : 36env ["ONEAPI_DEVICE_SELECTOR" ]= "level_zero:" + a .gpus 37for kv in a .env : 38k ,_ ,v = kv .partition ("=" ) 39env [k ]= v 40args = ["--serve" ,"--pack" ,f" { ROOT } /data/packs/iq3_s" ,"--native" ,S1 ,"--ple-gguf" ,S2 , 41"--expert-profile" ,f" { W } /src/data/expert-profile-sycl.bin" ,"--expert-cache" ,"auto" ,"--prefill" ,"auto" , 42"--mtp" ,f" { ROOT } /data/mtp/rt" ,"--max-context" ,str (a .max_context ),"--kv" ,"int8" ,"--ple-io" ,"ram" , 43"--stream-experts" ,"--vram-reserve-mib" ,"1024" ,"--layer-split" ,a .layer_split ]+ shlex .split (a .extra ) 44cmdline = "source /opt/intel/oneapi/setvars.sh >/dev/null 2>&1; exec " + " " .join (shlex .quote (x )for x in [a .engine ]+ args ) 45log = open (f" { W } /out/ { a . tag } .err" ,"w" ) 46p = subprocess .Popen (["bash" ,"-c" ,cmdline ],stdin = subprocess .PIPE ,stdout = subprocess .PIPE ,stderr = log ,env = env ,text = True ,bufsize = 1 ) 47q = queue .Queue () 48threading .Thread (target = lambda : ([q .put (l .rstrip ("\n" ))for l in p .stdout ],q .put ("__EOF__" )),daemon = True ).start () 49 50def prompt (case ): 51return [int (x )for x in open (f" { ROOT } /prompts/ { case } .txt" ).read ().split ()] 52 53def gen (ids ,n ): 54p .stdin .write (f"GEN { n } " + "," .join (map (str ,ids ))+ "\n" );p .stdin .flush () 55toks ,t0 = [],time .time () 56while True : 57try : 58l = q .get (timeout = 1.0 ) 59except queue .Empty : 60if p .poll ()is not None :raise RuntimeError ("engine exited %s" % p .returncode ) 61if time .time ()- t0 > a .timeout :raise TimeoutError ("request" ) 62continue 63if l == "__EOF__" :raise RuntimeError ("engine closed stdout" ) 64if l .startswith ("T " ):toks .append (int (l .split ()[1 ])) 65elif l .startswith ("DONE" ):return l .split (),toks 66elif l .startswith ("ERR" ):raise RuntimeError (l ) 67 68res = [] 69try : 70d ,_ = gen (prompt ("short" ),8 )# warm-up 71for item in a .plan .split ("," ): 72case ,n ,rep = item .split (":" ) 73for r in range (int (rep )): 74ids = [1000 + r ]+ prompt (case ) 75d ,toks = gen (ids ,int (n )) 76g ,pt ,pms ,dms = int (d [1 ]),int (d [2 ]),float (d [3 ]),float (d [4 ]) 77rec = {"case" :case ,"rep" :r ,"prompt_tokens" :pt ,"prompt_ms" :pms ,"pp" :pt / pms * 1000 if pms else 0 , 78"generated" :g ,"decode_ms" :dms ,"tg" :g / dms * 1000 if dms else 0 ,"tokens" :toks } 79res .append (rec ) 80f"[ { a . tag } ] { case } # { r } pt= { pt } pp= { rec [ 'pp' ]:.1f } gen= { g } tg= { rec [ 'tg' ]:.1f } " ,file = sys .stderr ,flush = True ) 81finally : 82try :p .stdin .write ("QUIT\n" );p .stdin .flush () 83except Exception :pass 84try :p .wait (timeout = 60 ) 85except subprocess .TimeoutExpired :p .kill () 86log .close () 87json .dump ({"tag" :a .tag ,"engine" :a .engine ,"env" :a .env ,"extra" :a .extra ,"results" :res },open (f" { W } /out/ { a . tag } .json" ,"w" )) 88 89 90main ()