Optimized compute engine
Blocked matrix computation, correctness, and measured improvements.
01Matrix engine#
Linear in this repository computes a 6×16 output tile with 12 independent FMA accumulators. A 128-deep weight panel occupies 8 KiB of local storage and is reused across input rows. Small batches use a four-chain dot path. Packing is timed on every call. The GEMM kernel kept on the 2026-10-21 evening competitor protocol is avx2-4x16; the N=2048 GFLOPS column (Nexus 330, 362, 369; TensorFlow 389) is not a measurement of this 6×16 tile.
02Backward and convolution#
dX and dW share the blocked kernel without materialized transposes. Unrequested gradient products are skipped. Gradients accumulate into existing values. Convolution multiplies the im2col layout directly into channel-major output; forward and backward share the same engine.
03Speed and numerical accuracy#
LayerNorm vectorizes two-pass float64 sum/variance reductions, preserving accuracy for large means and small variance. Global fast-math is disabled. Kernel tests cover random inputs, both sides of 16/128 boundaries, single rows, bias, optional gradients, repeated accumulation, and grouped convolution.
04Source organization#
src/core separates convolution, normalization, pooling, embedding, and dropout. src/simd/avx2 separates the matrix microkernel, Linear, and LayerNorm. Each folder's details.txt explains layouts and design decisions. The public C++ API is preserved.
05Reading the results#
The benchmark page keeps the 2026-09-29 NumPy/PyTorch comparison apart from the old/new NexusModel times. Three rounds rotate order; each has 20 warmups and 30×5 calls. The evening of 2026-10-21 on this Ryzen 7 5800H is a separate protocol. GEMM kept avx2-4x16. At N=2048 Nexus recorded 330, 362, and 369 GFLOPS; TensorFlow recorded 389. CPU Conv2d was behind PyTorch at 31.6 GFLOPS; Nexus was about 4.9 to 6.8 GFLOPS. Depthwise AVX was ahead of PyTorch 4.93 and TensorFlow 0.688. AVX-512 is not selected. There is no world ranking. GPU data is a historical archive.
cmake -S . -B buildcmake --build build --config Releasectest --test-dir build -C Release --output-on-failurecmake -S docs/examples -B docs/.example-buildcmake --build docs/.example-build --config Releasepython docs/benchmarks/compare_libraries.py