Files
leleka/engine/strata/tools/dflash2/final_tables.py
T
Pavlo RatushnyiandClaude Sonnet 5.5 87e2633afe engine/strata: bring the Strata subtree to upstream 41cf05a0 (engine 0.1.50) with the local patches re-applied
Documented tree replacement (the history has no git-subtree metadata): 3-way merge of the old subtree
(570201a:engine/strata) against upstream 41cf05a06a25dd29103b7b27a2279a3f60c21876 (2026-10-25), merge base =
the old pin d9ab8435 (tree-identical to upstream 5b734e42; d9ab8435 is not an ancestor of upstream main).

Local patches re-applied by hand where they conflicted (15 files): STRATA_CUDA_STATIC profile, experimental KAR
experts and KAR PLE arms, keyless V-only arm (now beside upstream's K8V4 hybrid KV and fused norm+rope). Details,
conflict table and left-out files are in docs/upstream.md.

Left out (weights, captures, logs, media): new bench/results (2022 files), binary media and app assets (61),
docs/work/evidence (24), *.bin / *.gguf data files, and the 7 files the first import already left out.

scripts/build-cpu.sh: build the 11 CPU tests upstream registered since the old pin (they ran as "Not Run").
Checked: build-cpu.sh 16/16 ctest in WSL; sm_86 CUDA objects of the patched files compile, also with the KAR
macros on. No GPU run, no quality gate.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 12:49:15 +01:00

62 lines
3.1 KiB
Python

import json
import numpy as np
import sys
sys.path.insert(0, r"C:\dflash2-work")
exec(open(r"C:\dflash2-work\analyze2.py").read().split("print(\"check")[0]) # TV, PROD, A8, A4, walk, conf_T, names
fixed8 = {n: walk(A8[n], lambda r: 8, 8, n)[0] for n in names}
fixed4 = {n: walk(A4[n], lambda r: 4, 8, n)[0] for n in names}
fixed5 = {n: walk(A8[n], lambda r: 5, 8, n)[0] for n in names}
print("| prompt | MTP+lookup (default) tokens/round, tok/s | MTP only tokens/round, tok/s | DFlash2 block 4 | block 8 |")
print("| --- | --- | --- | --- | --- |")
for n in names:
p = PROD[n]
print("| %s | %.2f, %.1f | %.2f, %.1f | %.2f | %.2f |" % (n, p[0], p[1], p[2], p[3], fixed4[n], fixed8[n]))
print("| 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]),
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()))))
print("gain of block-4 tokens/round over MTP default: mean of ratios %+.1f%%, per prompt %s" % (
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}))
print("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)))
# conditional acceptance by draft position (block 8, all anchors, conditional on all earlier correct)
cond = np.zeros(7); cn = np.zeros(7)
for n in names:
for r in A8[n]:
for i in range(7):
cn[i] += 1
if r["ok"][i]:
cond[i] += 1
else:
break
print("block-8 conditional acceptance by position (all prompts):", (cond / cn).round(3).tolist())
cond4 = np.zeros(3); cn4 = np.zeros(3)
for n in names:
for r in A4[n]:
for i in range(3):
cn4[i] += 1
if r["ok"][i]:
cond4[i] += 1
else:
break
print("block-4 conditional acceptance by position (all prompts):", (cond4 / cn4).round(3).tolist())
print("\nspeed estimate table (tok/s), D = drafter cost per round")
pol = [("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)),
("confidence>=0.4, up to 6", A8, conf_T(0.4, 6))]
for label, A, f in pol:
for D in (5.0, 8.0, 12.0):
r_ = []
tps_ = []
for n in names:
tau, ms, tps, hist = walk(A[n], f, D, n)
r_.append(tps / PROD[n][1])
tps_.append(tps)
print("%-28s D=%4.0f ms: mean %.1f tok/s (default %.1f): mean-of-ratios %+.1f%%, best %+.0f%% (%s), worst %+.0f%% (%s)" % (
label, D, np.mean(tps_), np.mean([PROD[n][1] for n in names]), 100 * (np.mean(r_) - 1),
100 * (max(r_) - 1), names[int(np.argmax(r_))], 100 * (min(r_) - 1), names[int(np.argmin(r_))]))
# window histogram of the confidence policy
print()
for n in names:
tau, ms, tps, hist = walk(A8[n], conf_T(0.5, 8), 8.0, n)
print(n, "conf>=0.5 cap 8: windows", {int(i): int(h) for i, h in enumerate(hist) if h}, "tau %.2f" % tau)