nx_f32_llama_v4b.nx
buildroot/runtime/nx_f32_llama_v4b.nx
about
nx_f32_llama_v4b.nx -- BATCHED MULTI-SEQUENCE decode twins: one forward
step advances M INDEPENDENT paged sequences by one token each (the
continuous-batching primitive, vLLM-class serving).
WHY IT PAYS: QKV / FFN / lm_head rows are sequence-INDEPENDENT, so M
forks batch through the same matmuls -- every weight byte is read once
for M tokens instead of once per token (the same amortization that makes
chunked prefill fast). Attention is per-sequence: each row r attends
its own seqs[r] via nx_f32_attn_with_paged with n_q=1 (100%% reuse).
Per-cell matmul math is independent of m, so each row's logits are
BIT-IDENTICAL to the m=1 sequential path (gated by nx_batched_gate).
Faithful derivative of nx_f32_llama_v4p with EXACTLY these deltas:
* pseq -> seqs: *i64 (M pointers to NxPagedSeq), one NEW token per seq
* RoPE position per row = seqs[r].seq_len (each row is ITS seq's next)
* attention: per-row loop over nx_f32_attn_with_paged(n_q=1)
* stack: ensure_append(seq_r, 1) each BEFORE layers; advance each AFTER
genealogy_id: kwon_2023_pagedattention + yu_2022_orca_continuous_batching
lineage_id: substrate_f32_llama_v4b_v1
dependencies 18 imports · 6 importers
diagram shows first 10 each side; +8 more imports, +0 more importers in the complete lists below.
imports: nx_syscalls.nxnx_tier.nxnx_f32.nxnx_f32_rmsnorm.nxnx_f32_matmul.nxnx_f32_activations.nxnx_f32_rope.nxnx_f32_attn_multi.nxnx_f32_lazy_weight.nxnx_thread_pool.nxnx_f32_llama_block.nxnx_f32_llama_block_v4.nxnx_f32_llama_stack_v4.nxnx_f32_llm.nxnx_f32_llm_v4.nxnx_kvcache.nxnx_f32_attn_paged.nxnx_f32_llama_v4p.nx
imported by: nx_batched_gate.nxnx_batched_tput.nxnx_llm_batch_serve.nxnx_llm_sched.nxnx_llm_sched_gate.nxnx_reasoning_paged.nx
structs
| none |
consts
| none |
functions
| 43 | func nx_f32_llama_block_forward_v4b( |
| 196 | func nx_f32_llama_stack_forward_v4b( |
| 281 | func nx_f32_llm_forward_v4b( |