okami.mom/strata

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

Niko1221Merge f-145-q36 (Qwen3.6 start that cannot fit its buffers says so; vision_cmp --dump-ngl)e79156ae2

main
2.9 KiB71 linesraw
1"""q36_vram_refusal.py --exe E --model M : an engine start that does not fit the card says so with the numbers.
2
3Starts the engine (--serve) with demanding configurations (many slots, a long context, every expert asked for as a slot) and
4checks that each start either reaches READY or exits 1 with one of the engine's own refusals ("not enough VRAM for N slots ...",
5"not enough VRAM left for the hybrid experts' buffers and slots ...") - never a bare cudaMalloc failure.  On a card that holds
6every configuration the check only reports that they started.  The engine is stopped right after READY.
7
8  python q36_vram_refusal.py --exe build/strata-q36 --model Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf
9"""
10import argparse, subprocess, sys, threading, time
11
12CONFIGS = [
13    ["--max-context", "8192", "--batch", "8", "--expert-slots", "256"],
14    ["--max-context", "32768", "--batch", "8", "--expert-slots", "256"],
15    ["--max-context", "8192", "--batch", "8"],
16    ["--max-context", "32768", "--batch", "8"],
17    ["--max-context", "131072", "--batch", "8"],
18]
19CLEAR = ("not enough VRAM for", "not enough VRAM left for the hybrid experts")
20RAW = ("cudaMalloc", "hipMalloc", "out of memory")
21
22
23def run(exe, model, extra, timeout):
24    p = subprocess.Popen([exe, "--serve", "--model", model, *extra], stdin=subprocess.PIPE, stdout=subprocess.PIPE,
25                         stderr=subprocess.PIPE, text=True, bufsize=1)
26    err = []
27    t = threading.Thread(target=lambda: err.extend(p.stderr), daemon=True)
28    t.start()
29    ready = False
30    try:
31        for line in p.stdout:
32            if line.startswith("READY"):
33                ready = True
34                p.stdin.write("STOP\n")
35                p.stdin.flush()
36                break
37        p.wait(timeout=timeout)
38    except subprocess.TimeoutExpired:
39        p.kill()
40    t.join(5)
41    return ready, p.returncode, "".join(err)
42
43
44def main():
45    ap = argparse.ArgumentParser()
46    ap.add_argument("--exe", required=True)
47    ap.add_argument("--model", required=True)
48    ap.add_argument("--timeout", type=int, default=900)
49    a = ap.parse_args()
50    ok = True
51    for extra in CONFIGS:
52        time.sleep(5)   # the previous engine's VRAM is back
53        ready, rc, err = run(a.exe, a.model, extra, a.timeout)
54        if ready:
55            print("START  %-62s ready" % " ".join(extra))
56            continue
57        clear = [l for l in err.splitlines() if any(c in l for c in CLEAR)]
58        raw = [l for l in err.splitlines() if any(r in l for r in RAW)]
59        good = bool(clear) and not raw and rc == 1
60        ok &= good
61        if not good:
62            for l in err.splitlines()[-6:]:
63                print("    | " + l[:240])
64        print("%s %-62s exit %s: %s" % ("REFUSE" if good else "FAIL  ", " ".join(extra), rc,
65                                        (clear or raw or err.splitlines()[-1:] or ["(no output)"])[0][:260]))
66    print("GATE", "PASS" if ok else "FAIL")
67    return 0 if ok else 1
68
69
70if __name__ == "__main__":
71    sys.exit(main())