nx_compute_runner.nx
buildroot/runtime/nx_compute_runner.nx
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
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
| 67 | struct ComputeRunner |
consts
| 50 | const NX_CR_OK: nx_int = 0 |
| 51 | const NX_CR_ERR_GRAPH_INVALID: nx_int = 1 // validate / toposort hadn't passed |
| 52 | const NX_CR_ERR_INPUT_MISSING: nx_int = 2 // INPUT node has no binding |
| 53 | const NX_CR_ERR_CONST_MISSING: nx_int = 3 // CONST node has no binding |
| 54 | const NX_CR_ERR_UNSUPPORTED_OP: nx_int = 4 // op_code not yet implemented |
| 55 | const NX_CR_ERR_KERNEL_FAILED: nx_int = 5 // kernel returned non-OK verdict |
| 56 | const NX_CR_ERR_SHAPE_INFER: nx_int = 6 // couldn't determine output shape |
| 57 | const NX_CR_N_VERDICTS: nx_int = 7 |
| 86 | const NX_CR_BYTES: nx_int = 88 // 11 fields * 8 |
functions
| 59 | func nx_cr_verdict_is_valid(v: nx_int) -> nx_int called by 1: main |
| 88 | func nx_cr_alloc(g: *ComputeGraph, cap_inputs: nx_int, cap_consts: nx_int) -> *ComputeRunner |
| 116 | func nx_cr_bind_input(r: *ComputeRunner, t: *NxTensor) -> nx_int called by 1: main |
| 123 | func nx_cr_bind_const(r: *ComputeRunner, t: *NxTensor) -> nx_int called by 1: main |
| 132 | func nx_cr_store_set(r: *ComputeRunner, node_id: nx_int, port: nx_int, t: *NxTensor) -> nx_int called by 1: _runner_exec_node |
| 140 | func nx_cr_store_get(r: *ComputeRunner, node_id: nx_int, port: nx_int) -> *NxTensor |
| 152 | func _runner_alloc_like(t: *NxTensor) -> *NxTensor |
| 163 | func _runner_run_relu(input: *NxTensor) -> *NxTensor |
| 176 | func _runner_run_add(a: *NxTensor, b: *NxTensor) -> *NxTensor |
| 189 | func _runner_run_mul(a: *NxTensor, b: *NxTensor) -> *NxTensor |
| 207 | func _runner_run_matmul(a: *NxTensor, b: *NxTensor, verdict_out: *i64) -> *NxTensor |
| 224 | func _runner_exec_node(r: *ComputeRunner, node_id: nx_int, called by 1: nx_cr_run calls 8: nx_cg_get_nodenx_cr_store_setnx_cr_store_get_runner_run_relu_runner_run_add_runner_run_mul+2 |
| 319 | func nx_cr_run(r: *ComputeRunner) -> nx_int |
| 351 | func nx_cr_get_output(r: *ComputeRunner, node_id: nx_int, port: nx_int) -> *NxTensor |