okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
2b36e8a02
main
1import json 2import numpy as np 3 4TV = {1 :39.96 ,2 :43.21 ,3 :48.39 ,4 :53.68 ,5 :59.40 ,6 :66.00 ,7 :74.66 ,8 :80.34 }# ms per verify window, gfx1151 IQ3_S (STRATA_SPEC_T_CYCLE run) 5HOST = 0.07 6PROD = {"chat_explain" : (2.39 ,43.33 ,2.38 ,43.97 ),"code_py" : (2.27 ,43.32 ,2.22 ,42.72 ),"code_cpp" : (2.11 ,40.60 ,2.05 ,39.93 ), 7"math" : (2.99 ,52.38 ,2.95 ,52.29 ),"summarize" : (2.81 ,48.25 ,2.75 ,48.06 ),"json_extract" : (3.25 ,53.91 ,3.22 ,54.22 ), 8"creative" : (2.30 ,42.77 ,2.29 ,42.65 ),"chat_advice" : (1.94 ,38.59 ,1.92 ,38.47 )}# default tau, default tok/s, MTP-only tau, MTP-only tok/s 9names = list (PROD ) 10A8 = json .load (open (r"C:\dflash2-work\anchors1_b8.json" )) 11A4 = json .load (open (r"C:\dflash2-work\anchors1_b4.json" )) 12SEQ = {n :json .load (open (r"C:\dflash2-work\p\%s.seq.json" % n ))for n in names } 13 14 15def walk (rows ,T_of ,D ,n ): 16by = {r ["s" ]:r for r in rows } 17s = len (SEQ [n ]["prompt" ]) 18tok = 0 19ms = 0.0 20rounds = 0 21hist = np .zeros (10 ) 22while s in by : 23r = by [s ] 24T = T_of (r ) 25a = 0 26while a < T - 1 and a < len (r ["ok" ])and r ["ok" ][a ]: 27a += 1 28tok += a + 1 29ms += TV [T ]+ D + HOST 30rounds += 1 31hist [T ]+= 1 32s += a + 1 33return tok / rounds ,ms / rounds ,1000.0 * tok / ms ,hist 34 35 36def conf_T (theta ,cap = 8 ): 37def f (r ): 38T = 1 39for p in r ["p" ][:cap - 1 ]: 40if p >= theta : 41T += 1 42else : 43break 44return T 45return f 46 47 48"check, fixed b=8 walk tau vs the earlier walk: " , {n :round (walk (A8 [n ],lambda r :8 ,8 ,n )[0 ],3 )for n in names }) 49"check, fixed b=4 drafter walk tau: " , {n :round (walk (A4 [n ],lambda r :4 ,8 ,n )[0 ],3 )for n in names }) 50out = {} 51for D in (5.0 ,8.0 ,12.0 ): 52"\n=== drafter cost D = %.0f ms per round (verify cost + D + 0.07) ===" % D ) 53cfgs = [("fixed4 block-4 drafter" ,A4 ,lambda r :4 ), ("fixed3 block-8 drafter" ,A8 ,lambda r :3 ), 54 ("fixed4 block-8 drafter" ,A8 ,lambda r :4 ), ("fixed5" ,A8 ,lambda r :5 ), ("fixed6" ,A8 ,lambda r :6 ), 55 ("fixed7" ,A8 ,lambda r :7 ), ("fixed8" ,A8 ,lambda r :8 )] 56for th in (0.3 ,0.4 ,0.5 ,0.6 ,0.7 ,0.8 ): 57for cap in (4 ,5 ,6 ,8 ): 58cfgs .append (("conf>=%.1f cap %d" % (th ,cap ),A8 ,conf_T (th ,cap ))) 59"%-26s" % "policy" + "" .join ("%15s" % n [:13 ]for n in names )+ " mean-of-ratios" ) 60best = None 61for label ,A ,f in cfgs : 62ratios ,row = [],"%-26s" % label 63for n in names : 64tau ,ms ,tps ,hist = walk (A [n ],f ,D ,n ) 65ratios .append (tps / PROD [n ][1 ]) 66row += "%15s" % ("%.2f/%.1f(%+.0f%%)" % (tau ,tps ,100 * (tps / PROD [n ][1 ]- 1 ))) 67m = 100 * (np .mean (ratios )- 1 ) 68if D == 8.0 or label .startswith ("fixed" )or True : 69row + " %+6.1f%%" % m ) 70if best is None or m > best [0 ]: 71best = (m ,label ) 72out [(D ,label )]= m 73"best:" ,best )