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
3.1 KiB61 linesraw
1import json
2import numpy as np
3import sys
4sys.path.insert(0, r"C:\dflash2-work")
5exec(open(r"C:\dflash2-work\analyze2.py").read().split("print(\"check")[0])   # TV, PROD, A8, A4, walk, conf_T, names
6
7fixed8 = {n: walk(A8[n], lambda r: 8, 8, n)[0] for n in names}
8fixed4 = {n: walk(A4[n], lambda r: 4, 8, n)[0] for n in names}
9fixed5 = {n: walk(A8[n], lambda r: 5, 8, n)[0] for n in names}
10print("| prompt | MTP+lookup (default) tokens/round, tok/s | MTP only tokens/round, tok/s | DFlash2 block 4 | block 8 |")
11print("| --- | --- | --- | --- | --- |")
12for n in names:
13    p = PROD[n]
14    print("| %s | %.2f, %.1f | %.2f, %.1f | %.2f | %.2f |" % (n, p[0], p[1], p[2], p[3], fixed4[n], fixed8[n]))
15print("| mean | %.2f, %.1f | %.2f, %.1f | %.2f | %.2f |" % (np.mean([PROD[n][0] for n in names]), np.mean([PROD[n][1] for n in names]),
16      np.mean([PROD[n][2] for n in names]), np.mean([PROD[n][3] for n in names]), np.mean(list(fixed4.values())), np.mean(list(fixed8.values()))))
17print("gain of block-4 tokens/round over MTP default: mean of ratios %+.1f%%, per prompt %s" % (
18    100 * (np.mean([fixed4[n] / PROD[n][0] for n in names]) - 1), {n: round(100 * (fixed4[n] / PROD[n][0] - 1)) for n in names}))
19print("gain of block-8 tokens/round over MTP default: mean of ratios %+.1f%%" % (100 * (np.mean([fixed8[n] / PROD[n][0] for n in names]) - 1)))
20
21# conditional acceptance by draft position (block 8, all anchors, conditional on all earlier correct)
22cond = np.zeros(7); cn = np.zeros(7)
23for n in names:
24    for r in A8[n]:
25        for i in range(7):
26            cn[i] += 1
27            if r["ok"][i]:
28                cond[i] += 1
29            else:
30                break
31print("block-8 conditional acceptance by position (all prompts):", (cond / cn).round(3).tolist())
32cond4 = np.zeros(3); cn4 = np.zeros(3)
33for n in names:
34    for r in A4[n]:
35        for i in range(3):
36            cn4[i] += 1
37            if r["ok"][i]:
38                cond4[i] += 1
39            else:
40                break
41print("block-4 conditional acceptance by position (all prompts):", (cond4 / cn4).round(3).tolist())
42
43print("\nspeed estimate table (tok/s), D = drafter cost per round")
44pol = [("fixed 4 (block-4 drafter)", A4, lambda r: 4), ("fixed 5 (block-8 drafter)", A8, lambda r: 5), ("confidence>=0.5, up to 8", A8, conf_T(0.5, 8)),
45       ("confidence>=0.4, up to 6", A8, conf_T(0.4, 6))]
46for label, A, f in pol:
47    for D in (5.0, 8.0, 12.0):
48        r_ = []
49        tps_ = []
50        for n in names:
51            tau, ms, tps, hist = walk(A[n], f, D, n)
52            r_.append(tps / PROD[n][1])
53            tps_.append(tps)
54        print("%-28s D=%4.0f ms: mean %.1f tok/s (default %.1f): mean-of-ratios %+.1f%%, best %+.0f%% (%s), worst %+.0f%% (%s)" % (
55            label, D, np.mean(tps_), np.mean([PROD[n][1] for n in names]), 100 * (np.mean(r_) - 1),
56            100 * (max(r_) - 1), names[int(np.argmax(r_))], 100 * (min(r_) - 1), names[int(np.argmin(r_))]))
57# window histogram of the confidence policy
58print()
59for n in names:
60    tau, ms, tps, hist = walk(A8[n], conf_T(0.5, 8), 8.0, n)
61    print(n, "conf>=0.5 cap 8: windows", {int(i): int(h) for i, h in enumerate(hist) if h}, "tau %.2f" % tau)