cd /news/artificial-intelligence/microgpt-in-pure-c-hits-10m-tps-on-a… · home topics artificial-intelligence article
[ARTICLE · art-103128] src=github.com ↗ pub= topic=artificial-intelligence verified=true sentiment=↑ positive

Microgpt in pure C hits 10M tps on Apple m5

A new open-source project, microgpt, implements a character-level GPT in a single dependency-free C file, achieving 10,168,430 tokens per second on an Apple M5 Pro with NEON and 6,927,775 tokens per second on an AMD Ryzen 5 5600H with AVX2. The model, with 4,192 parameters, trains on 20,000 of 32,033 names in seconds and generalizes to unseen data, scoring 2.2039 nats per character on held-out names.

read1 min views3 publishedAug 18, 2026
Microgpt in pure C hits 10M tps on Apple m5
Image: Michielbdejong (auto-discovered)

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.

make run

Or run it directly, on any corpus with one item per line:

./microgpt data/names.txt

Builds on macOS, Linux and Windows (MSYS2), on ARM64 with NEON and x86-64 with AVX2. The Makefile picks the flags for the host.

step 5000 / 20000 | loss 2.6036  (avg 2.2940)
step 10000 / 20000 | loss 1.9639  (avg 2.2564)
step 15000 / 20000 | loss 2.7007  (avg 2.2151)
step 20000 / 20000 | loss 2.3463  (avg 2.2201)

inference
sample  1: kayley
sample  2: maria
sample  3: arana
sample  4: shayan
sample  5: jayden
sample  6: saria
sample  7: kaylen
sample  8: amari
sample  9: alina
sample 10: mailyn
  c fp32+NEON       10168430 tok/sec

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.

machine backend tok/sec
Apple M5 Pro NEON 10,168,430
AMD Ryzen 5 5600H AVX2 6,927,775
── more in #artificial-intelligence 4 stories · sorted by recency
── more on @microgpt 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/microgpt-in-pure-c-h…] indexed:0 read:1min 2026-08-18 ·