nx_reasoning.nx
buildroot/runtime/nx_reasoning.nx
about
nx_reasoning.nx -- sovereign TEST-TIME COMPUTE organ (self-consistency).
The no.1 2025/26 frontier gap on the LLM census (nx_swcompare_gapmap llm,
momentum=11): spend MORE inference compute per question to get a BETTER
answer. This organ implements the foundational primitive:
Self-consistency majority vote (Wang et al. 2023, ICLR): sample N
diverse completions at temperature T, extract each final answer,
return the mode. Accuracy rises with N on tasks where the error
mode is "diverse wrong answers, consistent right answer".
Generation goes through the CHATML TEMPLATE at the TOKEN level
(<|im_start|> injected as ids -- the nx_f32_llm_chat_test.nx proven
path). MEASURED 2026-07-09: Qwen2.5-Instruct on a RAW continuation
prompt ("47 + 38 =") emits garbage even with correct digit-split
tokenization (verified by nx_tok_probe); the instruct model is only
in-distribution INSIDE its template. Composes the EXISTING sampler
(Hinton-2015 temperature + Fan-2018 top-k) + forward_v4 -- ZERO new
model machinery. The answers array is the composition point for
future best-of-N verifier re-ranking.
genealogy_id: wang_2023_self_consistency
lineage_id: substrate_reasoning_v2 (v1 = raw-continuation, measured-hostile)
dependencies 8 imports · 14 importers
diagram shows first 10 each side; +0 more imports, +4 more importers in the complete lists below.
imports: nx_syscalls.nxnx_tier.nxnx_prng.nxnx_bpe.nxnx_f32_kv_cache.nxnx_f32_llm.nxnx_f32_llm_v4.nxnx_f32_sampler.nx
imported by: nx_batched_gate.nxnx_batched_tput.nxnx_f32_llm_serve.nxnx_llm_batch_serve.nxnx_llm_sched.nxnx_llm_sched_gate.nxnx_paged_fwd_gate.nxnx_reason_paged_probe.nxnx_reason_probe.nxnx_reasoning_gate.nxnx_reasoning_paged.nxnx_specdec.nxnx_specdec_gate.nxnx_tok_probe.nx
structs
| 39 | struct NxReasonCfg |
consts
| 35 | const NX_REASON_NONE: i64 = 0 - 999999999 |
| 54 | const NX_REASON_CFG_BYTES: nx_int = 96 // 12 fields * 8 |
functions
| 56 | func nx_reason_cfg_alloc() -> *NxReasonCfg |
| 61 | func _nxr_enc(vocab: *NxBpeVocab, text: *u8, tlen: nx_int, toks: *i64, off: nx_int) -> nx_int |
| 79 | func nx_reason_build_chat_toks(rc: *NxReasonCfg, qtext: *u8, qlen: nx_int, |
| 96 | func nx_reason_chat_gen(rc: *NxReasonCfg, qtext: *u8, qlen: nx_int, |
| 160 | func nx_reason_extract_int(text: *u8, n: nx_int) -> i64 called by 1: main |
| 187 | func nx_reason_extract_last_int(text: *u8, n: nx_int) -> i64 |
| 217 | func nx_reason_majority(answers: *i64, n: nx_int) -> i64 |
| 241 | func nx_reason_selfconsist(rc: *NxReasonCfg, qtext: *u8, qlen: nx_int, called by 1: main calls 5: sys_mmapnx_prng_initnx_reason_chat_gennx_reason_extract_last_intnx_reason_majority |
| 263 | func _nxr_put_u(buf: *u8, off: i64, v: i64) -> i64 |
| 274 | func _nxr_put_s(buf: *u8, off: i64, s: *u8) -> i64 |
| 284 | func nx_reason_build_q(buf: *u8, a: i64, op_code: i64, b: i64) -> nx_int |
| 300 | func nx_reason_build_q_short(buf: *u8, a: i64, op_code: i64, b: i64) -> nx_int |
| 310 | func nx_reason_build_arith_prompt(buf: *u8, a: i64, op_code: i64, b: i64) -> nx_int |