code wiki / _hdl_build / nx_f32_embed_gate.nx

nx_f32_embed_gate.nx

buildroot/runtime/_hdl_build/nx_f32_embed_gate.nx

8094 B155 linesdepth 13pulls 58 transitivereach 0 importersview sourcekind gate/prooftopic f32
docsdependenciesstructsconstsfunctions

about

nx_f32_embed_gate.nx -- KAT for the NEURAL EMBEDDING TAP (rung 1 of the retrieval ladder). WHY THIS GATE IS SHAPED THIS WAY. Our count-based PPMI reranker was measured on BEIR/nfcorpus at 255 permille against BM25's 305 -- a LOSS -- and the banked conclusion was: A GATE PROVING A MECHANISM ON A FIXTURE HAS NOT MEASURED THE MODEL. So this gate deliberately does NOT assert "an embedding came out non-zero"; that passes on noise. It asserts SEMANTIC ORDERING a count model cannot fake: the related pair shares almost NO surface tokens (cat/kitten, sat/rested, mat/rug), so a lexical or co-occurrence model has nothing to latch onto. Only learned semantics ranks it correctly. TEETH (both polarities -- a gate that can only pass is furniture): 1 NON-VACUITY : the embedding is not all-zero 2 SELF-SIM : cos(x,x) == 1000 permille -- the metric itself is sane 3 SEMANTIC : related pair scores ABOVE unrelated pair <- the real assertion 4 NEG-CONTROL : the unrelated pair must NOT also score near-1; if everything is similar to everything the space has COLLAPSED and tooth 3 passes for the wrong reason 5 DETERMINISM : same input twice = identical vector (integer f32, no hidden RNG) license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 11 imports · 0 importers

nx_syscalls.nx nx_tier.nx nx_bpe.nx nx_gguf.nx nx_gguf_load.nx nx_gguf_meta.nx nx_f32_llm_read_dims.nx nx_f32_bpe_load.nx nx_f32.nx nx_f32_div.nx nx_f32_embed_gate.nx

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

imports: nx_syscalls.nxnx_tier.nxnx_bpe.nxnx_gguf.nxnx_gguf_load.nxnx_gguf_meta.nxnx_f32_llm_read_dims.nxnx_f32_bpe_load.nxnx_f32.nxnx_f32_div.nxnx_f32_llm_v4.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close eg_w sys_write 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 ↻ _fld_read_vocab_size_from_

structs

none

consts

30const EG_MAXTOK: i64 = 256
31const EG_PERMILLE: i64 = 1000
33const EG_SELF_TOL: i64 = 2
36const EG_COLLAPSE_PERMILLE: i64 = 990
37const EG_KV_SLOTS: i64 = 512
39const EG_EPS: i64 = 0x358637BD
40const EG_ATTN_SCALE: i64 = 0x3E000000
41const EG_ROPE_BASE: i64 = 0x415D0EAB
42const EG_VOCAB_BYTES: i64 = 67108864
43const EG_VOCAB_IDS: i64 = 262144
44const EG_VOCAB_MERGES: i64 = 524288

functions

46func eg_w(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 2: eg_nmain calls 1: sys_write
47func eg_n(v: i64) -> i64
called by 1: main calls 3: eg_wsys_mmapsys_write
57func eg_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: main
61func eg_cos(a: *i64, b: *i64, n: i64) -> i64
84func main(argc: i64, argv: *i64) -> i64