nx_nofloat_serve_core.nx
buildroot/runtime/nx_nofloat_serve_core.nx
about
nx_nofloat_serve_core.nx -- the PURE CORE of the no-float LLM serve organ (2026-07-10): model session +
greedy generation + HTTP request handler, NO sockets (the daemon shell owns those; the gate exercises this
core in-process with synthetic requests -- the proven pure-core+gate+daemon idiom).
nsv_init(path) one-time: load GGUF, tokenizer meta, dequant-once i32 (lossless hero) + i8 (fast) caches.
nsv_generate(gp) ctx-bundle: sequential CACHED prefill (decode_step per prompt token -- mathematically
identical to batch prefill under causal masking) then greedy decode; text out through
the byte-level-BPE inverse (nx_nofloat_tokdec) so ' Paris' renders as real text.
nsv_handle(...) routes: GET / (app page) GET /health GET /api POST /gen {prompt,max_new,mode}.
license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 11 imports · 16 importers
diagram shows first 10 each side; +1 more imports, +6 more importers in the complete lists below.
imports: nx_syscalls.nxnx_tier.nxnx_le.nxnx_tensor.nxnx_gguf.nxnx_gguf_load.nxnx_gguf_meta.nxnx_nofloat_llm.nxnx_nofloat_tok.nxnx_nofloat_tokdec.nxnx_nofloat_arch.nx
imported by: nx_code_embed_gate.nxnx_coder_gen_nf.nxnx_forge_bestof.nxnx_forge_local_gen.nxnx_forge_repair.nxnx_gpu_embed_gate.nxnx_gramdec_lib.nxnx_jina_embed_gate.nxnx_nofloat_prefix_cache_gate.nxnx_nofloat_serve.nxnx_nofloat_serve_gate.nxnx_nofloat_speed_bench.nxnx_propose_verify_lib.nxnx_qwen_extract.nxnx_qwen_reader_bench_gate.nxnx_research_synth_qwen.nx
structs
| none |
consts
| 22 | const NSV_MAXT: i64 = 2048 // final prompt+gen TOKEN cap (KV cache rows). L2 raise 384->2048 (FORGE 2026-07-12) |
| 26 | const NSV_MAXIN: i64 = 16384 // max prompt BYTES for the tokenizer's byte-level pretokenize scratch (tok_ptr/tok_len). |
| 30 | const NSV_MAXNEW: i64 = 512 // per-request generation cap (L2 raise 96->512 for whole small organs) |
| 31 | const NSV_EOS1: i64 = 151643 |
| 32 | const NSV_EOS2: i64 = 151645 |
functions
| 63 | func nsv_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 64 | func nsv_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){dst[off+i]=s[i];i=i+1} return off+i } |
| 65 | func nsv_catb(dst: *u8, off: i64, s: *u8, n: i64) -> i64 { var i: i64=0; while i<n {dst[off+i]=s[i];i=i+1} return off+n } |
| 66 | func nsv_catn(dst: *u8, off: i64, v: i64) -> i64 called by 9: nsv_respnsv_handle_streamnsv_handlepvl_prompt_completepvl_prompt_solvepvl_prompt_solve_chat+3 calls 1: sys_mmap |
| 79 | func nsv_log(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 87 | func nsv_load_meta(path: *u8) -> i64 called by 1: nsv_init calls 13: sys_mmapnsv_logsys_read_filenx_gguf_parsenac_read_confignx_gguf_tensor_at+7 |
| 156 | func nsv_alloc_scratch() -> i64 |
| 219 | func nsv_init_i8(path: *u8) -> i64 |
| 223 | func nsv_init(path: *u8) -> i64 called by 19: mainmainmainmainmainmain+13 calls 6: sys_now_msnsv_lognf_poolnsv_load_metansv_alloc_scratchnsv_build_caches |
| 242 | func nsv_build_caches() -> i64 |
| 277 | func nsv_step(pos: i64, mode: i64) -> i64 |
| 288 | func nsv_rand(sp: *i64) -> i64 called by 1: nsv_sample |
| 302 | func nsv_sample(sp: *i64) -> i64 |
| 375 | func nsv_next_token(np: *i64) -> i64 |
| 395 | func nsv_emit_piece(tok: i64, ep: *i64) -> i64 |
| 424 | func nsv_chatml_ids(content: *u8, clen: i64) -> i64 |
| 462 | func nsv_generate(gp: *i64) -> i64 |
| 549 | func nsv_kv_snapshot(P: i64) -> i64 |
| 573 | func nsv_kv_restore() -> i64 called by 1: nsv_generate_pfx |
| 598 | func nsv_kv_snapshot_save(path: *u8) -> i64 |
| 616 | func nsv_kv_snapshot_load(path: *u8) -> i64 |
| 648 | func nsv_generate_pfx(gp: *i64, prefix_len: i64, use_snap: i64) -> i64 called by 4: mainlg_taskmainmain calls 11: nsv_chatml_idstk_bpe_encodesys_mmapsys_now_msnsv_kv_restoredequant_row+5 |
| 759 | func nsv_gwall(fd: i64, buf: *u8, count: i64) -> i64 |
| 770 | func nsv_grall(fd: i64, buf: *u8, count: i64) -> i64 |
| 781 | func nsv_gpu_connect() -> i64 |
| 801 | func nsv_embed(text: *u8, tlen: i64, mode: i64, outvec: *i64) -> i64 called by 4: ce_embedmaince_embednsv_handle calls 9: tk_bpe_encodensv_gpu_connectsys_mmapdequant_rownsv_gwallsys_close+3 |
| 839 | func nsv_resp(resb: *u8, rescap: i64, code: i64, ctype: *u8, body: *u8, blen: i64) -> i64 |
| 853 | func nsv_jesc1(dst: *u8, o: i64, c: i64) -> i64 called by 1: nsv_jesc |
| 864 | func nsv_jesc(dst: *u8, off: i64, src: *u8, n: i64) -> i64 |
| 871 | func nsv_jkey(body: *u8, n: i64, key: *u8) -> i64 |
| 889 | func nsv_jstr(body: *u8, n: i64, p: i64, dst: *u8, dcap: i64) -> i64 |
| 915 | func nsv_jint(body: *u8, n: i64, p: i64, def: i64) -> i64 called by 1: nsv_parse_gen |
| 939 | func nsv_page(dst: *u8, cap: i64) -> i64 |
| 947 | func nsv_parse_gen(req: *u8, rn: i64, gp: *i64) -> i64 |
| 989 | func nsv_embed_prefix(task: *u8, tl: i64, kq: i64) -> *u8 called by 1: nsv_handle |
| 1012 | func nsv_parse_embed(req: *u8, rn: i64, ep: *i64) -> i64 |
| 1064 | func nsv_handle_stream(fd: i64, req: *u8, rn: i64) -> i64 |
| 1107 | func nsv_handle(req: *u8, rn: i64, resb: *u8, rescap: i64) -> i64 |