okami.mom/strata

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

Niko1221Merge branch 'f-1402-w' into f-140253623e56f

main
3.9 KiB68 linesraw
1"""Plot native 0.1.40 decoding policies from results.csv; requires matplotlib."""
2import csv
3from pathlib import Path
4
5import matplotlib
6matplotlib.use("Agg")
7import matplotlib.pyplot as plt
8
9ROOT = Path(__file__).resolve().parent
10rows = list(csv.DictReader((ROOT / "results.csv").open(encoding="utf-8", newline="")))
11policies = [("nomtp", "No speculation", "#9caabe"),
12            ("mtp", "MTP T4", "#087f8c"),
13            ("ngram", "Ngram only", "#d28b35"),
14            ("mtp-ngram", "MTP + ngram", "#765ca8")]
15ink, muted, grid = "#162c43", "#506176", "#e4eaf0"
16plt.rcParams.update({"font.family": "DejaVu Sans", "font.size": 11,
17                    "text.color": ink, "axes.labelcolor": muted,
18                    "xtick.color": muted, "ytick.color": ink,
19                    "axes.spines.top": False, "axes.spines.right": False,
20                    "axes.spines.left": False, "axes.spines.bottom": False,
21                    "svg.fonttype": "none", "svg.hashsalt": "rtxpro-v0140-ngram"})
22fig = plt.figure(figsize=(14, 11.5), facecolor="#f7f9fc")
23fig.text(.04, .961, "COMMUNITY MEASUREMENTS / UNMODIFIED STRATA 0.1.40",
24         fontsize=10, fontweight="bold", color="#087f8c")
25fig.text(.04, .914, "Four decoding paths on RTX PRO 6000", fontsize=27, fontweight="bold")
26fig.text(.04, .877, "8K actual input + 512 output · One request · FP16 KV · 16K allocation",
27         fontsize=13, color=muted)
28gs = fig.add_gridspec(2, 2, left=.17, right=.962, bottom=.19, top=.78,
29                      hspace=.85, wspace=.55)
30for col, (quant, name) in enumerate([("q4", "Unsloth Q4_K_XL"), ("q8", "Unsloth Q8_0")]):
31    data = {}
32    for mode, _, _ in policies:
33        matches = [r for r in rows if r["version"] == "v0.1.40" and
34                   r["quant"] == quant and r["mode"] == mode]
35        assert len(matches) == 1 and matches[0]["status"] == "completed"
36        data[mode] = matches[0]
37    for row, (metric, title, unit) in enumerate([
38            ("decode_tok_s", "Streaming decode · higher is faster", "Committed output tokens / second"),
39            ("total_seconds", "Whole request · lower is faster", "Seconds, including prefill")]):
40        ax = fig.add_subplot(gs[row, col], facecolor="white")
41        ax.set_title(name + "\n" + title, loc="left", fontsize=13,
42                     fontweight="bold", pad=16, linespacing=1.5)
43        values = [float(data[mode][metric]) for mode, _, _ in policies]
44        limit = max(values)*1.22
45        for i, ((mode, label, color), value) in enumerate(zip(policies, values)):
46            ax.barh(i, value, height=.52, color=color, zorder=3)
47            ax.text(value+limit*.02, i, f"{value:.1f}" if row == 0 else f"{value:.2f}",
48                    va="center", fontsize=11)
49        ax.set_yticks(range(4), [label for _, label, _ in policies])
50        ax.set_ylim(3.6, -.6)
51        ax.set_xlim(0, limit)
52        ax.tick_params(axis="both", length=0, pad=9)
53        ax.set_axisbelow(True)
54        ax.grid(axis="x", color=grid, linewidth=.8)
55        ax.set_xlabel(unit, fontsize=10, labelpad=9)
56fig.text(.04, .104, "RTX PRO 6000 Blackwell Workstation 96 GB / 400 W · Ryzen 9 7950X · 128 GB RAM",
57         fontsize=10, fontweight="bold")
58fig.text(.04, .076, "Native 0.1.40 engine; one observation per path. Model loading excluded; existing compatibility packs.",
59         fontsize=9.5, color=muted)
60fig.text(.04, .048, "Ngram: suffix match ≥3, verifier up to T8. Combined: MTP T4 + suffix lookup + up to 4 chained lookup drafts.",
61         fontsize=9.5, color=muted)
62fig.text(.04, .021, "Q4 token streams matched. Q8 ngram paths first differ at output token 4; cause unresolved. Draft counts are in the report.",
63         fontsize=9.5, color=muted)
64for ext in ["png", "svg"]:
65    fig.savefig(ROOT / f"ngram.{ext}", dpi=180, facecolor=fig.get_facecolor(),
66                metadata={"Date": None} if ext == "svg" else None)
67svg = ROOT / "ngram.svg"
68svg.write_text("\n".join(line.rstrip() for line in svg.read_text().splitlines()) + "\n")