From-scratch GPT-2 124M pretrained on 2.48B tokens with 4x A40 — full writeup

upulbandara · reddit · 2026-10-20

To understand LLM pre-training hands-on, the author built and trained GPT-2 (124M params) from scratch: 2.48B tokens (20 tokens per parameter) on 4 NVIDIA A40 GPUs, producing reasonably coherent English output. Inspired by Karpathy's nanoGPT work, the code and training details are open-sourced on GitHub (upul/Build-GPT-2).

The project covers the key pre-training pieces:

Next step: a 1B model with RoPE, RMSNorm, SwiGLU, and Grouped-Query Attention.

Original post →

More from Infra

Infra channel →