// HACKER NEWS — CYBERSECURITY
Microgpt in pure C hits 10M tps on Apple m5
The most atomic way to train and inference a GPT in pure, dependency-free C.
A character-level transformer with forward pass, backprop, Adam and
sampling, in one C file with nothing beyond libc. It trains on ~32k names
in a couple of seconds and generates new ones.
Or run it directly, on any corpus with one item per line:
Builds on macOS, Linux and Windows (MSYS2), on ARM64 with NEON and x86-64
with AVX2. The Makefile picks the flags for the host.
The model has 4192 parameters and generalises rather than memorises.
Trained on 20000 of the 32033 names, it scores 2.2054 nats per character
on those and 2.2039 on the 12033 it never saw, beating an interpolated
trigram that has nearly five times as many parameters.
Training and inference use separate forward passes. gpt_forward stores
activations for backprop; gpt_forward_infer is a specialised
single-token path whose logits match it to within fp32 rounding.
docs/PERFORMANCE.md covers how that path works and
what limits it.