I built a Kolmogorov-Arnold Network from scratch in C++ (no PyTorch, no Eigen, just the STL) and it beat micrograd MLP on a toy task

Wait 5 sec.

Hey all 👋 What it is: A KAN implementation completely from scratch, inspired from the micrograd by Andrej Karpathy Each edge is a cubic B-spline plus a SiLU term, with my own Cox-de Boor recursion A tiny reverse-mode autograd engine in the style of micrograd. Every node lives in a NeuronPool (a std::deque, so pointers never go stale). The creation order is already the topological order, so backprop is one reverse loop, with no DFS. Each spline edge is a single graph node that stores its own partial derivatives (local_grad), so the forward pass does all the spline work and backward never re-evaluates it 70 parameters, ~0.15 s to train in C++ The bench: I put it up against micrograd’s MLP (67 params) on y = 3x² + 7x + 2. Both used per-sample SGD for 200 epochs, with the median taken over 5 seeds. KAN micrograd MLP final train loss 0.0123 test MSE 0.0107 time 0.149 s The caveats: The speed gap is mostly C++ vs interpreted Python, so don’t read it as KAN vs MLP. It’s a tiny 1-D regression with 9 training points. It shows the thing learns correctly, not that KANs beat MLPs in general. A smooth polynomial just happens to suit splines. Known rough edges (they’re listed in the README): w_out is shared across the outer edges. No grid refinement or pruning. It’s fixed to 2 inputs for now. All the critics are welcome!!! 🔗 GitHub: https://github.com/spyke7/microkan Stars and issues are welcome ⭐   submitted by   /u/cool-boii   to   r/programmingprojects [link]   [comments]