Recipes, tried logs and result folders move under <gpu>/: recipes at <gpu>/<model>/<engine>-<profile>.md, tried logs at <gpu>/<model>/tried.md, runs at <gpu>/results/<run>/. build generates a README for every GPU in cookbook.toml and the GPU table in README.md. validate checks that a run sits in the folder of the GPU it ran on and warns about stray top-level folders. Format docs and host setup move to docs/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4673f0afb6
commit
562c7f2fb8
153 files changed
+445
-288
No files matched your search
+83
-35
@@ -36,6 +36,8 @@ PROFILES = {
|
||||
FIELDS = ("title", "summary", "model", "quant", "kv", "engine", "gpu", "profile",
|
||||
"spec", "thinking", "results")
|
||||
ZERO_DIGEST = "0" * 64
|
||||
# Top-level folders that are not GPU folders.
|
||||
RESERVED = {"docs", "tools", "site"}
|
||||
|
||||
|
||||
def slug(s):
|
||||
@@ -129,9 +131,17 @@ class Cookbook:
|
||||
self.root = Path(root)
|
||||
self.errors, self.warnings = [], []
|
||||
self.config = tomllib.loads((self.root / "cookbook.toml").read_text(encoding="utf-8"))
|
||||
# One folder per GPU: <gpu>/<model>/<engine>-<profile>.md, <gpu>/<model>/tried.md
|
||||
# and <gpu>/results/<run>/.
|
||||
self.gpu_dirs = {slug(g): g for g in self.config["gpus"]}
|
||||
for d in sorted(self.root.iterdir()):
|
||||
if d.is_dir() and not d.name.startswith(".") and d.name not in RESERVED | set(self.gpu_dirs):
|
||||
self.warning(d.name, "not a GPU in cookbook.toml, so nothing in it is checked")
|
||||
self.results = self._load_results()
|
||||
self.recipes = self._load_docs("recipes", self._recipe)
|
||||
self.tried = self._load_docs("tried", self._tried)
|
||||
docs = [p for g in self.gpu_dirs for p in sorted((self.root / g).glob("*/*.md"))
|
||||
if p.parent.name != "results"]
|
||||
self.recipes = self._load_docs([p for p in docs if p.name != "tried.md"], self._recipe)
|
||||
self.tried = self._load_docs([p for p in docs if p.name == "tried.md"], self._tried)
|
||||
for r in self.results.values():
|
||||
if not r["used"]:
|
||||
self.warning(f"results/{r['id']}", "not cited by any recipe or tried log")
|
||||
@@ -145,9 +155,10 @@ class Cookbook:
|
||||
# ------------------------------------------------------------ loading
|
||||
def _load_results(self):
|
||||
out = {}
|
||||
base = self.root / "results"
|
||||
for d in sorted(p for p in base.iterdir() if p.is_dir()) if base.exists() else []:
|
||||
where = f"results/{d.name}"
|
||||
dirs = [(gpu, d) for g, gpu in self.gpu_dirs.items() if (self.root / g / "results").exists()
|
||||
for d in sorted((self.root / g / "results").iterdir()) if d.is_dir()]
|
||||
for gpu, d in dirs:
|
||||
where = d.relative_to(self.root).as_posix()
|
||||
try:
|
||||
meta = json.loads((d / "meta.json").read_text(encoding="utf-8"))
|
||||
res = json.loads((d / f"{d.name}.json").read_text(encoding="utf-8"))
|
||||
@@ -159,6 +170,9 @@ class Cookbook:
|
||||
self.error(where, f"{f} missing")
|
||||
if ((res.get("env") or {}).get("notes") or {}) != meta.get("notes"):
|
||||
self.error(where, "the notes in meta.json and the results file differ (edited?)")
|
||||
if (meta.get("collected") or {}).get("gpu_model") != gpu:
|
||||
self.error(where, f"ran on {(meta.get('collected') or {}).get('gpu_model')}, "
|
||||
f"but it is in the {gpu} folder")
|
||||
m = meta.get("mandatory") or {}
|
||||
cmd = d / "server-cmd.txt"
|
||||
out[d.name] = {"id": d.name, "dir": d, "meta": meta, "res": res,
|
||||
@@ -169,11 +183,9 @@ class Cookbook:
|
||||
"metrics": metrics(meta, res), "used": False}
|
||||
return out
|
||||
|
||||
def _load_docs(self, sub, parse):
|
||||
def _load_docs(self, paths, parse):
|
||||
out = []
|
||||
for p in sorted((self.root / sub).rglob("*.md")):
|
||||
if p.name == "README.md":
|
||||
continue
|
||||
for p in paths:
|
||||
rel = p.relative_to(self.root).as_posix()
|
||||
try:
|
||||
front, body = split_front(p.read_text(encoding="utf-8"))
|
||||
@@ -190,11 +202,11 @@ class Cookbook:
|
||||
if missing:
|
||||
self.error(rel, "front matter lacks " + ", ".join(missing))
|
||||
return None
|
||||
rid = rel[len("recipes/"):-len(".md")]
|
||||
rid = rel[:-len(".md")]
|
||||
tp, pp = int(f.get("tp", 1)), int(f.get("pp", 1))
|
||||
want = f"{slug(f['model'])}/{slug(f['gpu'])}/{slug(f['engine'])}-{f['profile']}"
|
||||
want = f"{slug(f['gpu'])}/{slug(f['model'])}/{slug(f['engine'])}-{f['profile']}"
|
||||
if rid != want:
|
||||
self.error(rel, f"should be recipes/{want}.md for its model, gpu, engine and profile")
|
||||
self.error(rel, f"should be {want}.md for its gpu, model, engine and profile")
|
||||
if f["profile"] not in PROFILES:
|
||||
self.error(rel, f"profile {f['profile']!r}: use one of {', '.join(PROFILES)}")
|
||||
return None
|
||||
@@ -286,7 +298,7 @@ class Cookbook:
|
||||
if k not in f:
|
||||
self.error(rel, f"front matter lacks {k}")
|
||||
return None
|
||||
want = f"tried/{slug(f['model'])}/{slug(f['gpu'])}.md"
|
||||
want = f"{slug(f['gpu'])}/{slug(f['model'])}/tried.md"
|
||||
if rel != want:
|
||||
self.error(rel, f"should be {want}")
|
||||
entries = []
|
||||
@@ -397,33 +409,67 @@ class Cookbook:
|
||||
top[key] = rc
|
||||
return top
|
||||
|
||||
def gpu_recipes(self, gpu):
|
||||
return sorted((r for r in self.recipes if r["front"]["gpu"] == gpu),
|
||||
key=lambda r: (r["front"]["model"], list(PROFILES).index(r["front"]["profile"]),
|
||||
r["front"]["engine"]))
|
||||
|
||||
def headline(self, rc, star=False):
|
||||
_, label, unit, _ = PROFILES[rc["front"]["profile"]]
|
||||
return f"{num(rc['value'], 2 if unit == 'J/tok' else 1)} {unit} {label}{' ★' if star else ''}"
|
||||
|
||||
def index_md(self):
|
||||
"""The GPU table in the top-level README."""
|
||||
best = self.best()
|
||||
L = []
|
||||
gpus = list(self.config["gpus"])
|
||||
for gpu in gpus:
|
||||
rows = sorted((r for r in self.recipes if r["front"]["gpu"] == gpu),
|
||||
key=lambda r: (r["front"]["model"], list(PROFILES).index(r["front"]["profile"]),
|
||||
r["front"]["engine"]))
|
||||
if not rows:
|
||||
continue
|
||||
L += [f"### {gpu}", "", "| model | profile | engine | headline | status | recipe |",
|
||||
"|---|---|---|---|---|---|"]
|
||||
L = ["| GPU | VRAM | bandwidth (spec) | recipes | fastest for one user |", "|---|---|---|---|---|"]
|
||||
for gpu, g in self.config["gpus"].items():
|
||||
rows = self.gpu_recipes(gpu)
|
||||
fastest = [best[k] for k in sorted(best) if k[0] == gpu and k[2] == "single-user"]
|
||||
top = " · ".join(f"{rc['front']['model']}: {num(rc['value'])} t/s ({rc['front']['engine']})"
|
||||
for rc in fastest) or "none yet: wanted"
|
||||
L.append(f"| [{gpu}]({slug(gpu)}/README.md) | {g['vram_gb']} GB | {g['mem_bw_gbs']} GB/s | "
|
||||
f"{len(rows)} | {top} |")
|
||||
return "\n".join(L)
|
||||
|
||||
def gpu_md(self, gpu):
|
||||
"""A GPU folder's README, generated whole."""
|
||||
g, d, best = self.config["gpus"][gpu], slug(gpu), self.best()
|
||||
rows = self.gpu_recipes(gpu)
|
||||
L = [f"# {gpu}", "",
|
||||
"<!-- Generated by tools/cookbook.py build from cookbook.toml and this folder. Don't edit. -->",
|
||||
"", f"{g['vram_gb']} GB VRAM · {g['mem_bw_gbs']} GB/s memory bandwidth (spec) · {g['arch']}", ""]
|
||||
if g.get("notes"):
|
||||
L += [g["notes"].strip(), ""]
|
||||
if any(r["demo"] for r in rows):
|
||||
L += ["> **Demo data.** The results in this folder are synthetic, made by "
|
||||
"`tools/demo/make_demo.py`. Nothing here was measured.", ""]
|
||||
L += ["## Recipes", ""]
|
||||
if rows:
|
||||
L += ["| model | profile | engine | headline | status | recipe |", "|---|---|---|---|---|---|"]
|
||||
for rc in rows:
|
||||
f = rc["front"]
|
||||
_, label, unit, _ = PROFILES[f["profile"]]
|
||||
star = " ★" if best.get((gpu, f["model"], f["profile"])) is rc else ""
|
||||
status = "demo" if rc["demo"] else rc["status"]
|
||||
L.append(f"| {f['model']} | {f['profile']} | {f['engine']} | "
|
||||
f"{num(rc['value'], 2 if unit == 'J/tok' else 1)} {unit} {label}{star} | "
|
||||
f"{status} | [{rc['id']}](recipes/{rc['id']}.md) |")
|
||||
L.append("")
|
||||
L.append("★ the fastest recipe for that GPU, model and profile.")
|
||||
wanted = self.wanted()
|
||||
star = best.get((gpu, f["model"], f["profile"])) is rc
|
||||
L.append(f"| {f['model']} | {f['profile']} | {f['engine']} | {self.headline(rc, star)} | "
|
||||
f"{'demo' if rc['demo'] else rc['status']} | "
|
||||
f"[{f['title']}]({rc['id'].removeprefix(d + '/')}.md) |")
|
||||
L += ["", "★ the fastest recipe for that model and profile on this GPU."]
|
||||
else:
|
||||
L.append("None yet.")
|
||||
tried = [t for t in self.tried if t["front"]["gpu"] == gpu]
|
||||
if tried:
|
||||
L += ["", "## What lost", ""] + [
|
||||
f"- [{t['front']['model']}]({t['rel'].removeprefix(d + '/')}): {len(t['entries'])} variants"
|
||||
for t in tried]
|
||||
wanted = [m for gg, m in self.wanted() if gg == gpu]
|
||||
if wanted:
|
||||
L += ["", "**Wanted** (fits in VRAM, no single-user recipe yet): " +
|
||||
", ".join(f"{m} on {g}" for g, m in wanted) + "."]
|
||||
return "\n".join(L)
|
||||
L += ["", "## Wanted", "", "Fits in VRAM, no single-user recipe yet: " + ", ".join(wanted) +
|
||||
". See [CONTRIBUTING.md](../CONTRIBUTING.md)."]
|
||||
n = sum(1 for r in self.results.values() if r["dir"].parent.parent.name == d)
|
||||
where = (f"{n} result folder{'s' if n != 1 else ''} in [`results/`](results/), as bench.sh wrote them."
|
||||
if n else "None yet. Runs go in `results/` here, as bench.sh writes them.")
|
||||
L += ["", "## Results", "", where,
|
||||
"Host setup for every recipe: [docs/host-setup.md](../docs/host-setup.md)."]
|
||||
return "\n".join(L) + "\n"
|
||||
|
||||
def wanted(self):
|
||||
have = {(r["front"]["gpu"], r["front"]["model"]) for r in self.recipes
|
||||
@@ -444,6 +490,8 @@ class Cookbook:
|
||||
out[td["path"]] = fill(text, "tried", self.tried_md(td))
|
||||
readme = self.root / "README.md"
|
||||
out[readme] = fill(readme.read_text(encoding="utf-8"), "index", self.index_md())
|
||||
for gpu in self.config["gpus"]:
|
||||
out[self.root / slug(gpu) / "README.md"] = self.gpu_md(gpu)
|
||||
out[self.root / "site" / "index.html"] = site_html(self, out)
|
||||
return out
|
||||
|
||||
|
||||
Reference in new issue
Block a user