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
2.4 KiB50 linesraw
1#!/usr/bin/env python3
2"""The 24-prompt identity gate against a RECORDED set of answers: start the server of CONFIG, send the 24 greedy prompts of
3research/tools/dgx-spark-2026-10/dgx_quality24.py, and compare every answer byte for byte with the answers in REFERENCE.json (a file research/tools/dgx-spark-2026-10/dgx_quality24.py wrote:
4its rows hold "a" and "b"; --side picks which one is the reference, "a" by default).
5
6    python research/tools/dgx-spark-2026-10/dgx_gate_ref.py CONFIG REFERENCE.json OUT.json [--side a|b] [--port 8091]
7
8Exit code 0 = every answer identical. This is the gate a build on a DGX Spark has to pass against the answers the 2026-10-26 handover
9recorded (bench/quality24-fork.json for IQ3_S, bench/quality24-nvfp4-fork.json for NVFP4).
10"""
11from __future__ import annotations
12
13import argparse
14import json
15import sys
16from pathlib import Path
17
18sys.path.insert(0, str(Path(__file__).resolve().parent))
19import dgx_quality24 as q  # noqa: E402
20
21
22def main() -> int:
23    ap = argparse.ArgumentParser()
24    ap.add_argument("config")
25    ap.add_argument("reference")
26    ap.add_argument("out")
27    ap.add_argument("--side", choices=("a", "b"), default="a")
28    ap.add_argument("--port", type=int, default=8091)
29    a = ap.parse_args()
30    ref = json.loads(Path(a.reference).read_text(encoding="utf-8"))
31    rows = ref["rows"]
32    if [r["prompt"] for r in rows] != q.PROMPTS:
33        print("the reference was made with other prompts than research/tools/dgx-spark-2026-10/dgx_quality24.py has now; the gate is not comparable", file=sys.stderr)
34        return 2
35    mine = q.run_config(a.config, a.port, "ref")
36    out = [{"prompt": r["prompt"], "reference": r[a.side], "answer": m, "identical": r[a.side] == m} for r, m in zip(rows, mine)]
37    same = sum(1 for r in out if r["identical"])
38    Path(a.out).write_text(json.dumps({"identical": same, "total": len(out), "reference": a.reference, "side": a.side, "rows": out}, indent=1),
39                           encoding="utf-8")
40    print(f"{same} of {len(out)} answers identical to {Path(a.reference).name} (side {a.side})")
41    for i, r in enumerate(out):
42        if not r["identical"]:
43            print(f"  differs at prompt {i}: {r['prompt'][:60]!r}")
44            print(f"    reference: {r['reference'][:90]!r}")
45            print(f"    this run : {r['answer'][:90]!r}")
46    return 0 if same == len(out) else 1
47
48
49if __name__ == "__main__":
50    sys.exit(main())