nx_qwen_reader_bench_gate.nx
buildroot/runtime/nx_qwen_reader_bench_gate.nx
about
nx_qwen_reader_bench_gate.nx -- IN-PROCESS sovereign benchmark of the pretrained no-float Qwen2.5-0.5B as an
extractive SQuAD reader. Loads the model ONCE (nsv_init -> dequant-once caches), loops the real
(question, context, gold) rows from knowledge/index/reader_rows.bin, greedy-generates the answer IN-PROCESS
(NO HTTP, NO daemon, NO socket), scores integer token-F1 vs gold, prints per-row detail + the mean permille.
WHY THIS EXISTS: the prior PowerShell->HTTP->:8032 harness was fragile (the daemon's request path could not
take the long SQuAD contexts -> connection dropped mid-batch) AND it violated doctrine ("sovereign gates,
not curl harnesses"). Rule#3: stop patching the HTTP path -- rewrite the measurement as an in-process gate.
Baselines for context (printed with the result): from-scratch neural reader F1~81 ; mechanical reader F1=251.
usage: nx_qwen_reader_bench_gate [N] (default N=30 ; i32 lossless ; greedy) Sovereign: nx_nofloat_serve_core.
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_nofloat_serve_core.nxnx_qa_score_lib.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 16 | const QRB_MODEL: *u8 = "/home/elderwesto/nx_stage/nx_real_model.gguf" |
| 17 | const QRB_CTXCAP: i64 = 440 // context truncation (chars); 1-shot @ 440 (440 ctx + ~370 prefix/q <= 900 guard). ⚠2-shot@380 REVERTED — the standalone +104 (722 vs 618) was a SINGLE-GOLD artifact; on-protocol multi-alias it did NOT hold (SQuAD 427 < 510). See arc memory. |
| 18 | const QRB_MAXPROMPT: i64 = 900 // hard char guard: sized for the FIXED tokenizer + NSV_MAXT=384 (900/2.5-worst-bpe = 360 tok + MAXNEW 16 = 376 < 384). Was 600 = a stale relic of the old 192-tok window that spuriously SKIPPED rows 8/9 (po=607) to 0. |
| 19 | const QRB_MAXNEW: i64 = 16 |
| 20 | const QRB_MODE: i64 = 0 // 0 = i32 lossless (faithful), not i8 fast -- measure THE model, no approximation |
| 21 | const QRB_RESULTS: *u8 = "knowledge/index/qwen_reader_results.tsv" // resume-accumulate ledger: "idx<TAB>f1\n" |
functions
| 23 | func qrb_pn(v: i64) -> i64 { let b: *u8=sys_mmap(32); let e: i64=nsv_catn(b,0,v); sys_write(1,b,e); return 0 } |
| 24 | func qrb_ps(s: *u8) -> i64 { nsv_log(s); return 0 } |
| 27 | func qrb_lc(c: i64) -> i64 called by 1: qrb_norm |
| 33 | func qrb_norm(src: *u8, n: i64, dst: *u8) -> i64 { var i: i64=0; while i<n { dst[i]=qrb_lc(src[i] as i64) as u8; i=i+1 } return n } |
| 36 | func qrb_words(buf: *u8, n: i64, starts: *i64, lens: *i64) -> i64 |
| 49 | func qrb_weq(a: *u8, ao: i64, al: i64, b: *u8, bo: i64, bl: i64) -> i64 |
| 64 | func qrb_sel_ctx(cp: *u8, cn: i64, qp: *u8, qn: i64, sel: *i64) -> i64 |
| 196 | func qrb_f1(pred: *u8, pn: i64, gold: *u8, gn: i64, sc: *i64) -> i64 |
| 229 | func qrb_read_done(sumptr: *i64) -> i64 |
| 256 | func qrb_append_result(idx: i64, f1: i64) -> i64 |
| 271 | func main(argc: i64, argv: *i64) -> i64 |