okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
db4dd65e5
main
1"""q36_interleave_probe.py --exe E --args "..." [--long 3000] [--slots 3] : what the slots that are decoding see while a new 2request's long prompt is read: the tokens they produce during the read, and their longest pause between two tokens, against the 3same without a read. The read goes chunk by chunk with one decode window of the other slots between two chunks. 4 5python tools/qwen35/q36_interleave_probe.py --exe build/strata-q36 --args "--model M --max-context 8192 --batch 4" --long 3000 6""" 7import argparse ,shlex ,sys ,time 8from pathlib import Path 9sys .path .insert (0 ,str (Path (__file__ ).resolve ().parent )) 10from q36_harness import Eng ,load_prompts 11 12ap = argparse .ArgumentParser () 13ap .add_argument ("--exe" ,required = True ) 14ap .add_argument ("--args" ,default = "" ) 15ap .add_argument ("--long" ,type = int ,default = 3000 ) 16ap .add_argument ("--slots" ,type = int ,default = 3 ,help = "slots decoding while the long prompt is read" ) 17ap .add_argument ("--n" ,type = int ,default = 600 ) 18ap .add_argument ("--log" ,default = None ) 19a = ap .parse_args () 20eng = Eng (a .exe ,shlex .split (a .args ),log = a .log ) 21P = load_prompts (str (Path (__file__ ).resolve ().parent / "parity_prompts.ids" )) 22filler = [] 23while len (filler )< a .long : 24for p in P : 25filler += p [3 :- 8 ] 26longids = filler [:a .long ]+ P [1 ][- 8 :] 27stamps = {s : []for s in range (a .slots )} 28for s in range (a .slots ):# admit the decoding slots 29ids = P [[0 ,1 ,2 ,3 ,5 ,8 ][s % 6 ]] 30eng .send ("BGEN %d %d %s" % (s ,a .n ,"," .join (map (str ,ids )))) 31while True : 32l = eng .line () 33if l .startswith ("BADM" ): 34break 35if l .startswith ("BT " ): 36stamps [int (l .split ()[1 ])].append (time .time ()) 37# 1. a stretch of decoding with no read 38t_end = time .time ()+ 1.0 39while time .time ()< t_end : 40l = eng .line () 41if l .startswith ("BT " ): 42stamps [int (l .split ()[1 ])].append (time .time ()) 43base = {s :v [:]for s ,v in stamps .items ()} 44# 2. the long request 45t0 = time .time () 46eng .send ("BGEN %d 8 %s" % (a .slots ,"," .join (map (str ,longids )))) 47pp = [] 48t_adm = None 49while True : 50l = eng .line () 51now = time .time () 52if l .startswith ("BT " ): 53stamps [int (l .split ()[1 ])].append (now ) 54elif l .startswith ("PP " ): 55pp .append (now ) 56elif l .startswith ("BADM" ): 57t_adm = now 58break 59read_s = t_adm - t0 60during = {s : [t for t in v if t0 <= t <= t_adm ]for s ,v in stamps .items ()} 61 62 63def gaps (v ): 64return [b - a_ for a_ ,b in zip (v ,v [1 :])] 65 66 67rate0 = sum (len (v )for s ,v in base .items ())/ max (1e-9 ,1.0 )if False else None 68n_during = sum (len (v )for v in during .values ()) 69mx = max ((max (gaps (v ))for v in during .values ()if len (v )> 1 ),default = 0.0 ) 70mx0 = max ((max (gaps (v [- 60 :]))for v in base .values ()if len (v )> 2 ),default = 0.0 ) 71"a prompt of %d tokens read in %.2f s (%d chunks, %.0f tok/s) beside %d decoding slots" % (len (longids ),read_s ,len (pp ), 72len (longids )/ read_s ,a .slots )) 73"the %d decoding slots produced %d tokens during the read (%.1f tok/s together); longest pause between two tokens of a slot %.0f ms" 74" (while only decoding: %.0f ms)" % (a .slots ,n_during ,n_during / read_s ,1000 * mx ,1000 * mx0 )) 75for s in range (a .slots ): 76eng .send ("BSTOP %d" % s ) 77eng .send ("BSTOP %d" % a .slots ) 78time .sleep (1.0 ) 79eng .close ()