Reddit
gemma4.c Runs Gemma 4 E2B in 700 Lines of Pure C at Real Time on a Ryzen 7 7700
A single 700-line C file handles the tokenizer, transformer, KV cache, sampling and CPU kernels with no external library doing the interesting parts, producing a roughly 5.0 GB model file. Weights are int8 with FP16 scales, linear-layer inputs are dynamically quantized to int8, and other activations stay float32, validated against the Hugging Face Transformers reference running Google's unquantized Gemma 4 E2B QAT checkpoint in BF16. The author confirmed the demo video is real time on a Ryzen 7 7700, CPU only, and describes it as an educational proof of how small a competent inference runtime can be.
↳ Follow the thread