code wiki / (root) / nx_nofloat_serve_core.nx

nx_nofloat_serve_core.nx

buildroot/runtime/nx_nofloat_serve_core.nx

58784 B1244 linesdepth 9pulls 20 transitivereach 37 importersview sourcekind librarytopic nofloat
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_tier.nx nx_le.nx nx_tensor.nx nx_gguf.nx nx_gguf_load.nx nx_gguf_meta.nx nx_nofloat_llm.nx nx_nofloat_tok.nx nx_nofloat_tokdec.nx nx_nofloat_serve_core.nx nx_code_embed_gate.nx nx_coder_gen_nf.nx nx_forge_bestof.nx nx_forge_local_gen.nx nx_forge_repair.nx nx_gpu_embed_gate.nx nx_gramdec_lib.nx nx_jina_embed_gate.nx nx_nofloat_prefix_cache_gate.nx nx_nofloat_serve.nx

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

22const NSV_MAXT: i64 = 2048 // final prompt+gen TOKEN cap (KV cache rows). L2 raise 384->2048 (FORGE 2026-07-12)
26const NSV_MAXIN: i64 = 16384 // max prompt BYTES for the tokenizer's byte-level pretokenize scratch (tok_ptr/tok_len).
30const NSV_MAXNEW: i64 = 512 // per-request generation cap (L2 raise 96->512 for whole small organs)
31const NSV_EOS1: i64 = 151643
32const NSV_EOS2: i64 = 151645

functions

63func nsv_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
64func 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 }
65func 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 }
66func nsv_catn(dst: *u8, off: i64, v: i64) -> i64
79func 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 }
87func nsv_load_meta(path: *u8) -> i64
156func nsv_alloc_scratch() -> i64
called by 1: nsv_init calls 3: nsv_logsys_mmaprope_freqs
219func nsv_init_i8(path: *u8) -> i64
called by 5: mainmainmainmainmain calls 1: nsv_init
223func nsv_init(path: *u8) -> i64
242func nsv_build_caches() -> i64
277func nsv_step(pos: i64, mode: i64) -> i64
288func nsv_rand(sp: *i64) -> i64
called by 1: nsv_sample
302func nsv_sample(sp: *i64) -> i64
375func nsv_next_token(np: *i64) -> i64
395func nsv_emit_piece(tok: i64, ep: *i64) -> i64
424func nsv_chatml_ids(content: *u8, clen: i64) -> i64
462func nsv_generate(gp: *i64) -> i64
549func nsv_kv_snapshot(P: i64) -> i64
called by 1: nsv_generate_pfx calls 1: sys_mmap
573func nsv_kv_restore() -> i64
called by 1: nsv_generate_pfx
598func nsv_kv_snapshot_save(path: *u8) -> i64
616func nsv_kv_snapshot_load(path: *u8) -> i64
648func nsv_generate_pfx(gp: *i64, prefix_len: i64, use_snap: i64) -> i64
759func nsv_gwall(fd: i64, buf: *u8, count: i64) -> i64
called by 1: nsv_embed calls 1: sys_write
770func nsv_grall(fd: i64, buf: *u8, count: i64) -> i64
called by 1: nsv_embed calls 1: sys_read
781func nsv_gpu_connect() -> i64
801func nsv_embed(text: *u8, tlen: i64, mode: i64, outvec: *i64) -> i64
839func nsv_resp(resb: *u8, rescap: i64, code: i64, ctype: *u8, body: *u8, blen: i64) -> i64
called by 1: nsv_handle calls 3: nsv_catnsv_catnnsv_catb
853func nsv_jesc1(dst: *u8, o: i64, c: i64) -> i64
called by 1: nsv_jesc
864func nsv_jesc(dst: *u8, off: i64, src: *u8, n: i64) -> i64
called by 2: nsv_emit_piecensv_handle calls 1: nsv_jesc1
871func nsv_jkey(body: *u8, n: i64, key: *u8) -> i64
889func nsv_jstr(body: *u8, n: i64, p: i64, dst: *u8, dcap: i64) -> i64
915func nsv_jint(body: *u8, n: i64, p: i64, def: i64) -> i64
called by 1: nsv_parse_gen
939func nsv_page(dst: *u8, cap: i64) -> i64
called by 1: nsv_handle calls 1: nsv_cat
947func nsv_parse_gen(req: *u8, rn: i64, gp: *i64) -> i64
989func nsv_embed_prefix(task: *u8, tl: i64, kq: i64) -> *u8
called by 1: nsv_handle
1012func nsv_parse_embed(req: *u8, rn: i64, ep: *i64) -> i64
called by 1: nsv_handle calls 3: sys_mmapnsv_jkeynsv_jstr
1064func nsv_handle_stream(fd: i64, req: *u8, rn: i64) -> i64
1107func nsv_handle(req: *u8, rn: i64, resb: *u8, rescap: i64) -> i64