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
4.4 KiB111 linesraw
1#!/usr/bin/env python3
2"""The drop's acceptance gate in one command: setup detection, one benchmark cell, the identity gate and a needle, each
3with a band that the numbers on a DGX Spark should land in. Exit code 0 = all passed.
4
5    python research/tools/dgx-spark-2026-10/dgx_smoke.py [--config strata-iq3_s.json] [--tokens 12000] [--data-dir ~/Strata-data]
6
7Bands are deliberately loose (they must survive page-cache state and drift); a failure means something is wrong, not that
8the machine is 5% slower than the number in the documents.
9"""
10from __future__ import annotations
11
12import argparse
13import json
14import os
15import re
16import subprocess
17import sys
18import tempfile
19import time
20from pathlib import Path
21
22ROOT = Path(__file__).resolve().parents[3]
23PY = sys.executable
24WORK = Path(tempfile.mkdtemp(prefix="dgx-smoke-"))      # this run's own scratch folder (never a fixed /tmp name another run could share)
25
26
27def sh(cmd: str) -> tuple[int, str]:
28    p = subprocess.run(cmd, shell=True, cwd=str(ROOT), capture_output=True, text=True, timeout=3600)
29    return p.returncode, (p.stdout or "") + (p.stderr or "")
30
31
32def check_setup(data_dir: str) -> tuple[bool, str]:
33    rc, out = sh(f"{PY} setup.py --check --yes --data-dir '{data_dir}' 2>&1 | head -8")
34    low = out.lower()
35    ok = "unified memory" in low and "arm64" in low
36    gpu = next((line.strip() for line in out.splitlines() if "GPU:" in line), "")
37    return ok, gpu or (out.strip().splitlines()[0] if out.strip() else "no output")
38
39
40def bench(config: str, cell: str, out_dir: str) -> dict | None:
41    rc, out = sh(f"{PY} tools/dgx_bench.py --config {config} --tag smoke --cells {cell} --rounds 1 --port 8093 "
42                 f"--out {out_dir} 2>&1")
43    m = re.search(r"prompt_n\s+(\d+)\s+prompt\s+([0-9.]+)\s+tok/s\s+decode\s+([0-9.]+)", out)
44    if not m:
45        return None
46    return {"prompt_n": int(m.group(1)), "prompt": float(m.group(2)), "decode": float(m.group(3))}
47
48
49def identity(config: str) -> tuple[bool, str]:
50    base = json.loads((ROOT / config).read_text())
51    off = dict(base)
52    off["args"] = list(base["args"])
53    env = dict(base.get("env") or {})
54    env["STRATA_PF_FUSED"] = "0"
55    off["env"] = env
56    off_path = WORK / "nofused.json"
57    off_path.write_text(json.dumps(off, indent=1))
58    rc, out = sh(f"{PY} research/tools/dgx-spark-2026-10/dgx_quality.py {off_path} {config} {WORK / 'quality.json'} 2>&1")
59    m = re.search(r"(\d+) of (\d+) answers identical", out)
60    if not m:
61        return False, out.strip()[-200:]
62    return m.group(1) == m.group(2), out.strip().splitlines()[-1]
63
64
65def needle(config: str, tokens: int) -> tuple[bool, str]:
66    rc, out = sh(f"{PY} research/tools/dgx-spark-2026-10/dgx_needle.py --config {config} --tokens {tokens} --runs 2 2>&1")
67    m = re.search(r"(\d+) of (\d+) recalled", out)
68    if not m:
69        return False, out.strip()[-200:]
70    return m.group(1) == m.group(2), out.strip().splitlines()[-1]
71
72
73def main() -> int:
74    ap = argparse.ArgumentParser()
75    ap.add_argument("--config", default="strata-iq3_s.json")
76    ap.add_argument("--cell", default="4096:0:256")
77    ap.add_argument("--tokens", type=int, default=12000)
78    ap.add_argument("--data-dir", default=os.environ.get("STRATA_DATA_DIR") or str(Path.home() / "Strata-data"),
79                    help="the data folder setup uses (default: $STRATA_DATA_DIR or ~/Strata-data)")
80    a = ap.parse_args()
81    results = []
82    t0 = time.time()
83
84    ok, detail = check_setup(a.data_dir)
85    results.append(("setup detection", ok, detail))
86
87    b = bench(a.config, a.cell, str(WORK / "bench"))
88    if b is None:
89        results.append(("bench cell", False, "no parsable cell"))
90    else:
91        ok = b["prompt"] > 800 and b["decode"] > 30
92        results.append(("bench cell", ok, f"{b['prompt']:.0f} prompt / {b['decode']:.1f} decode tok/s"))
93
94    ok, detail = identity(a.config)
95    results.append(("identity, fused vs MMQ", ok, detail))
96
97    ok, detail = needle(a.config, a.tokens)
98    results.append(("needle, recall", ok, detail))
99
100    print()
101    width = max(len(n) for n, _, _ in results)
102    for name, ok, detail in results:
103        print(f"{'PASS' if ok else 'FAIL'}  {name:<{width}}  {detail}")
104    bad = [n for n, ok, _ in results if not ok]
105    print(f"\n{len(results) - len(bad)} of {len(results)} passed in {time.time() - t0:.0f} s"
106          + (f"; failed: {', '.join(bad)}" if bad else ""))
107    return 0 if not bad else 1
108
109
110if __name__ == "__main__":
111    sys.exit(main())