code wiki / (root) / nx_llm_batch_serve.nx

nx_llm_batch_serve.nx

buildroot/runtime/nx_llm_batch_serve.nx

12980 B288 linesdepth 16pulls 71 transitivereach 0 importersview sourcekind servicetopic llm
docsdependenciesstructsconstsfunctions

about

nx_llm_batch_serve.nx -- the SOVEREIGN CONTINUOUS-BATCHING LLM SEAT. Wraps nx_llm_sched (batch-invariance GATED by nx_llm_sched_gate) in the proven nx_f32_llm_serve accept-loop pattern: binds 127.0.0.1:11435 (:11434 stays the production single-stream seat), accept WITH TIMEOUT between decode rounds -- new POST /chat requests admit MID-FLIGHT and join the running batch; each round = ONE batched forward for every active request; finished requests get their OpenAI-chat JSON and close. Modes: (no args) = serve forever. `once <N>` = serve exactly N requests then exit 0 (the testable smoke mode). expect: LIVE on :11435 (blocks) / exit 0 in once-mode. license_tier: ORIGINAL module: nishi-core.seat.llm-batch

dependencies 29 imports · 0 importers

nx_syscalls.nx nx_connect.nx nx_tier.nx nx_le.nx nx_bpe.nx nx_gguf.nx nx_gguf_load.nx nx_gguf_meta.nx nx_f32.nx nx_f32_kv_cache.nx nx_llm_batch_serve.nx

diagram shows first 10 each side; +19 more imports, +0 more importers in the complete lists below.

imports: nx_syscalls.nxnx_connect.nxnx_tier.nxnx_le.nxnx_bpe.nxnx_gguf.nxnx_gguf_load.nxnx_gguf_meta.nxnx_f32.nxnx_f32_kv_cache.nxnx_f32_lazy_weight.nxnx_f32_llama_block.nxnx_f32_llama_block_v4.nxnx_f32_llama_stack_v4.nxnx_f32_llama_layer_lazy_load.nxnx_f32_llm.nxnx_f32_llm_v4.nxnx_f32_llm_read_dims.nxnx_f32_bpe_load.nxnx_f32_llm_special_tokens.nxnx_f32_sampler.nxnx_prng.nxnx_reasoning.nxnx_kvcache.nxnx_f32_attn_paged.nxnx_f32_llama_v4p.nxnx_f32_llama_v4b.nxnx_llm_sched.nxnx_http_client.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main bs_atoi bs_puts sys_write sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close sys_exit nx_gguf_parse nx_le_read_u32 nx_le_read_u64 nx_le_read_u32 ↻ _gguf_skip_value nx_le_read_u64 ↻ nx_le_read_u32 ↻ _gguf_skip_value ↻ sys_mmap ↻ nx_f32_llama_model_alloc sys_mmap ↻ nx_f32_llm_read_dims_from_ sys_mmap ↻ nx_gguf_meta_find nx_le_read_u64 ↻ nx_le_read_u32 ↻ _gmeta_bytes_equal nx_gguf_skip_value _gguf_skip_value ↻ nx_gguf_meta_read_string_l nx_le_read_u64 ↻ nx_gguf_meta_read_string_p _fld_read_arch_u32 sys_mmap ↻ _fld_concat_key nx_gguf_meta_find ↻ nx_gguf_meta_read_u32 nx_le_read_u32 ↻

structs

none

consts

45const NX_BSEAT_PORT: i64 = 11435

functions

47func bs_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main calls 1: sys_write
48func bs_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
49func bs_find(buf: *u8, n: i64, ndl: *u8, nl: i64) -> i64
55func bs_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){ dst[off]=s[i]; off=off+1; i=i+1 } return off }
called by 1: bs_respond
56func bs_write_all(fd: i64, buf: *u8, n: i64) -> i64 { var off: i64=0; while off<n { let w: i64=sys_write(fd, ((buf as i64)+off) as *u8, n-off); if w<=0 { off=n } else { off=off+w } } return 0 }
called by 2: bs_respondmain calls 1: sys_write
57func bs_extract_prompt(body: *u8, blen: i64, out: *u8, cap: i64) -> i64
called by 1: main calls 2: bs_slenbs_find
78func bs_json_esc(src: *u8, sn: i64, dst: *u8, cap: i64) -> i64
called by 1: bs_respond
92func bs_atoi(s: *u8) -> i64
called by 1: main
106func bs_respond(S: *NxLlmSched, slot: nx_int, fd: i64,
126func main(argc: i64, argv: *i64) -> i64