code wiki / (root) / nx_qwen_reader_bench_gate.nx

nx_qwen_reader_bench_gate.nx

buildroot/runtime/nx_qwen_reader_bench_gate.nx

18508 B419 linesdepth 10pulls 22 transitivereach 0 importersview sourcekind gate/prooftopic qwen
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_nofloat_serve_core.nx nx_qa_score_lib.nx nx_qwen_reader_bench_gate.nx

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

main qrb_ps nsv_log sys_write qrb_pn sys_mmap nsv_catn sys_mmap ↻ sys_write ↻ nsv_init sys_now_ms sys_mmap ↻ sys_clock_gettime_mono nsv_log ↻ nf_pool nx_pool_new nx_hw_worker_count nx_hw_cpu_count sys_mmap ↻ sys_munmap sys_mmap ↻ nx_chan_new sys_mmap ↻ _nx_chan_cell sys_thread_create nx_thread_spawn sys_mmap ↻ nx_thread_spawn_fn sys_mmap ↻ sys_mmap ↻ nsv_load_meta sys_mmap ↻ nsv_log ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close nx_gguf_parse

structs

none

consts

16const QRB_MODEL: *u8 = "/home/elderwesto/nx_stage/nx_real_model.gguf"
17const 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.
18const 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.
19const QRB_MAXNEW: i64 = 16
20const QRB_MODE: i64 = 0 // 0 = i32 lossless (faithful), not i8 fast -- measure THE model, no approximation
21const QRB_RESULTS: *u8 = "knowledge/index/qwen_reader_results.tsv" // resume-accumulate ledger: "idx<TAB>f1\n"

functions

23func 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 }
called by 1: main calls 3: sys_mmapnsv_catnsys_write
24func qrb_ps(s: *u8) -> i64 { nsv_log(s); return 0 }
called by 1: main calls 1: nsv_log
27func qrb_lc(c: i64) -> i64
called by 1: qrb_norm
33func 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 }
called by 2: qrb_sel_ctxqrb_f1 calls 1: qrb_lc
36func qrb_words(buf: *u8, n: i64, starts: *i64, lens: *i64) -> i64
called by 2: qrb_sel_ctxqrb_f1
49func qrb_weq(a: *u8, ao: i64, al: i64, b: *u8, bo: i64, bl: i64) -> i64
called by 2: qrb_sel_ctxqrb_f1
64func qrb_sel_ctx(cp: *u8, cn: i64, qp: *u8, qn: i64, sel: *i64) -> i64
called by 1: main calls 3: qrb_normqrb_wordsqrb_weq
196func qrb_f1(pred: *u8, pn: i64, gold: *u8, gn: i64, sc: *i64) -> i64
229func qrb_read_done(sumptr: *i64) -> i64
256func qrb_append_result(idx: i64, f1: i64) -> i64
271func main(argc: i64, argv: *i64) -> i64