okami.mom/strata

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

Niko1221Merge f-142b-serve into f-1426e1085c1d

main
2.7 KiB59 linesraw
1"""Use remaining authorized reserve for IQ3 260K recall at two extra positions."""
2import json
3from pathlib import Path
4import socket
5import subprocess
6import sys
7import time
8
9from strata_bench_continue import Continuation, b
10
11
12def main():
13    with socket.socket() as sock:
14        if sock.connect_ex(("127.0.0.1", b.PORT)) == 0:
15            raise RuntimeError("Benchmark service is occupied; it was preserved")
16    runner = Continuation(["iq3_xxs", "iq3_s"])
17    (b.OUT / "supplement.pid").write_text(str(b.os.getpid()))
18    supervisor = subprocess.Popen([sys.executable, str(b.SCRIPT), "--watchdog", str(b.os.getpid()),
19        str(runner.clock["measurement_stop_epoch"]+300)], stdout=subprocess.DEVNULL,
20        stderr=subprocess.DEVNULL, creationflags=b.FLAGS)
21    try:
22        runner.budget("reserve_iq3_recall", max(0, runner.hard-time.monotonic()))
23        runner.init_tokenizer()
24        runner.inventory()
25        for model in ("iq3_xxs", "iq3_s"):
26            eligible = [r for r in runner.rows if r["model"] == model and r["group"] == "speed"
27                and r.get("target") == 260000 and r.get("ok") and r.get("token_count_matches")
28                and r.get("engine_environment", {}).get("STRATA_UNBUFFERED_LOAD") == "1"]
29            estimate = max((r["client_elapsed_s"] for r in eligible), default=900)*2 + 120
30            if not eligible or runner.left() < estimate:
31                runner.event("supplement_skipped", requested_model=model,
32                    reason="no successful main 260K trial or insufficient reserve for both positions",
33                    estimated_seconds=estimate, remaining_seconds=runner.left())
34                continue
35            def run():
36                runner.start(model, 262144)
37                for depth in (10, 90):
38                    label = f"recall-260000-d{depth}"
39                    if any(r["model"] == model and r["label"] == label and r.get("ok")
40                        and r.get("engine_environment", {}).get("STRATA_UNBUFFERED_LOAD") == "1" for r in runner.rows):
41                        continue
42                    runner.perform(label, runner.make(260000, "code", 9, depth), 260000,
43                        group="recall", max_tokens=40, expected=f"amber-quartz-260000-9-{depth}")
44            runner.safe_block(run)
45            runner.stop()
46        runner.event("supplement_finished")
47    finally:
48        if runner.active_worker and runner.active_worker.poll() is None:
49            b.kill_tree(runner.active_worker)
50        for job in runner.child_jobs:
51            b.kill_tree(job)
52        runner.stop()
53        runner.monitor.done.set()
54        if supervisor.poll() is None:
55            supervisor.terminate()
56
57
58if __name__ == "__main__":
59    main()