Cygnet: a Forth interpreter in pure LLVM IR runs Qwen3 inference 9.76x faster than C

solidavocadorock · reddit · 2026-11-30

Inspired by Alexey Fateev's llm.asm (hand-written x86-64 assembly running AI on bare metal, Ring -1 hypervisors and eBPF LSM hooks), the author built Cygnet: a from-scratch Forth interpreter/compiler written in pure LLVM IR (.ll), with five AI phases implemented as compact portable Forth (.fs) programs.

Key design points:

Benchmarks on Ryzen 9 7950X (QEMU/KVM, Ring 0): Phase 01 Qwen3 Q80 inference hits 33,236 tok/s vs 3,406 tok/s for reference C -O2 (9.76x) with 16/16 exact tokens; Phase 02 is a 16,664B bare-metal Ring 0 Forth OS booting in 45ms; Phase 03 trains a from-scratch Mini-GPT on TinyShakespeare at 206,941 tok/s (loss 4.17→2.08); Phase 04's kernel-patch policy passes 122/122 held-out scenarios (vs 119/122 for GRPO MiniCPM5-2B) at 139.2ns per decision.

Original post →

More from Infra

Infra channel →