okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
b0fc432ed
main
1#!/usr/bin/env python3 2"""recon.py - reconcile PAR-A's boston numbers with this harness (runs on boston, one arm after the other).""" 3import os ,subprocess ,sys ,time 4PA = "/data/external/niko/parA" 5I = "/data/external/niko/int029" 6R = "/data/external/niko/par29" 7W = R + "/armw" 8OUT = R + "/res/recon" 9PY = "/data/external/niko/t027/venv/bin/python" 10os .makedirs (W ,exist_ok = True ) 11for name ,tgt in (("b5" ,PA + "/b5" ), ("src5" ,PA + "/src5" ), ("bint" ,I + "/b-int" ), ("srcint" ,I + "/int" )): 12if not os .path .lexists (W + "/" + name ): 13os .symlink (tgt ,W + "/" + name ) 14REPL = '[{"gpus":[0]},{"gpus":[1]}]' 15PA_ENV = ["STRATA_QSA_SLOTS=1" ,"STRATA_BATCH_SELF_COMMIT=1" ,"STRATA_SLOT_COPY_DIRECT=1" ,"STRATA_CKPT_POOL=1" ,"STRATA_CKPT_POOL_READY=4" , 16"STRATA_SLOT_CKPT_MOVE=1" ,"STRATA_SLOT_COPY_BATCHSYNC=1" ,"STRATA_REPLICA_SHARED_ARENA=1" ] 17 18 19def armrun (tag ,build ,src ,loadcmd = None ): 20out = f" { OUT } / { tag } " 21cmd = [PY ,PA + "/armrun.py" ,"--out" ,out ,"--gpus" ,"0,1" ,"--replicas" ,REPL ,"--parallel" ,"8" ,"--build" ,build ,"--src" ,src , 22"--conc" ,"8,16" ,"--rounds" ,"2" ,"--max-tokens" ,"128" ,"--port" ,"8191" ] 23for e in PA_ENV : 24cmd += ["--env" ,e ] 25if loadcmd : 26cmd += ["--loadcmd" ,loadcmd ] 27env = dict (os .environ ,PARA_W = W ) 28t = time .time () 29subprocess .run (cmd ,env = env ,capture_output = True ,text = True ) 30f"== { tag } ( { time . time () - t :.0f } s)" ,flush = True ) 31for f in ("load.txt" ,): 32p = f" { out } / { f } " 33if os .path .exists (p ): 34"" .join (l for l in open (p ).read ().splitlines (True )if l .strip ()[:2 ]in ("8 " ,"16" )or "tok/s" in l and l .startswith ("c=" )),flush = True ) 35if loadcmd : 36open (p ).read ()[- 700 :]) 37 38 39def mine (tag ,env ,post = None ,exe = None ,repo = None ,rounds = 2 ): 40out = f" { OUT } / { tag } " 41cmd = [PY ,R + "/h/tools/par_run.py" ,"--box" ,"boston" ,"--tag" ,tag ,"--exe" ,exe or I + "/b-int/strata" ,"--repo" ,repo or I + "/int" , 42"--gpus" ,"0,1" ,"--parallel" ,"8" ,"--server-extra" , ("--replicas 2" if "A9" not in tag else "" ),"--env" ,";" .join (env ),"--rounds" ,"2" , 43"--work" ,f"w2:8,16@--nonce rc --max-tokens 128 --rounds { rounds } --warm-requests 2" ,"--out" ,out ] 44if post : 45cmd += ["--post-cmd" ,post ] 46t = time .time () 47r = subprocess .run (cmd ,capture_output = True ,text = True ) 48f"== { tag } ( { time . time () - t :.0f } s)\n" + "\n" .join (l for l in r .stdout .splitlines ()if l .startswith (("w2" ," " ,"c=" ,"DONE" ,"ABORT" ," 8" ," 16" ))),flush = True ) 49 50 51THEIR_LOAD = f" { PY } { PA } /par_load.py {{url}} --conc 8,16 --rounds 2 --prompt-tokens 1000 --max-tokens 128 --out /dev/null" 52MY_STACK = PA_ENV + ["STRATA_BATCH_GDN_GROUPS=1" ,"STRATA_BATCH_ATTN_ROWS=1" ] 53if "A7" in sys .argv :mine ("A7_myarm_burst_rounds1" ,PA_ENV ) 54if "A8" in sys .argv :mine ("A8_myarm_sustained_rounds6" ,PA_ENV ,rounds = 6 ) 55if "A9" in sys .argv :mine ("A9_layersplit_b1like_rounds1" , ["STRATA_QSA_SLOTS=1" ] ,rounds = 1 ,exe = I + "/b-base/strata" ,repo = I + "/base" ) 56which = [x for x in sys .argv [1 :]if x not in ("A7" ,"A8" ,"A9" )]if len (sys .argv )> 1 else ["A1" ,"A2" ,"A3" ,"A4" ,"A5" ,"A6" ] 57if "A1" in which :armrun ("A1_pa_exact_theirload" ,"b5" ,"src5" ) 58if "A2" in which :armrun ("A2_pa_exact_myload" ,"b5" ,"src5" ,R + "/h/tools/par/my_load.py" ) 59if "A3" in which :armrun ("A3_pa_cfg_intbuild_theirload" ,"bint" ,"srcint" ) 60if "A4" in which :armrun ("A4_pa_cfg_intbuild_myload" ,"bint" ,"srcint" ,R + "/h/tools/par/my_load.py" ) 61if "A5" in which :mine ("A5_myarm_theirload" ,MY_STACK ,THEIR_LOAD ) 62if "A6" in which :mine ("A6_myarm_paenv_theirload" ,PA_ENV ,THEIR_LOAD )