GPT-2 Runs in Pure CMake with Integer Arithmetic

Implementation of GPT-2 in pure CMake

GPT-2 Runs in Pure CMake with Integer Arithmetic

A new GitHub project implements GPT-2 entirely in CMake, using Q16.16 fixed-point arithmetic instead of floating-point. It includes both a toy model and the full GPT-2 model, with scripts to generate tables and convert Hugging Face checkpoints. The README demonstrates running the model with a simple `cmake -P` command, making it a quirky but functional proof that CMake can serve as a general-purpose programming language.

GPT-2 in pure CMake, executed with Q16.16 integer arithmetic.
  1. voxelghost

    [delayed]

  2. inoffensivename

    To quote April Ludgate: Gross. I love it.

  3. ahartmetz

    FWIW, this is most likely not even fast enough to laugh at how slow it is - for that, you need to see something happening in less than an hour or so.

    It can only use one core at a time, but that is not the worst thing: CMake is interpreted and stringly typed, so every number will have to be converted string -> number and usually back on every use.

More from this day

2026-08-23