okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge commit 'b8d604d28' into f-clean-1ab0fc432ed

main
3.5 KiB62 linesraw
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")):
12    if not os.path.lexists(W + "/" + name):
13        os.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):
20    out = f"{OUT}/{tag}"
21    cmd = [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"]
23    for e in PA_ENV:
24        cmd += ["--env", e]
25    if loadcmd:
26        cmd += ["--loadcmd", loadcmd]
27    env = dict(os.environ, PARA_W=W)
28    t = time.time()
29    subprocess.run(cmd, env=env, capture_output=True, text=True)
30    print(f"== {tag} ({time.time() - t:.0f}s)", flush=True)
31    for f in ("load.txt",):
32        p = f"{out}/{f}"
33        if os.path.exists(p):
34            print("".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)
35            if loadcmd:
36                print(open(p).read()[-700:])
37
38
39def mine(tag, env, post=None, exe=None, repo=None, rounds=2):
40    out = f"{OUT}/{tag}"
41    cmd = [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]
44    if post:
45        cmd += ["--post-cmd", post]
46    t = time.time()
47    r = subprocess.run(cmd, capture_output=True, text=True)
48    print(f"== {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)