Skip to content

Instantly share code, notes, and snippets.

View nmicic's full-sized avatar
😀
I may be slow to respond.

Nenad Micic nmicic

😀
I may be slow to respond.
View GitHub Profile
@nmicic
nmicic / microgpt.c
Last active March 23, 2026 16:43 — forked from karpathy/microgpt.py
microgpt.c — sub-20ms GPT training and inference in pure C
/* Copyright (c) 2026 Nenad Mićić <nenad@micic.be> https://be.linkedin.com/in/nenadmicic
* SPDX-License-Identifier: Apache-2.0
*
* microgpt.c — Minimal GPT training and inference in 655 lines of pure C.
* Hand-written forward and backward pass, two-phase gradient accumulation.
* Trains a 1-layer, 4-head, 4192-parameter character-level transformer.
*
* Inspired by Andrej Karpathy's microgpt.py (200 lines of Python):
* https://gist.github.com/karpathy/8627fe009c40f57531cb18360106ce95
*