code wiki / (root) / nx_compute_runner.nx

nx_compute_runner.nx

buildroot/runtime/nx_compute_runner.nx

12741 B353 linesdepth 7pulls 9 transitivereach 1 importersview sourcekind librarytopic compute
docsdependenciesstructsconstsfunctions

about

nx_compute_runner.nx -- executes a validated ComputeGraph. The brick that closes the loop: with this in tree, the substrate has a working ComfyUI replacement at the compute layer. Build a graph -> validate -> toposort -> RUN -> get real tensor output -> verify via nx_numeric_oracle. All pure NishiLang. Dispatch: NODE_INPUT -- copies caller-supplied input tensor into the tensor store at the node's output slot NODE_CONST -- copies caller-supplied const tensor (weight blob) into the store NODE_OUTPUT -- alias-copies its input tensor into the store so external readers can collect graph outputs NODE_TENSOR_OP -- dispatches by op_code to elementwise / shape ops implemented inline NODE_KERNEL -- dispatches by kernel_kind to nx_blas_i64 (and future nx_conv / nx_attention modules) Tensor lifecycle: * One tensor per output port of each node. * Indexed by tensor_idx = node_id * NX_CN_MAX_OUTPUTS + port. * Allocated by the runner; freed by sys_mmap unwind at process exit (no GC in v1; tight footprint kept by careful sizing). Audit: Caller passes an optional *TraceCfg. If non-null, the runner emits one CONTINUITY_CHECK-style span per node (kind = generic "node executed"). Span attrs carry node_id + op_code + verdict. genealogy_id: comfyui_executor + jax_pjit + tvm_runtime + tensorflow_executor lineage_id: substrate_compute_runner_v1

dependencies 6 imports · 1 importers

nx_syscalls.nx nx_tier.nx nx_tensor.nx nx_compute_node.nx nx_compute_graph.nx nx_blas_i64.nx nx_compute_runner.nx nx_compute_runner_test.nx

imports: nx_syscalls.nxnx_tier.nxnx_tensor.nxnx_compute_node.nxnx_compute_graph.nxnx_blas_i64.nx

imported by: nx_compute_runner_test.nx

structs

67struct ComputeRunner

consts

50const NX_CR_OK: nx_int = 0
51const NX_CR_ERR_GRAPH_INVALID: nx_int = 1 // validate / toposort hadn't passed
52const NX_CR_ERR_INPUT_MISSING: nx_int = 2 // INPUT node has no binding
53const NX_CR_ERR_CONST_MISSING: nx_int = 3 // CONST node has no binding
54const NX_CR_ERR_UNSUPPORTED_OP: nx_int = 4 // op_code not yet implemented
55const NX_CR_ERR_KERNEL_FAILED: nx_int = 5 // kernel returned non-OK verdict
56const NX_CR_ERR_SHAPE_INFER: nx_int = 6 // couldn't determine output shape
57const NX_CR_N_VERDICTS: nx_int = 7
86const NX_CR_BYTES: nx_int = 88 // 11 fields * 8

functions

59func nx_cr_verdict_is_valid(v: nx_int) -> nx_int
called by 1: main
88func nx_cr_alloc(g: *ComputeGraph, cap_inputs: nx_int, cap_consts: nx_int) -> *ComputeRunner
called by 1: main calls 1: sys_mmap
116func nx_cr_bind_input(r: *ComputeRunner, t: *NxTensor) -> nx_int
called by 1: main
123func nx_cr_bind_const(r: *ComputeRunner, t: *NxTensor) -> nx_int
called by 1: main
132func nx_cr_store_set(r: *ComputeRunner, node_id: nx_int, port: nx_int, t: *NxTensor) -> nx_int
called by 1: _runner_exec_node
140func nx_cr_store_get(r: *ComputeRunner, node_id: nx_int, port: nx_int) -> *NxTensor
152func _runner_alloc_like(t: *NxTensor) -> *NxTensor
163func _runner_run_relu(input: *NxTensor) -> *NxTensor
176func _runner_run_add(a: *NxTensor, b: *NxTensor) -> *NxTensor
189func _runner_run_mul(a: *NxTensor, b: *NxTensor) -> *NxTensor
207func _runner_run_matmul(a: *NxTensor, b: *NxTensor, verdict_out: *i64) -> *NxTensor
224func _runner_exec_node(r: *ComputeRunner, node_id: nx_int,
319func nx_cr_run(r: *ComputeRunner) -> nx_int
351func nx_cr_get_output(r: *ComputeRunner, node_id: nx_int, port: nx_int) -> *NxTensor
called by 1: main calls 1: nx_cr_store_get