nx_actor_role_llm.nx
buildroot/runtime/nx_actor_role_llm.nx
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
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
| 62 | struct NxLlmActorCtx |
consts
| 37 | const NX_LR_PHASE_INIT: nx_int = 0 |
| 38 | const NX_LR_PHASE_EMBED: nx_int = 1 |
| 39 | const NX_LR_PHASE_PROJ: nx_int = 2 |
| 40 | const NX_LR_PHASE_SAMPLE: nx_int = 3 |
| 41 | const NX_LR_PHASE_EMIT: nx_int = 4 |
| 42 | const NX_LR_PHASE_DONE: nx_int = 5 |
| 43 | const NX_LR_PHASE_N: nx_int = 6 |
| 47 | const NX_LR_AC_V_STEPPED: nx_int = 0 |
| 48 | const NX_LR_AC_V_COMPLETED: nx_int = 1 |
| 49 | const NX_LR_AC_V_FAILED_EMBED: nx_int = 2 |
| 50 | const NX_LR_AC_V_FAILED_PROJ: nx_int = 3 |
| 51 | const NX_LR_AC_V_FAILED_SAMPLE: nx_int = 4 |
| 52 | const NX_LR_AC_V_INVALID: nx_int = 5 |
| 53 | const NX_LR_AC_V_NULL: nx_int = 6 |
| 54 | const NX_LR_AC_V_N: nx_int = 7 |
| 78 | const NX_LR_CTX_BYTES: nx_int = 104 // 13 fields * 8 |
functions
| 82 | func nx_lr_phase_is_valid(p: nx_int) -> nx_int called by 1: main |
| 88 | func nx_lr_ac_v_is_valid(v: nx_int) -> nx_int called by 1: main |
| 99 | func nx_lr_actor_new(embedding_table: *NxTensor, |
| 161 | func _lr_step_embed(ctx: *NxLlmActorCtx) -> nx_int |
| 170 | func _lr_step_proj(ctx: *NxLlmActorCtx) -> nx_int |
| 177 | func _lr_step_sample(ctx: *NxLlmActorCtx) -> nx_int called by 1: nx_lr_actor_step calls 3: nx_logit_apply_temperaturenx_logit_top_k_masknx_sample_categorical |
| 195 | func _lr_step_emit(ctx: *NxLlmActorCtx, |
| 211 | func nx_lr_actor_step(ctx: *NxLlmActorCtx, called by 5: mainmainmainmainmain calls 7: _lr_step_embed_lr_step_proj_lr_step_sample_lr_step_emitnx_ac_stepnx_ac_complete+1 |
| 251 | func nx_lr_actor_reset_for_next_token(ctx: *NxLlmActorCtx, |
| 273 | func nx_lr_actor_phase(ctx: *NxLlmActorCtx) -> nx_int called by 1: main |
| 278 | func nx_lr_actor_token(ctx: *NxLlmActorCtx) -> nx_int |
| 283 | func nx_lr_actor_is_done(ctx: *NxLlmActorCtx) -> nx_int |