I built a complete, working transformer inference engine in pure Go — no CGO, no llama.cpp, no external dependencies — and it runs a 135M-parameter model locally at 9.5 tokens/second on a 4 core VM with 4 GB of RAM. The full source is ~900 lines of Go. Here is the line-by-line breakdown, and an explanation of why Go 1.27 makes this possible for the first time.
Press enter or click to view image in full size
Why Go? Why Now?
Before Go 1.27, the reason AI inference lived in C/C++ was simple: you need direct access to hardware SIMD instructions (AVX2, AVX-512, NEON, SVE), and Go’s compiler didn’t expose them. You could write assembly, call C via CGO, or hope the compiler auto-vectorized your loops (it rarely does for this access pattern).
Go 1.27 changes this with the simd package, which is an experimental standard library addition that provides:
simd.LoadFloat32s(slice)— loads a chunk of decimal numbers (float32s) into a special processor register. Think of a register as a tiny, ultra-fast workspace inside the CPU where calculations happen in a single step..MulAdd(a, b)— computesa * b + accumulatorfor every element in the chunk at the same…