okami.mom/strata

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

Niko1221Merge f-029-par-harness1fb3e9a32

main
4.3 KiB63 linesraw
1#!/usr/bin/env python3
2"""recon3.py BOX ARMS... - sustained + burst for the honest headline.  Runs PAR-A's armrun.py with this harness's both.py as the loader.
3BOX boston: W=armw (symlinks to the int029 / base builds); BOX r9700: W=/data/par-a (b4 / src4)."""
4import os, subprocess, sys, time
5box = sys.argv[1]
6arms = sys.argv[2:]
7HOST = ["STRATA_QSA_SLOTS=1", "STRATA_BATCH_SELF_COMMIT=1", "STRATA_SLOT_COPY_DIRECT=1", "STRATA_CKPT_POOL=1", "STRATA_CKPT_POOL_READY=4",
8        "STRATA_SLOT_CKPT_MOVE=1", "STRATA_SLOT_COPY_BATCHSYNC=1"]
9CUDA = ["STRATA_BATCH_GDN_GROUPS=1", "STRATA_BATCH_ATTN_ROWS=1"]
10if box == "boston":
11    R = "/data/external/niko/par29"; PA = "/data/external/niko/parA"; I = "/data/external/niko/int029"; W = R + "/armw"
12    PY = "/data/external/niko/t027/venv/bin/python"
13    for name, tgt in (("bbase", I + "/b-base"), ("srcbase", I + "/base"), ("bint", I + "/b-int"), ("srcint", I + "/int")):
14        if not os.path.lexists(W + "/" + name):
15            os.symlink(tgt, W + "/" + name)
16    G2 = ["--gpus", "0,1"]
17    REP = '[{"gpus":[0]},{"gpus":[1]}]'
18    ARMS = {
19        "B1": (["--parallel", "8"], [], "bbase", "srcbase"),
20        "LS": (["--parallel", "8"], HOST + CUDA, "bint", "srcint"),
21        "REP": (["--parallel", "8", "--replicas", REP], HOST + CUDA + ["STRATA_REPLICA_SHARED_ARENA=1", "STRATA_COALESCE_PREFILL=3", "STRATA_COALESCE_WAIT_MS=40"], "bint", "srcint"),
22        "REPCR": (["--parallel", "8", "--replicas", REP, "--arg=--no-prefill-borrow"], HOST + CUDA + ["STRATA_REPLICA_SHARED_ARENA=1", "STRATA_COALESCE_PREFILL=3", "STRATA_COALESCE_WAIT_MS=40", "STRATA_BATCH_CONCURRENT_READ=1"], "bint", "srcint"),
23        "REPCR_NOCO": (["--parallel", "8", "--replicas", REP, "--arg=--no-prefill-borrow"], HOST + CUDA + ["STRATA_REPLICA_SHARED_ARENA=1", "STRATA_BATCH_CONCURRENT_READ=1"], "bint", "srcint"),
24        "REP_NOCO": (["--parallel", "8", "--replicas", REP], HOST + CUDA + ["STRATA_REPLICA_SHARED_ARENA=1"], "bint", "srcint"),
25    }
26    GP = G2; CONC = "8,16,32"
27else:
28    R = "/data/par29h"; PA = "/data/par-a"; W = R + "/armw"; PY = "/data/p4/venv/bin/python"
29    os.makedirs(W, exist_ok=True)
30    for name, tgt in (("b4", PA + "/b4"), ("src4", PA + "/src4"), ("bint", R + "/int/b-int"), ("srcint", R + "/int/src")):
31        if not os.path.lexists(W + "/" + name):
32            os.symlink(tgt, W + "/" + name)
33    REP2 = '[{"gpus":[0]},{"gpus":[1]}]'
34    REP4 = '[{"gpus":[0]},{"gpus":[1]},{"gpus":[2]},{"gpus":[3]}]'
35    CO = ["STRATA_REPLICA_SHARED_ARENA=1", "STRATA_LM_HIP=1", "STRATA_COALESCE_PREFILL=3", "STRATA_COALESCE_WAIT_MS=40"]
36    ARMS = {
37        "B1p8_2c": (["--gpus", "0,1", "--parallel", "8"], [], "b4", "src4"),
38        "B1p16_2c": (["--gpus", "0,1", "--parallel", "16"], [], "b4", "src4"),
39        "REP2": (["--gpus", "0,1", "--parallel", "8", "--replicas", REP2], HOST + CO, "b4", "src4"),
40        "B1_4c": (["--gpus", "0,1,2,3", "--profile4"], [], "b4", "src4"),
41        "REP2CR": (["--gpus", "0,1", "--parallel", "8", "--replicas", REP2, "--arg=--no-prefill-borrow"], HOST + CO + ["STRATA_BATCH_CONCURRENT_READ=1"], "bint", "srcint"),
42        "REP4CR": (["--gpus", "0,1,2,3", "--parallel", "4", "--replicas", REP4, "--arg=--no-prefill-borrow"], HOST + CO + ["STRATA_BATCH_CONCURRENT_READ=1"], "bint", "srcint"),
43        "REP2I": (["--gpus", "0,1", "--parallel", "8", "--replicas", REP2], HOST + CO, "bint", "srcint"),
44        "REP4": (["--gpus", "0,1,2,3", "--parallel", "4", "--replicas", REP4], HOST + CO, "b4", "src4"),
45    }
46    GP = None; CONC = "8,16,32"
47OUT = R + "/res/recon3"
48for tag in arms:
49    flags, env, build, src = ARMS[tag][0], ARMS[tag][1], ARMS[tag][2], ARMS[tag][3]
50    out = f"{OUT}/{box}_{tag}"
51    cmd = [PY, PA + "/armrun.py", "--out", out, "--build", build, "--src", src, "--conc", CONC, "--rounds", "2", "--max-tokens", "128",
52           "--port", "8197", "--loadcmd", R + "/h/tools/par/both.py"] + (GP or []) + flags
53    for e in env:
54        cmd += ["--env", e]
55    e2 = dict(os.environ, PARA_W=W, PA_LOAD=PA + "/par_load.py", BOTH_CONC=CONC)
56    t = time.time()
57    subprocess.run(cmd, env=e2, capture_output=True, text=True)
58    print(f"=== {box} {tag} ({time.time() - t:.0f}s)", flush=True)
59    p = out + "/load.txt"
60    if os.path.exists(p):
61        for l in open(p).read().splitlines():
62            if l.startswith(("###", "w2 c=")) or l[:3].strip().isdigit() and "tok/s" not in l and len(l.split()) > 5:
63                print(l[:170], flush=True)