okami.mom/strata

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

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

main
4.7 KiB83 linesraw
1"""Render the recorded release comparison; requires matplotlib, no GPU."""
2import csv
3from pathlib import Path
4
5import matplotlib
6matplotlib.use("Agg")
7import matplotlib.pyplot as plt
8from matplotlib.patches import Patch
9
10ROOT = Path(__file__).resolve().parent
11rows = list(csv.DictReader((ROOT / "results.csv").open(encoding="utf-8", newline="")))
12groups = [("q4", "mtp", "Q4_K_XL / MTP T4"),
13          ("q4", "nomtp", "Q4_K_XL / no MTP"),
14          ("q8", "mtp", "Q8_0 / MTP T4"),
15          ("q8", "nomtp", "Q8_0 / no MTP")]
16colors = {"v0.1.39": "#9caabe", "v0.1.40": "#087f8c"}
17ink, muted, grid = "#162c43", "#506176", "#e4eaf0"
18plt.rcParams.update({"font.family": "DejaVu Sans", "font.size": 11,
19                    "text.color": ink, "axes.labelcolor": muted,
20                    "xtick.color": muted, "ytick.color": ink,
21                    "axes.spines.top": False, "axes.spines.right": False,
22                    "axes.spines.left": False, "axes.spines.bottom": False,
23                    "svg.fonttype": "none", "svg.hashsalt": "rtxpro-v0140"})
24fig = plt.figure(figsize=(14, 8.4), facecolor="#f7f9fc")
25fig.text(.04, .956, "COMMUNITY MEASUREMENTS / UNMODIFIED RELEASE ENGINES",
26         fontsize=10, fontweight="bold", color=colors["v0.1.40"])
27fig.text(.04, .905, "Strata 0.1.39 → 0.1.40", fontsize=29, fontweight="bold")
28fig.text(.04, .867, "Q4 and Q8 on RTX PRO 6000 Blackwell · 8K input + 512 output · FP16 KV",
29         fontsize=13, color=muted)
30fig.text(.04, .809, "Q8 now loads natively", fontsize=20, fontweight="bold")
31fig.text(.04, .780, "Stock 0.1.39 rejects its Q8 PLE table; no patched baseline is plotted.",
32         fontsize=11, color=muted)
33fig.text(.64, .809, "Q4 decode improves", fontsize=20, fontweight="bold",
34         color=colors["v0.1.40"])
35gains = []
36for mode in ["mtp", "nomtp"]:
37    values = {r["version"]: float(r["decode_tok_s"]) for r in rows
38              if r["quant"] == "q4" and r["mode"] == mode}
39    gains.append(100 * (values["v0.1.40"] / values["v0.1.39"] - 1))
40fig.text(.64, .780, f"+{gains[0]:.1f}% MTP · +{gains[1]:.1f}% no MTP (single runs)",
41         fontsize=11, color=muted)
42fig.legend(handles=[Patch(color=colors[v], label=v) for v in colors],
43           loc="upper right", bbox_to_anchor=(.97, .966), frameon=False, ncol=2)
44gs = fig.add_gridspec(1, 2, left=.215, right=.963, bottom=.205, top=.690, wspace=.27)
45for col, (metric, title, unit, limit) in enumerate([
46        ("decode_tok_s", "Streaming decode · higher is faster", "Output tokens / second", 310),
47        ("total_seconds", "Whole request · lower is faster", "Seconds, including prefill", 23)]):
48    ax = fig.add_subplot(gs[0, col], facecolor="white")
49    ax.set_title(title, loc="left", fontsize=13, fontweight="bold", pad=18)
50    for i, (quant, mode, _) in enumerate(groups):
51        for version, offset in [("v0.1.39", -.19), ("v0.1.40", .19)]:
52            match = [r for r in rows if r["quant"] == quant and r["mode"] == mode
53                     and r["version"] == version]
54            assert len(match) == 1
55            row = match[0]
56            if row["status"] != "completed":
57                ax.text(limit*.018, i+offset, "Unsupported Q8 PLE", va="center",
58                        color=muted, fontsize=9.5, fontstyle="italic")
59                continue
60            value = float(row[metric])
61            ax.barh(i+offset, value, height=.30, color=colors[version], zorder=3)
62            label = f"{value:.1f}" if col == 0 else f"{value:.2f}"
63            ax.text(value+limit*.018, i+offset, label, va="center", fontsize=10)
64    ax.set_yticks(range(4), [g[2] for g in groups] if col == 0 else [""]*4)
65    ax.tick_params(axis="both", length=0, pad=10)
66    ax.set_ylim(3.6, -.6)
67    ax.set_xlim(0, limit)
68    ax.set_axisbelow(True)
69    ax.grid(axis="x", color=grid, linewidth=.8)
70    ax.set_xlabel(unit, fontsize=10, labelpad=10)
71fig.text(.04, .124, "RTX PRO 6000 Blackwell Workstation 96 GB / 400 W · Ryzen 9 7950X · 128 GB RAM",
72         fontsize=10, fontweight="bold")
73fig.text(.04, .092, "Single observation per configuration; model loading excluded. Existing compatibility packs used by both engines.",
74         fontsize=9.5, color=muted)
75fig.text(.04, .061, "16,384-token allocation · one request · temperature 0 · ngram off · each timed request reads all 8,192 input tokens.",
76         fontsize=9.5, color=muted)
77fig.text(.04, .030, "Release comparison, not a PLE-only ablation or an intelligence benchmark. Token checks and limitations are in the report.",
78         fontsize=9.5, color=muted)
79for ext in ["png", "svg"]:
80    fig.savefig(ROOT / f"overview.{ext}", dpi=180, facecolor=fig.get_facecolor(),
81                metadata={"Date": None} if ext == "svg" else None)
82svg = ROOT / "overview.svg"
83svg.write_text("\n".join(line.rstrip() for line in svg.read_text().splitlines()) + "\n")