nx_llm_run.nx
buildroot/runtime/nx_llm_run.nx
about
nx_llm_run.nx -- end-to-end LLM inference scaffold.
L5 integration brick. Closes the SUBSTRATE COMPLETENESS PROOF:
every primitive shipped this session (BPE + embedding + RMSNorm +
attention + RoPE + SiLU + sampler + ...) composes into a SINGLE
callable that maps text -> next-token-text. Per the bits-up
cardinal: no new math, no new kernels -- pure composition.
===== End-to-end pipeline =======================================
text input
-> nx_bpe_encode (token_ids)
-> nx_embedding_lookup or _q8 (input vectors)
-> for each layer in 0..n_layers:
nx_transformer_block_forward
-> final RMSNorm (or LayerNorm) on output
-> output projection (matmul to vocab_size)
-> nx_attn_softmax_row_q10 (treat logits as 1-row tensor)
-> nx_logit_apply_temperature
-> nx_logit_top_k_mask
-> nx_sample_categorical (next token)
-> nx_bpe_decode (token -> text bytes)
===== Per the bits-up cardinal ===================================
This file ONLY composes existing primitives. No new structs, no
new sealed enums, no new math. Imports surface every layer:
nx_tensor (NxTensor L1 container)
nx_image (only via downstream consumers; not direct)
nx_bpe (text <-> tokens)
nx_embedding (token -> vector)
nx_model_spec (config envelope)
nx_transformer_block (per-layer compute)
nx_rmsnorm / nx_layernorm (final norm)
nx_attention (softmax + scale)
nx_token_sample (logits -> token)
nx_loop (bounded loops)
===== v1 scope ===================================================
dependencies 11 imports · 0 importers
diagram shows first 10 each side; +1 more imports, +0 more importers in the complete lists below.
imports: nx_syscalls.nxnx_tier.nxnx_loop.nxnx_tensor.nxnx_bpe.nxnx_embedding.nxnx_model_spec.nxnx_rmsnorm.nxnx_attention.nxnx_token_sample.nxnx_prng.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 84 | const NX_LLM_OK: nx_int = 0 |
| 85 | const NX_LLM_ERR_BAD_SPEC: nx_int = 1 |
| 86 | const NX_LLM_ERR_BAD_VOCAB: nx_int = 2 |
| 87 | const NX_LLM_ERR_OOM: nx_int = 3 |
| 88 | const NX_LLM_ERR_INTERNAL: nx_int = 4 |
| 89 | const NX_LLM_N_VERDICTS: nx_int = 5 |
functions
| 91 | func nx_llm_verdict_is_valid(v: nx_int) -> nx_int called by 1: main |
| 115 | func nx_llm_generate_one(spec: *NxModelSpec, embed: *NxTensor, |
| 207 | func main() -> i64 |