okami.mom/strata

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

Niko1221Merge f-clean-3 (321794636): docs and history (cleanup step 3, items 3.0-3.10); release manifest and capability table with checks, history/ with pointers, link check, tools/ split, bench index; owner OK'd the wording 11-082b36e8a02

main
2.9 KiB73 linesraw
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):
16    by = {r["s"]: r for r in rows}
17    s = len(SEQ[n]["prompt"])
18    tok = 0
19    ms = 0.0
20    rounds = 0
21    hist = np.zeros(10)
22    while s in by:
23        r = by[s]
24        T = T_of(r)
25        a = 0
26        while a < T - 1 and a < len(r["ok"]) and r["ok"][a]:
27            a += 1
28        tok += a + 1
29        ms += TV[T] + D + HOST
30        rounds += 1
31        hist[T] += 1
32        s += a + 1
33    return tok / rounds, ms / rounds, 1000.0 * tok / ms, hist
34
35
36def conf_T(theta, cap=8):
37    def f(r):
38        T = 1
39        for p in r["p"][:cap - 1]:
40            if p >= theta:
41                T += 1
42            else:
43                break
44        return T
45    return f
46
47
48print("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})
49print("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    print("\n=== drafter cost D = %.0f ms per round (verify cost + D + 0.07) ===" % D)
53    cfgs = [("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)]
56    for th in (0.3, 0.4, 0.5, 0.6, 0.7, 0.8):
57        for cap in (4, 5, 6, 8):
58            cfgs.append(("conf>=%.1f cap %d" % (th, cap), A8, conf_T(th, cap)))
59    print("%-26s" % "policy" + "".join("%15s" % n[:13] for n in names) + "   mean-of-ratios")
60    best = None
61    for label, A, f in cfgs:
62        ratios, row = [], "%-26s" % label
63        for n in names:
64            tau, ms, tps, hist = walk(A[n], f, D, n)
65            ratios.append(tps / PROD[n][1])
66            row += "%15s" % ("%.2f/%.1f(%+.0f%%)" % (tau, tps, 100 * (tps / PROD[n][1] - 1)))
67        m = 100 * (np.mean(ratios) - 1)
68        if D == 8.0 or label.startswith("fixed") or True:
69            print(row + "   %+6.1f%%" % m)
70        if best is None or m > best[0]:
71            best = (m, label)
72        out[(D, label)] = m
73    print("best:", best)