seatorch¶
A scalar autograd engine in C. The training and weight-export front-end for the Mini NPU. This is what makes the portfolio pitch true: you trained the model yourself, no PyTorch.
Status: not started. Begins after cmatrix ships.
Goal¶
Train a small MLP on MNIST using only this engine, quantize the trained weights to INT8, and export them in a format the Mini NPU can load over UART. End-to-end, your code, every layer.
Milestones¶
| # | Milestone | What it proves |
|---|---|---|
| 1 | Value struct: scalar + grad + backward fn pointer + parent pointers |
computational graph as a data structure |
| 2 | Ops: add, mul, pow, relu — each builds graph + defines local backward | forward pass is graph construction |
| 3 | Topological sort + backward() |
reverse-mode autodiff, the actual algorithm |
| 4 | Tiny MLP (2-3 scalar layers) on toy data (XOR or similar) | wiring scalars into a network, sanity check before scaling |
| 5 | SGD optimizer, training loop | the boring but necessary part |
| 6 | Scale to MNIST (this will be slow — scalar-level ops on 784 inputs) | forces the next milestone |
| 7 | Vectorize: replace scalar Value graph with tensor ops (flat float arrays, manual matmul) |
this is the real engineering step — from "autograd toy" to "usable engine" |
| 8 | Benchmark naive matmul vs SIMD-optimized (AVX2 or NEON depending on what you're running on) | systems performance work, ties to your SIMD/cache curriculum |
| 9 | Post-training INT8 quantization (per-tensor scale/zero-point) | the actual quant math, not a library call |
| 10 | Weight exporter: dump quantized weights as .hex for the NPU's BRAM format |
the bridge to mini-npu |
| 11 | (Stretch) CUDA matmul kernel, if you get a CUDA-capable box / cloud GPU | you're on AMD locally — this is optional, see decision log |
| 12 | (Stretch) FlashAttention-style fused attention, if you extend to a tiny transformer later | far stretch, only if seatorch's scope grows post-MNIST |
Risk note: milestone 6→7 is where this stalls if you don't time-box it. Scalar MNIST will be painfully slow — that's expected and is the motivation for vectorizing, not a bug to chase.
Ship checklist¶
- Repo: engine + training script + quantizer + exporter
- MNIST accuracy number (float) and INT8 accuracy number (post-quant) — the delta is the headline result
- Writeup: what reverse-mode autodiff actually costs you in C vs what PyTorch hides, with real numbers from milestone 8
- Show HN / r/cpp once the writeup has a sharp angle
Decision log¶
- Fill in as you go: scalar-graph vs immediate tensor design, why you picked the order above, AMD GPU situation re: CUDA milestone.
Explicitly not in scope (v1)¶
Multi-threading, GPU training (beyond the optional CUDA stretch), anything beyond MLP architecture. Convolution support is the Mini NPU's problem if it comes up, not seatorch's.