code wiki / (root) / nx_actor_role_llm.nx

nx_actor_role_llm.nx

buildroot/runtime/nx_actor_role_llm.nx

11612 B287 linesdepth 5pulls 13 transitivereach 5 importersview sourcekind librarytopic actor
docsdependenciesstructsconstsfunctions

about

nx_actor_role_llm.nx -- LLM-inference actor role adapter. REAL integration with the other-agent Nishi AI stack: this adapter wraps a cooperative-scheduled LLM inference step sequence as an actor. Each call to nx_lr_actor_step() executes ONE phase of the micro-LLM forward pass by calling the other-agent primitives: Phase 0 (EMBED): nx_embedding_lookup (other agent) Phase 1 (PROJ): nx_blas_matmul (other agent) Phase 2 (SAMPLE): nx_logit_apply_temperature + nx_logit_top_k_mask + nx_sample_categorical (other agent) Phase 3 (EMIT): nx_ms_send_fanout (this agent) + mark complete This proves the parallel-companion substrate doesn't just COMPOSE structurally with the Nishi AI port -- it actually drives real inference primitives. V1 ships a tiny 1-token-from-prompt path using i64 Q10 storage; multi-layer + attention defer to future composes per [[feedback-honest-perf-verdict-no-aspirational-claims]] (the v2 LLM runner stack is what handles full Llama, not this). Composes [[feedback-parallel-companion-multimodal-dnd-real-time]] + [[project-conductor-arc-phases-c-d-integrate-with-nishi-ai-2026-05-19]] (the integration project).

dependencies 9 imports · 5 importers

nx_syscalls.nx nx_tier.nx nx_tensor.nx nx_blas_i64.nx nx_embedding.nx nx_token_sample.nx nx_prng.nx nx_actor.nx nx_message.nx nx_actor_role_llm.nx nx_actor_role_llm_test.nx nx_bench_v1_vs_v2_test.nx nx_dual_companion_compose_test.nx nx_quad_companion_compose_test.nx nx_triple_companion_compose_test.n

imports: nx_syscalls.nxnx_tier.nxnx_tensor.nxnx_blas_i64.nxnx_embedding.nxnx_token_sample.nxnx_prng.nxnx_actor.nxnx_message.nx

imported by: nx_actor_role_llm_test.nxnx_bench_v1_vs_v2_test.nxnx_dual_companion_compose_test.nxnx_quad_companion_compose_test.nxnx_triple_companion_compose_test.nx

structs

62struct NxLlmActorCtx

consts

37const NX_LR_PHASE_INIT: nx_int = 0
38const NX_LR_PHASE_EMBED: nx_int = 1
39const NX_LR_PHASE_PROJ: nx_int = 2
40const NX_LR_PHASE_SAMPLE: nx_int = 3
41const NX_LR_PHASE_EMIT: nx_int = 4
42const NX_LR_PHASE_DONE: nx_int = 5
43const NX_LR_PHASE_N: nx_int = 6
47const NX_LR_AC_V_STEPPED: nx_int = 0
48const NX_LR_AC_V_COMPLETED: nx_int = 1
49const NX_LR_AC_V_FAILED_EMBED: nx_int = 2
50const NX_LR_AC_V_FAILED_PROJ: nx_int = 3
51const NX_LR_AC_V_FAILED_SAMPLE: nx_int = 4
52const NX_LR_AC_V_INVALID: nx_int = 5
53const NX_LR_AC_V_NULL: nx_int = 6
54const NX_LR_AC_V_N: nx_int = 7
78const NX_LR_CTX_BYTES: nx_int = 104 // 13 fields * 8

functions

82func nx_lr_phase_is_valid(p: nx_int) -> nx_int
called by 1: main
88func nx_lr_ac_v_is_valid(v: nx_int) -> nx_int
called by 1: main
99func nx_lr_actor_new(embedding_table: *NxTensor,
161func _lr_step_embed(ctx: *NxLlmActorCtx) -> nx_int
170func _lr_step_proj(ctx: *NxLlmActorCtx) -> nx_int
called by 1: nx_lr_actor_step calls 1: nx_blas_matmul
177func _lr_step_sample(ctx: *NxLlmActorCtx) -> nx_int
195func _lr_step_emit(ctx: *NxLlmActorCtx,
called by 1: nx_lr_actor_step calls 1: nx_ms_send_fanout
211func nx_lr_actor_step(ctx: *NxLlmActorCtx,
251func nx_lr_actor_reset_for_next_token(ctx: *NxLlmActorCtx,
called by 1: main calls 1: nx_ac_find
273func nx_lr_actor_phase(ctx: *NxLlmActorCtx) -> nx_int
called by 1: main
278func nx_lr_actor_token(ctx: *NxLlmActorCtx) -> nx_int
283func nx_lr_actor_is_done(ctx: *NxLlmActorCtx) -> nx_int
called by 2: mainmain