{"slug": "microgpt-in-pure-c-hits-10m-tps-on-apple-m5", "title": "Microgpt in pure C hits 10M tps on Apple m5", "summary": "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.", "body_md": "The most atomic way to train and inference a GPT in pure, dependency-free C.\n\nA 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.\n\n```\nmake run\n```\n\nOr run it directly, on any corpus with one item per line:\n\n```\n./microgpt data/names.txt\n```\n\nBuilds on macOS, Linux and Windows (MSYS2), on ARM64 with NEON and x86-64 with AVX2. The Makefile picks the flags for the host.\n\n```\nstep 5000 / 20000 | loss 2.6036  (avg 2.2940)\nstep 10000 / 20000 | loss 1.9639  (avg 2.2564)\nstep 15000 / 20000 | loss 2.7007  (avg 2.2151)\nstep 20000 / 20000 | loss 2.3463  (avg 2.2201)\n\ninference\nsample  1: kayley\nsample  2: maria\nsample  3: arana\nsample  4: shayan\nsample  5: jayden\nsample  6: saria\nsample  7: kaylen\nsample  8: amari\nsample  9: alina\nsample 10: mailyn\n  c fp32+NEON       10168430 tok/sec\n```\n\nThe 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.\n\nTraining and inference use separate forward passes. `gpt_forward`\n\nstores\nactivations for backprop; `gpt_forward_infer`\n\nis a specialised\nsingle-token path whose logits match it to within fp32 rounding.\n[docs/PERFORMANCE.md](/vixhal-baraiya/microgpt-c/blob/main/docs/PERFORMANCE.md) covers how that path works and\nwhat limits it.\n\n| machine | backend | tok/sec |\n|---|---|---|\n| Apple M5 Pro | NEON | 10,168,430 |\n| AMD Ryzen 5 5600H | AVX2 | 6,927,775 |", "url": "https://wpnews.pro/news/microgpt-in-pure-c-hits-10m-tps-on-apple-m5", "canonical_source": "https://github.com/vixhal-baraiya/microgpt-c", "published_at": "2026-08-18 15:46:46+00:00", "updated_at": "2026-08-19 15:43:28.281153+00:00", "lang": "en", "topics": ["artificial-intelligence", "machine-learning", "large-language-models", "developer-tools"], "entities": ["microgpt", "Apple M5 Pro", "AMD Ryzen 5 5600H"], "alternates": {"html": "https://wpnews.pro/news/microgpt-in-pure-c-hits-10m-tps-on-apple-m5", "markdown": "https://wpnews.pro/news/microgpt-in-pure-c-hits-10m-tps-on-apple-m5.md", "text": "https://wpnews.pro/news/microgpt-in-pure-c-hits-10m-tps-on-apple-m5.txt", "jsonld": "https://wpnews.pro/news/microgpt-in-pure-c-hits-10m-tps-on-apple-m5.jsonld"}}