code wiki / (root) / nx_blas_i64.nx

nx_blas_i64.nx

buildroot/runtime/nx_blas_i64.nx

8860 B238 linesdepth 3pulls 3 transitivereach 39 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_blas_i64.nx -- BLAS Level-1/2/3 reference kernels on i64+Q10. First kernel module on the sovereign-from-bits-up ML stack. Iteration I3 per nxc2/docs/MULTIMODAL_ORCHESTRATOR_ROADMAP.md. Per the "world class without the comfyui annoyance but the power and more" framing: we ship the CORRECT version first (slow, simple, auditable). AlphaTensor-discovered (Fawzi 2022) / AlphaEvolve- proposed (Romera-Paredes 2025) variants land later as alternative implementations of the same kernel, gated by nx_numeric_oracle verdict against this reference. Layout: row-major contiguous tensors only (v1). Strided / view support lands when permute becomes a hot path. Operations shipped: gemm -- C = alpha * A @ B + beta * C (Level 3) matmul -- gemm with alpha=1, beta=0 dot -- scalar = sum(x[i] * y[i]) (Level 1) axpy -- y = alpha * x + y (Level 1) scale -- x = alpha * x (Level 1, BLAS-1 _scal) gemv -- y = alpha * A @ x + beta * y (Level 2) Q-format convention: alpha and beta are Q10 scaling factors; tensor elements are plain i64 (NOT pre-scaled). Result element = (raw_dot * alpha_q10 + raw_c * beta_q10) / 1024. genealogy_id: blis_van_zee_2015 + goto_2008_matmul + alphatensor_fawzi_2022 + strassen_1969 + ieee_754_kahan_1965 lineage_id: substrate_blas_i64_v1

dependencies 3 imports · 7 importers

nx_syscalls.nx nx_tier.nx nx_tensor.nx nx_blas_i64.nx nx_actor_role_llm.nx nx_attention.nx nx_compute_runner.nx nx_compute_runner_test.nx nx_llm_run_v2.nx nx_sparse_tensor_test.nx nx_transformer_block.nx

imports: nx_syscalls.nxnx_tier.nxnx_tensor.nx

imported by: nx_actor_role_llm.nxnx_attention.nxnx_compute_runner.nxnx_compute_runner_test.nxnx_llm_run_v2.nxnx_sparse_tensor_test.nxnx_transformer_block.nx

structs

none

consts

43const NX_BLAS_Q10: nx_int = 1024
47const NX_BLAS_OK: nx_int = 0
48const NX_BLAS_ERR_BAD_DTYPE: nx_int = 1 // not I64
49const NX_BLAS_ERR_BAD_NDIM: nx_int = 2 // matmul needs ndim==2
50const NX_BLAS_ERR_SHAPE_MISMATCH: nx_int = 3 // K dimension or M/N mismatch
51const NX_BLAS_ERR_NOT_CONTIGUOUS: nx_int = 4 // v1 row-major only
52const NX_BLAS_N_VERDICTS: nx_int = 5

functions

54func nx_blas_verdict_is_valid(v: nx_int) -> nx_int
62func _blas_check_matmul(a: *NxTensor, b: *NxTensor, c: *NxTensor) -> nx_int
called by 1: nx_blas_gemm calls 1: nx_t_is_contiguous
91func nx_blas_gemm(a: *NxTensor, b: *NxTensor, c: *NxTensor,
called by 1: nx_blas_matmul calls 1: _blas_check_matmul
130func nx_blas_matmul(a: *NxTensor, b: *NxTensor, c: *NxTensor) -> nx_int
140func nx_blas_dot(x: *NxTensor, y: *NxTensor, out: *i64) -> nx_int
166func nx_blas_axpy(alpha_q10: nx_int, x: *NxTensor, y: *NxTensor) -> nx_int
189func nx_blas_scale(alpha_q10: nx_int, x: *NxTensor) -> nx_int
206func nx_blas_gemv(a: *NxTensor, x: *NxTensor, y: *NxTensor,