code wiki / (root) / nx_research_ledger.nx

nx_research_ledger.nx source

↩ module page · 262 lines · 29801 B

1// nx_research_ledger.nx -- rung 1 of "build up the NISHI RESEARCHER to LEARN each rung" (operator standing order 2026-06-16). 2// 3// module: nishi-core.research.ledger capability: RESEARCH_MEMORY (the researcher compounds knowledge) 4// 5// The researcher (nx_onsite_research_fetch) does the FETCH leg; this is the LEARNING leg: a durable, 6// append-only ledger of what each cliff taught us {topic :: cliff :: root-cause :: fix :: source :: outcome}. 7// Future research calls rl_query(topic) FIRST -> if a finding exists, start from it instead of re-researching 8// from scratch. That is how the researcher gets better "from the hardware rung up each rung". 9// 10// Sovereign: pure nx_syscalls file I/O (openat_append/openat_rd/read), no C. Idempotent (upsert by topic -> 11// safe to run twice = deterministic GREEN x2). Append-only history (CLAUDE.md #13). license_tier: ORIGINAL 12import "nx_syscalls.nx" 13import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc) 14import "nx_seg_store.nx" 15const K_MAGIC_1024: i64 = 1024 16const K_MAGIC_8192: i64 = 8192 17const K_MAGIC_65536: i64 = 65536 18 19// SOVEREIGN store prefix (nx_seg_store .docs/.keys) -- replaces the loose research_ledger.tsv (NO TSV). Findings are 20// records topic -> "cliff :: root :: fix :: source :: outcome"; substring retrieval reads the segments' .docs bytes. 21const LP: *u8 = "knowledge/registry/research_ledger" as *u8 22static G_LW: i64 23static G_LSEGID: i64 24static G_LADD: i64 25func rl_cat(dst: *u8, off: i64, s: *u8) -> i64 { var o: i64=off; var i: i64=0; while s[i]!=(0 as u8){dst[o]=s[i];o=o+1;i=i+1} return o } 26 27func rl_strlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 28 29// ---- stdout ---- 30func g_puts(s: *u8) -> i64 { sys_write(1, s, rl_strlen(s)); return 0 } 31// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer 32// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the 33// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls). 34// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign. 35func g_putn(v: i64) -> i64 { nxi_out(v); return 0 } 36 37func rl_w(fd: i64, s: *u8) -> i64 { sys_write(fd, s, rl_strlen(s)); return 0 } 38 39// non-overlapping occurrences of `needle` in buf[0..n] -- the retrieval primitive. 40func rl_count(buf: *u8, n: i64, needle: *u8) -> i64 { 41 let nl: i64 = rl_strlen(needle) 42 if nl == 0 { return 0 } 43 var count: i64 = 0 44 var i: i64 = 0 45 while i + nl <= n { 46 var j: i64 = 0 47 while j < nl { if buf[i + j] != needle[j] { j = nl + 1 } else { j = j + 1 } } 48 if j == nl { count = count + 1; i = i + nl } else { i = i + 1 } 49 } 50 return count 51} 52 53// read the whole ledger (all sovereign segments' .docs, concatenated) into buf; return nbytes. 54func rl_read_all(buf: *u8, maxlen: i64) -> i64 { 55 let segp: *i64 = sys_mmap(16) as *i64 56 let ns: i64 = ss_manifest_dyn(LP, segp) // uncapped: read the WHOLE ledger 57 let segs: *i64 = segp[0] as *i64 58 var total: i64 = 0; var i: i64 = 0 59 while i < ns { 60 let sf: *u8 = sys_mmap(K_MAGIC_1024); var o: i64 = rl_cat(sf, 0, LP); o = rl_cat(sf, o, (segs[i]) as *u8); o = rl_cat(sf, o, ".docs" as *u8); sf[o]=0 as u8 61 let fd: i64 = sys_openat_rd(sf) 62 if fd >= 0 { let n: i64 = sys_read(fd, (buf as i64 + total) as *u8, maxlen - total); sys_close(fd); if n > 0 { total = total + n } } 63 i = i + 1 64 } 65 return total 66} 67 68// idempotent learn: add {topic -> "cliff :: root :: fix :: source :: outcome"} to the sovereign store iff `topic` is 69// not already present (ss_get). Uses the global writer (G_LW) so main commits ONE segment for all findings. 70func rl_upsert(topic: *u8, cliff: *u8, root: *u8, fix: *u8, source: *u8, outcome: *u8) -> i64 { 71 let pq: *i64 = sys_mmap(16) as *i64; let lq: *i64 = sys_mmap(16) as *i64 72 if ss_get(LP, topic, pq, lq) == 1 { return 1 } 73 let val: *u8 = sys_mmap(K_MAGIC_8192); var o: i64 = 0 74 o = rl_cat(val, o, cliff); o = rl_cat(val, o, " :: " as *u8); o = rl_cat(val, o, root); o = rl_cat(val, o, " :: " as *u8) 75 o = rl_cat(val, o, fix); o = rl_cat(val, o, " :: " as *u8); o = rl_cat(val, o, source); o = rl_cat(val, o, " :: " as *u8); o = rl_cat(val, o, outcome) 76 ss_add(G_LW as *i64, 1, topic, val, o) 77 G_LADD = G_LADD + 1 78 return 0 79} 80 81func main() -> i64 { 82 g_puts("=== nishi researcher LEDGER -- learn each rung (append findings + retrieve) ===\n\n") 83 84 // sovereign writer for ALL findings (ONE segment committed at the end) -- replaces the per-append TSV 85 // fresh max+1 segid (uncapped): the capped ss_manifest count clobbers the cap segment past the cap 86 G_LSEGID = ss_next_segid(LP) 87 G_LW = ss_begin() as i64 88 G_LADD = 0 89 90 // --- LEARN this session's 3 cliff->fix findings (idempotent) --- 91 rl_upsert("gemm-perf" as *u8, 92 "sovereign matmul ~37x below single-thread BLAS" as *u8, 93 "scalar SSE, compute-bound (no packed lanes/packing)" as *u8, 94 "packed SIMD microkernel + A/B panel packing (Goto/BLIS 5-loop)" as *u8, 95 "flame/how-to-optimize-gemm; Goto TOMS GotoTOMS2" as *u8, 96 "perf roadmap recorded (reference-gemm-sclass-roadmap)" as *u8) 97 rl_upsert("lowrank-kv-vram" as *u8, 98 "KV cache is up to 70% of inference VRAM at long context" as *u8, 99 "full KV stored O(n) per token" as *u8, 100 "low-rank streaming sketch (Frequent Directions) keeps O(1)" as *u8, 101 "DeepSeek-MLA arXiv 2405.04434; Liberty FD 1501.01711" as *u8, 102 "M0 12x compression GREEN (nx_lowrank_kv_gate)" as *u8) 103 rl_upsert("fd-reorthogonalization" as *u8, 104 "f32 FD was WORSE than Q14 (neg-control inverted)" as *u8, 105 "loss of orthogonality: dominant singular dir leaks via single deflation under f32" as *u8, 106 "reorthogonalize = classical Gram-Schmidt TWICE (DGKS)" as *u8, 107 "Tropp arXiv 1902.08651 (orthogonalization is precision-critical)" as *u8, 108 "M1 64x lossless GREEN, cliff gone (nx_fd_f32)" as *u8) 109 rl_upsert("fd-effective-rank" as *u8, 110 "rank-sweep: rank=4 gave 267permille at l=4 (expected lossless); synthetic rank-2 data was secretly rank-1" as *u8, 111 "(a) FD shrink subtracts sigma2_min each step -> holds rank<=l-1 not l; (b) separable f(i)*g(j) test data is rank-1" as *u8, 112 "size sketch l=effective_rank+1; build test data as random C@B (non-separable)" as *u8, 113 "Liberty FD 1501.01711 (shrink) + internal rank-sweep" as *u8, 114 "nx_fd_f32 rank-sweep GREEN; honest l-1 capture documented" as *u8) 115 rl_upsert("lowrank-attn-pertoken" as *u8, 116 "FD covariance sketch (K^T K) cannot feed softmax attention (needs per-token Q.K[i])" as *u8, 117 "covariance compression loses per-token identity; softmax is a per-token nonlinearity" as *u8, 118 "per-token SVD-projection (Eigen-Attention): store coords[n x r] + shared basis[r x d]; k_i=coords_i@basis" as *u8, 119 "DeepSeek-MLA 2405.04434; Eigen-Attention" as *u8, 120 "M3 nx_lowrank_attn GREEN: rank-2 KV @ r=2 -> 0permille attention-output error, 3x VRAM cut (d=8)" as *u8) 121 rl_upsert("sovereign-model-download" as *u8, 122 "HF GGUF download needed but our fetcher does single-GET/no-redirect; HF LFS 302-redirects to a signed CDN URL" as *u8, 123 "the sovereign fetcher avoided redirects by design (canonical URLs); large model files need redirect-follow + 2nd TLS to the CDN + a big buffer" as *u8, 124 "GET resolve -> parse Location header -> nx_https_url_for_fetch on the CDN URL -> 2nd TLS session to us.aws.cdn.hf.co -> validate cert -> GET -> write body after the header boundary" as *u8, 125 "internal D1 nx_hf_probe + D2 nx_model_fetch (reuse nx_tls13_client_session_run + nx_https_get_complete)" as *u8, 126 "491MB Qwen2.5-0.5B staged sovereignly, run-exit=0, ~14s, no curl/wget/python; STAGE PERSISTENT (ext4 ~/nx_stage) not /tmp (tmp-cleaner reaps large idle files)" as *u8) 127 rl_upsert("real-kv-is-lowrank" as *u8, 128 "does low-rank KV compression help REAL models, or only synthetic data?" as *u8, 129 "measured the singular spectrum of REAL Qwen2.5-0.5B cached K/V after a real forward" as *u8, 130 "real KV IS low-rank: K top-4 holds 80-98% of covariance energy (early layers ~98%), V ~68% -> compress K harder than V" as *u8, 131 "internal M4c-1 nx_lowrank_kv_real on the sovereign-staged model" as *u8, 132 "the M0-M4 low-rank-KV arc transfers to real models; seq=8 small-sample but clear" as *u8) 133 rl_upsert("sse-forward-2p8x-then-codegen-bound" as *u8, 134 "Q4_K-only SSE left the LM forward at 408s/8tok; SSE-ing BOTH matmul paths (Q4_K + F32) brought it to 145s = 2.8x, bit-identical" as *u8, 135 "the huge F32 LM head (hidden x vocab = 896x151936, eager-dequanted to f32) was the dominant un-SSE'd cost -- it used the SOFTWARE f32 path nx_f32_matmul_t (~20 MFLOP/s); I'd only SSE'd the Q4_K path first" as *u8, 136 "SSE both matmul paths (nx_f32_q4k_matmul + nx_f32_matmul_t). further gains: matmul caps at 142 MFLOP/s (codegen-bound: COLD~=WARM rules out memory; each f32 op = movd-boxed addss, no register alloc) -> nx_cc register allocation is the deliberate lever" as *u8, 137 "nx_q4k_matmul_rate micro-bench (warm 142 ~= cold 143) + nx_lowrank_kv_real prefill timing (408->145s)" as *u8, 138 "LESSON: profile in ISOLATION + don't conclude 'SSE didn't help' until ALL hot paths are covered -- my first 'not arithmetic-bound' call was premature (the un-SSE'd F32 LM head was the real cost)" as *u8) 139 rl_upsert("lowrank-kv-endtoend-compounds" as *u8, 140 "does low-rank KV preserve the REAL model OUTPUT end-to-end, not just per-layer attention?" as *u8, 141 "compressing K+V to r=4-of-8 across ALL 24 layers shifted real Qwen logits 72% (zero-cache control 142% validated the decode uses the cache)" as *u8, 142 "per-layer recon errors COMPOUND across 24 layers + softmax; V less low-rank than K and drives output directly -> tune ranks per-tensor (K harder) + use long context" as *u8, 143 "internal M4c-2 nx_lowrank_kv_real zero-cache-control" as *u8, 144 "refines (not breaks) thesis: single-layer preserves (M3) but naive aggressive all-layer compression compounds; GOTCHA: cache max_seq must exceed prefill+decode or decode logits are all-zero" as *u8) 145 rl_upsert("pertensor-rank-tuning-measured" as *u8, 146 "M4c-2 fix: does compressing K harder than V (K is more low-rank, per M4c-1) beat a uniform rank on the REAL model output?" as *u8, 147 "uniform r=4 across K+V shifted real Qwen logits 717permille; K=r4 / V=r6 (per-tensor, same total budget) shifted only 615 -- ~14% better" as *u8, 148 "K is more low-rank than V (M4c-1: K top4=80-98%, V=68%) so K tolerates a tighter rank; spending the freed budget on V (which drives the output) preserves more" as *u8, 149 "internal nx_lowrank_kv_real per-tensor (615) vs uniform (717), zero-cache control 1423" as *u8, 150 "ACTIONABLE: rank should be per-tensor (and likely per-layer), not uniform -- a measured lever, validated on the real model" as *u8) 151 rl_upsert("lowrank-bottleneck-improves-quality" as *u8, 152 "operator's deepest goal: can a low-rank bottleneck IMPROVE quality (not just compress) -- i.e. is it a better inductive bias?" as *u8, 153 "trained full (DxD=64 params) vs low-rank bottleneck (Wu.Wd, r params) on a NOISY rank-2 target with CLEAN test, 9 seeds. r=2 (matched, 32=half params) generalized better in 9/9, avg test MSE 2 vs full 11 milli (~5.5x). RANK-SWEEP U-curve (avg test milli): r=1 UNDER=4 -> r=2 MATCHED=2 -> r=4 OVER=9 -> full=11 => optimal rank MATCHES the data's true rank, not 'smaller is always better'" as *u8, 154 "the full model has the capacity to MEMORIZE the train noise (train~1 << test~11 milli); the rank-2 bottleneck structurally CANNOT, so it fits only the true signal -> regularization = better generalization at half the VRAM" as *u8, 155 "internal nx_lowrank_train (sovereign tg_* autograd + AdamW, 9-seed sweep, gate 3/3 GREEN)" as *u8, 156 "CLOSES the quality-UP half of the Pareto thesis (M3/M4 = preserve, M2 = improve). HONEST: synthetic/small (D=8 linear) -- proves the MECHANISM not a production-LLM number; the LLM analogue is MLA's latent KV" as *u8) 157 rl_upsert("data-driven-rank-sizing" as *u8, 158 "how to CHOOSE the low-rank KV rank per tensor/layer without guessing (M2 says match the true rank; M4c-1 says K and V differ)?" as *u8, 159 "RULE: rank = min r with cumulative covariance energy(top-r) >= threshold (threshold = the ONLY knob, no magic ranks). On real Qwen M4c-1 anchors @90%: K layer0 r=1 (912permille) vs V layer12 r>4 (682) => K compresses far harder; data-driven K=1/V=5 = 34x VRAM vs uniform-r4 25x vs full 1x (seq=512,kv_dim=128,24L)" as *u8, 160 "K's covariance energy concentrates in ~1 direction (~91%) while V's spreads (68% by r4) -> a single uniform rank is wrong for both; size each tensor's rank to its OWN measured spectrum" as *u8, 161 "internal nx_lowrank_rank_plan (gate 5/5: rule correct on controlled spectrum + monotonic + neg-control refuses flat + real K<V + VRAM win), no slow forward" as *u8, 162 "ACTIONABLE design rule, validated + sovereign. HONEST: M4c-1 anchors sparse (r1,r4, seq=8) so the EXACT per-layer V rank needs the full spectrum (one one-time forward) -- the rule + K<<V contrast + VRAM win are anchor-determined" as *u8) 163 rl_upsert("lowrank-kv-hardware-budget" as *u8, 164 "what does data-driven low-rank KV actually BUY on the operator's real hardware (RTX 5080, 16 GiB)?" as *u8, 165 "max context on the 5080: Qwen0.5B full KV=679K tokens vs data-driven low-rank(K1/V5)=29M (42x); 7B-class full=106K vs ~18M (170x, illustrative). Multiplier = 2*kv_dim/(rK+rV) GROWS with model size" as *u8, 166 "KV cache is the context bottleneck (grows per token); big models (weights eat VRAM, context KV-bound) benefit MOST -> low-rank KV is the enabler for long context on consumer GPUs" as *u8, 167 "internal nx_lowrank_kv_budget (gate 4/4: more-context + closed-form multiplier + grows-with-size + neg-control no-compression), no slow forward" as *u8, 168 "ON-TELOS (capable AI on affordable hw): turns the 5080 into a long-context machine. HONEST: 0.5B measured; 7B ranks illustrative (assumes similar low ranks, needs a 7B spectrum); f32 KV (f16 doubles tokens)" as *u8) 169 rl_upsert("diverse-context-spectrum-correction" as *u8, 170 "SUPERSEDES the 34x/42x low-rank-KV magnitudes (#12,#13): were they real, or an artifact of HOW the cache was measured?" as *u8, 171 "OVER-OPTIMISTIC. The M4c-1 anchors (K layer0 r1=912 '90% at r=1') came from a near-degenerate context. With DIVERSE tokens the real seq=8 spectrum is far flatter (K l0 r1=631 r4=939); the per-layer 90% schedule = K avg 5 / V avg 6 of 8 -> ~16x at seq=512, WORSE than uniform-r4 25x (cache needs r>4 for 90% => r=4 is below the bar = why M4c-2 r=4 shifts the real output 615permille)" as *u8, 172 "repeated/low-diversity context makes KV rows near-identical -> artificially low-rank (near rank-1) spectrum; the data-driven RULE + the K<V direction survive, the MAGNITUDES do not" as *u8, 173 "internal nx_lowrank_kv_real M4d (diverse tokens, all 24 layers); the slow forward the operator cleared is what CAUGHT this" as *u8, 174 "LESSON: ALWAYS measure the KV spectrum with DIVERSE tokens -- degenerate context lies. seq=8 still too small (rank<=8) -> seq=64 forward running for the definitive long-context number" as *u8) 175 rl_upsert("kv-lowrank-definitive-seq64" as *u8, 176 "the DEFINITIVE long-context KV verdict (seq=64 forward, operator cleared the slow forward): how compressible is real Qwen KV, really?" as *u8, 177 "MODEST. 90%-energy per-layer schedule = avg K=27/V=37 of 64 -> ~3x VRAM @seq=512 (NOT the 34x/42x I over-claimed). End-to-end the data-driven 90% schedule shifts the real output 335permille vs uniform-r4's 615 (zero-cache 1252) -> data-driven HELPS but per-layer 90% COMPOUNDS across 24 layers; tight preservation needs a higher threshold => ~1.5x" as *u8, 178 "real KV at realistic context is only modestly low-rank (early-layer K steep r4=885, but mid/deep K + all V flat r4=288-549); compounding across 24 layers makes even 90%-per-layer a 34% output shift" as *u8, 179 "internal nx_lowrank_kv_real M4d+M4c-2 at seq=64 (schedule-wired)" as *u8, 180 "HONEST verdict: KV-compression is a MODEST ~2-3x lever on this model (data-driven sizing + K<V validated, but magnitude small). Weights are NOT a blanket fix either (see #16: heterogeneous). Measurement settled it, not assumptions" as *u8) 181 rl_upsert("weights-lowrank-heterogeneous" as *u8, 182 "are the model's WEIGHT matrices low-rank (the forward-free FlashSVD lever) -- and is it uniform across types?" as *u8, 183 "HETEROGENEOUS. attn_q (896x896) top-32=895permille (strongly low-rank ~14x) but SMALL; ffn_gate (4864x896) top-32=253; ffn_up top-32=82 (~full-rank, energy uniform across 896 dims) -- and ffn is where MOST params live => weight-SVD saves little OVERALL" as *u8, 184 "I over-extrapolated 'weights strong' from attn_q ALONE; the ffn measurement (forward-free) corrected it -- the 2nd over-claim measurement caught in this arc" as *u8, 185 "internal nx_lowrank_weight_spectrum (gguf load_tensor_to_f32 + f32 power-iter spectrum, NO forward)" as *u8, 186 "META-LESSON: low-rankness is HETEROGENEOUS across matrices (attn yes/ffn no; early-K yes/mid-deep+V no) -- NEVER extrapolate from one matrix, measure each. BOTH KV and weight low-rank VRAM levers are MODEST on real Qwen-0.5B; M2 quality-up (synthetic mechanism) is the solid positive" as *u8) 187 rl_upsert("speed-beat-cuda-landscape-cited" as *u8, 188 "what drives inference SPEED on consumer 16GB hardware + what BEATS CUDA? (CITED, sovereign-fetched June 2026)" as *u8, 189 "SOVEREIGN FETCH (nx_research_fetch, own TLS1.3 validated vs 167 Mozilla CAs, status 200) of the llama.cpp README: SPEED = integer quantization 1.5-8 bit (faster inference + reduced memory). BEAT-CUDA = the BACKEND MATRIX -- CUDA is NVIDIA-only; VULKAN targets 'GPU' = ALL vendors (cross-vendor); SYCL=Intel, HIP=AMD, MUSA/CANN/OpenCL/zDNN/etc. => Vulkan(SPIR-V) is the cross-vendor CUDA-alternative" as *u8, 190 "CUDA's moat is NVIDIA-lock; the sovereign counter is Vulkan compute = ONE backend, runs on EVERY GPU. 'Beat CUDA' honestly = match capability while being cross-vendor + unlocked, NOT raw-speed-beating on NVIDIA's home turf" as *u8, 191 "sovereign fetch -> knowledge/fetched/srch_llamacpp_readme.raw (raw.githubusercontent.com/ggml-org/llama.cpp/master/README.md, 30829 bytes, status 200)" as *u8, 192 "NISHI DIRECTION: (1) SPEED = quant (Nishi already reads Q4_K) + fast kernels (the nx_cc/SIMD work); (2) BEAT-CUDA = a sovereign VULKAN-COMPUTE matmul (emit SPIR-V, dispatch the forward's hot matmul on GPU) = the genesis accel-unification (run on all GPUs). The sovereign web-researcher is now PROVEN on a real cited fetch" as *u8) 193 rl_upsert("beat-cuda-spirv-vulkan-cited" as *u8, 194 "HOW does the cross-vendor (beat-CUDA) GPU path work, and is it sovereign-feasible? (CITED, sovereign-fetched)" as *u8, 195 "CITED (llama.cpp docs/build.md, sovereign fetch status 200): the Vulkan backend = libvulkan (the LOADER) + SPIR-V kernels (apt install libvulkan-dev glslc spirv-headers). SPIR-V (Khronos OPEN IR) is the kernel format; glslc compiles GLSL->SPIR-V but SPIR-V can be EMITTED directly. The ICD (VK_ICD_FILENAMES) is the vendor driver's Vulkan layer -- runs NVIDIA/AMD/Intel/Apple(MoltenVK)" as *u8, 196 "CUDA = wholly proprietary NVIDIA-only (PTX + closed driver). Vulkan = OPEN cross-vendor standard; SPIR-V = OPEN IR. So a sovereign accel can EMIT SPIR-V (exactly as Nishi emits x86) + dispatch via the open Vulkan loader -- the loader/ICD is a THIN open boundary (like virtio / the genesis driver axis), NOT a lock" as *u8, 197 "sovereign fetch knowledge/fetched/srch_latest.raw (llama.cpp docs/build.md, 37841 bytes, status 200, line 501/504)" as *u8, 198 "NISHI BEAT-CUDA ROADMAP: emit SPIR-V matmul kernels sovereignly + dispatch via libvulkan -> GPU-fast + runs on ALL GPUs + MORE sovereign than CUDA. Loader/driver = the sanctioned OS/HW boundary (god->hardware->driver HAL). Unlocks the genesis 'accel LOCKED' axis. NEVER-BRICK note: GPU compute dispatch is read/compute, not persistent HW writes -- safe by construction" as *u8) 199 rl_upsert("june2026-model-landscape-cited" as *u8, 200 "what are the modern (June 2026) models for 16GB hardware + what architectural/numeric speed levers do they use? (CITED sovereign fetch, past my Jan-2026 cutoff)" as *u8, 201 "SOVEREIGN FETCH (HF trending text-gen API, status 200 = real fresh data): Gemma-4(12B/26B-A4B/31B), GLM-5.2/5.1(FP8), DeepSeek-V4-Pro/Flash, Qwen3.6(27B-MTP/35B-A3B), Nemotron-3, LiquidAI LFM2.5-8B-A1B, MiMo-V2.5(FP4), HRM-Text-1B. SPEED LEVERS: (1) MoE active-params (A4B/A3B/A1B/A55B = big total, small ACTIVE compute); (2) FP4/FP8 quant (NVFP4, FP8) beyond int4" as *u8, 202 "June-2026 SOTA = MoE (sparse active compute = speed + fits 16GB despite big total) + low-bit FLOAT quant (NVFP4/FP8, not just int4). NVFP4 is NVIDIA-specific (tensor-core FP4) => the sovereign cross-vendor angle is FP8/FP4 via Vulkan" as *u8, 203 "sovereign fetch knowledge/fetched/srch_latest.raw (huggingface.co/api/models?pipeline_tag=text-generation&sort=trendingScore, status 200, 17170 bytes)" as *u8, 204 "NISHI SPEED ROADMAP (research-driven): (1) MoE ROUTING in the forward (compute only active experts) = the architectural lever; (2) FP8/FP4 quant added to Q4_K = the numeric lever; (3) SPIR-V/Vulkan dispatch = the sovereign cross-vendor accel. The researcher delivered REAL post-cutoff data -- its value is proven" as *u8) 205 rl_upsert("sovereign-multicore-fork-matmul" as *u8, 206 "tractable SOVEREIGN speed (no 3rd party, hardware up): can we parallelize the matmul across cores with ZERO userspace libs?" as *u8, 207 "YES, MEASURED: nx_par_matmul forks 8 workers (sys_fork), each computes a row-slice into SHARED mem (sys_mmap_shared), parent joins (sys_wait4); inner MAC = sovereign SSE. 384^3: serial 278ms -> parallel 41ms = 6.78x, BIT-IDENTICAL to serial. Pure syscalls, NO libvulkan/CUDA/Mesa/pthread" as *u8, 208 "fork+shared-mem+wait4 are sovereign syscalls Nishi already has; disjoint row-ranges = no races; COW = free shared-read of inputs. The matmul is the forward's bottleneck -> ~6.8x faster forward, all sovereign" as *u8, 209 "internal nx_par_matmul (gate 2/2: bit-identical + faster), measured 6.78x on this machine" as *u8, 210 "CORRECTION to #18 (operator 2026-06-18 'no 3rd party from the hardware rung up'): libvulkan is a 3rd-party userspace DRIVER => the SPIR-V-via-loader plan VIOLATES no-3rd-party. Sovereign accel = (a) CPU SSE+fork-parallel+quant [PROVEN], (b) raw-kernel-DRM GPU [frontier, no userspace driver; NVIDIA 5080 = reverse-eng]. NEXT = wire fork-parallel into the forward's big matmuls" as *u8) 211 rl_upsert("forward-fork-parallel-failed-pool-is-fix" as *u8, 212 "does the proven 6.78x sovereign fork-parallel matmul speed up the REAL forward when wired in?" as *u8, 213 "NO -- CORRECT but 8% SLOWER (1240s vs 1145s serial at seq=64; M4d/M4c-2 BIT-IDENTICAL to serial = correctness proven). The forward calls the matmul ~hundreds of times; forking 8 workers PER matmul (~1300+ forks of a 491MB process) + per-matmul shared-temp alloc/copy = overhead EXCEEDING the parallelism gain" as *u8, 214 "nx_par_matmul got 6.78x because it forked ONCE (one matmul); per-matmul fork doesn't scale (cost ~ process_size x call_count). The lever is real ISOLATED; the forward integration via per-matmul fork is the WRONG design" as *u8, 215 "internal nx_lowrank_kv_real forward w/ fork-parallel matmuls (correct, slower); fork now DISABLED (threshold raised) -> back to serial speed" as *u8, 216 "FIX = persistent worker POOL: fork 8 workers ONCE (needs a SHARED activation arena -- post-fork allocations aren't shared with pre-forked workers), dispatch via shared-mem + busy-spin = parallelism WITHOUT per-matmul fork. DEEPER: even perfect 8x -> ~18s/8tok, still bottlenecked by __f32 codegen (movd-boxed SSE ~142 MFLOP/s) = the nx_cc register-alloc issue (parallel effort). Full sovereign speed = nx_cc + pool-multicore + GPU" as *u8) 217 rl_upsert("worker-pool-finicky-deferred" as *u8, 218 "did the persistent worker pool (the fix for per-matmul fork) work?" as *u8, 219 "DEFERRED -- finicky sovereign IPC: busy-spin pool DEADLOCKED (LICM hoists the shared-flag read past sleep(0)); pipe-based pool DEADLOCKED at shutdown (workers inherit their OWN go-pipe write end -> no EOF; FIXED by closing inherited fds in the child) but a 3rd hang remained (uninvestigated, killed)" as *u8, 220 "sovereign multicore IPC (spin/pipes + fork) is fiddly to get right; AND even a perfect 8x lands at ~18s/8tok -- the DEEPER bottleneck is the __f32 codegen (nx_cc), so the pool's bounded payoff didn't justify more grind now" as *u8, 221 "internal nx_par_pool (2 hangs diagnosed+fixed, 1 remaining); nx_par_matmul proves the lever ISOLATED (6.78x bit-identical)" as *u8, 222 "DEFERRED: revisit the pool when the deeper lever (nx_cc codegen) lands, or with a careful diagnostic pass. The isolated 6.78x lever stands; per-matmul fork is DISABLED in the matmuls (serial restored)" as *u8) 223 rl_upsert("oci-sovereign-container-runtime-cited" as *u8, 224 "operator pointed the researcher at the OCI runtime-spec (rf_url.txt) -- what does a SOVEREIGN container runtime (no 3rd-party runc/crun) need?" as *u8, 225 "CITED (OCI runtime-spec config.md, sovereign fetch status 200, 57KB): container config = Root (rootfs path+readonly), Mounts (destination/type/source/options), Process (args/env/cwd/rlimits/capabilities/cgroupsPath/cpu-affinity), User (uid/gid), Hostname/Domainname. Linux specifics (namespaces/devices/cgroups/seccomp) are in config-linux.md (the natural next fetch)" as *u8, 226 "a sovereign OCI runtime = parse config.json -> unshare/clone namespaces -> pivot_root to rootfs -> mount the mounts -> set hostname -> drop to uid/gid -> execve process.args. ALL via syscalls (no runc). Extends 'no 3rd party' to the deployment layer" as *u8, 227 "sovereign fetch knowledge/fetched/srch_latest.raw (opencontainers/runtime-spec config.md, status 200, 57114 bytes)" as *u8, 228 "DIRECTION: a sovereign OCI-compliant runtime (run Nishi + any OCI image sovereignly, no runc). Needs syscalls Nishi may lack (clone/unshare/pivot_root/mount/sethostname) = genesis-rung-up. config-linux.md's devices (/dev/dri) is ALSO the GPU-access boundary for the raw-DRM accel frontier" as *u8) 229 rl_upsert("faceted-search-dublin-core-facets" as *u8, 230 "operator-directed research (rf_url.txt cycling): faceted search + the metadata vocabulary for facets -- for the onsite-search FACET gap" as *u8, 231 "CITED (sovereign fetches status 200): Faceted search = filter/navigate results by independent FACETS (attributes). Dublin Core DCMI Terms = the standard facet VOCABULARY: title/creator/subject/description/publisher/contributor/date/type/format/identifier/source/language/relation/coverage/rights (15 core) + created/available/audience/access etc." as *u8, 232 "the onsite-search arc is behind on 'facet' (its worklist); faceted search over a Dublin-Core facet schema (creator/subject/date/type/language) closes it -- filter the BM25 hits by selected facet values + return facet counts" as *u8, 233 "sovereign fetches knowledge/fetched/srch_latest.raw (Faceted_search wiki + dublincore DCMI terms, status 200, 30-681KB; researcher PROVEN robust across very diverse sites)" as *u8, 234 "NISHI DIRECTION: add faceted filtering to nx_onsite_search using DC facets (index per-doc DC metadata; filter BM25 hits by selected facet values + return per-facet counts). Closes the onsite-search facet gap [[project-onsite-search-reusable-sclass-2026-06-16]]" as *u8) 235 236 if G_LADD > 0 { ss_commit(LP, G_LW as *i64, G_LSEGID) } // commit ALL new findings as ONE sovereign segment 237 238 // --- READ BACK + RETRIEVE --- 239 let buf: *u8 = sys_mmap(K_MAGIC_65536) 240 let n: i64 = rl_read_all(buf, K_MAGIC_65536) 241 g_puts(" ledger bytes="); g_putn(n); g_puts("\n") 242 let q1: i64 = rl_count(buf, n, "reorthogon" as *u8) 243 let q2: i64 = rl_count(buf, n, "lowrank-kv-vram" as *u8) 244 let q3: i64 = rl_count(buf, n, "Frequent Directions" as *u8) 245 let qneg: i64 = rl_count(buf, n, "zzqzz_absent_topic" as *u8) 246 g_puts(" query 'reorthogon'="); g_putn(q1) 247 g_puts(" 'lowrank-kv-vram'="); g_putn(q2) 248 g_puts(" 'Frequent Directions'="); g_putn(q3) 249 g_puts(" neg='zzqzz'="); g_putn(qneg); g_puts("\n\n") 250 251 // --- gate --- 252 var pass: i64 = 0 253 var fail: i64 = 0 254 if n > 0 { g_puts(" T1 ledger persists to disk + reads back: PASS\n"); pass = pass + 1 } else { g_puts(" T1 ledger readback: FAIL\n"); fail = fail + 1 } 255 if q1 >= 1 { g_puts(" T2 retrieves the FD-reorthogonalization fix: PASS\n"); pass = pass + 1 } else { g_puts(" T2 retrieve fix: FAIL\n"); fail = fail + 1 } 256 if q3 >= 1 { g_puts(" T3 retrieves by capability keyword: PASS\n"); pass = pass + 1 } else { g_puts(" T3 retrieve by keyword: FAIL\n"); fail = fail + 1 } 257 if qneg == 0 { g_puts(" T4 neg-control: absent topic returns nothing: PASS\n"); pass = pass + 1 } else { g_puts(" T4 neg-control: FAIL\n"); fail = fail + 1 } 258 259 g_puts("\n PASS="); g_putn(pass); g_puts("/4 ") 260 if fail == 0 { g_puts("VERDICT=GREEN (researcher accumulates + retrieves learnings, sovereign)\n"); sys_exit(0); return 0 } 261 g_puts("VERDICT=RED\n"); sys_exit(1); return 1 262}