Show HN: NanoEuler – GPT-2 scale model in pure C/CUDA from scratch

The 30-Second Skim
- What happened: A developer has open-sourced NanoEuler, a ~116M-parameter GPT-2-class language model built entirely from scratch in C and CUDA — with no PyTorch, no autograd, and no ML libraries, and a complete pretrain-to-chat pipeline that runs on a single consumer GPU.
- Key facts & numbers: NanoEuler is a ~116M-parameter GPT-2-class decoder-only transformer built entirely from scratch in C/CUDA, with no PyTorch, no autograd, and no ML libraries of any kind. Every analytic gradient is hand-derived and verified against a central finite-difference check running in double precision, with the full model passing at a max relative error of 1.02e-04. The CUDA engine pairs cuBLAS matmuls (TF32 tensor cores) with a hand-written tiled FlashAttention kernel using online softmax and no T×T matrix in memory, with GPU vs CPU gradients validated to ~1e-6.
- What happens next: Every gradient finite-difference checked, every kernel hand-rolled, no PyTorch in sight — about as close to 'show me you understand the whole stack' as a repo gets.
- NanoEuler is a ~116M-parameter GPT-2-class decoder-only transformer built entirely from scratch in C/CUDA, with no PyTorch, no autograd, and no ML libraries of any kind.
- Every analytic gradient is hand-derived and verified against a central finite-difference check running in double precision, with the full model passing at a max relative error of 1.02e-04.
- The CUDA engine pairs cuBLAS matmuls (TF32 tensor cores) with a hand-written tiled FlashAttention kernel using online softmax and no T×T matrix in memory, with GPU vs CPU gradients validated to ~1e-6.
- The full pipeline ships in one repo: a hand-written byte-level BPE tokenizer (4096 vocab, ~3.4 bytes/token), pretraining on Project Gutenberg + a FineWeb-Edu slice, and supervised fine-tuning on Alpaca with response-masked cross-entropy.
Why It Matters
For ML engineers and students, the value here is not a new model but a fully auditable, single-file reference implementation: every kernel, gradient, and tokenizer pass is hand-written and gradient-checked, proving that a modern transformer stack can be built and understood end-to-end without any framework in the way.
Sources Cited
Related Coverage
Ask SkimNews