← Back to blog
AiAbout 6 min read

A 14,712-byte binary runs Qwen3-0.6B, and it beats llama.cpp on CPU

Published Nov 29, 2026
A 14,712-byte binary runs Qwen3-0.6B, and it beats llama.cpp on CPU

A 14,712-byte static binary is smaller than most README files. The one in llm.asm loads a tokenizer, runs Qwen3-0.6B at Q8_0, supports multi-turn chat with a KV cache, and prints tokens to a terminal. No C, no C++, no Rust, no libc, no libm, no runtime dependencies. It is assembled with nasm and linked with ld.

The repository appeared on 25 November and has passed three thousand stars. It contains three projects written in 100% pure x86-64 assembly, 17,252 lines in total.

The three binaries

The first is the inference engine. 14,712 bytes as shipped, or 14,008 with a compile flag that trades a little speed for size. It includes the BPE tokenizer, GQA, QK-Norm, RoPE, SwiGLU, a single-shot mode and a chat REPL with a KV cache.

The second is a bare-metal operating system. 24,252 bytes, boots on x86-64 through Multiboot 1 into long mode, brings up AVX2, FMA and F16C, initialises ACPI and APIC for SMP, and gives you VGA, PS/2 and a serial console with multi-turn chat. Boot time is 74 to 94 milliseconds. It needs no disk.

The third is a Mini-GPT trainer: 32,944 bytes, FP32, with a register-blocked 6×16 AVX2+FMA SGEMM, a full analytical backward pass, decoupled AdamW, and a live 80×24 Braille TUI. It trains TinyShakespeare to a validation loss of 1.51 in about four minutes, at 27,662 tokens per second.

There are two more directories for the curious: a bare-metal AMD SVM hypervisor running beneath an unmodified Linux 5.15, and a fixed-point INT8 decision model running inside four eBPF LSM hooks.

The numbers that make it more than a stunt

Writing an inference engine in assembly is the kind of project that usually ends with "it works, and it is slower than a real one, but it was fun". This one is not that.

Qwen3-0.6B at Q8_0 on the inference binary: 126.8 tok/s decode at 40 threads, 20.7 tok/s at one thread. Against llama.cpp's CPU path at the same quantisation, the README claims 18% to 36% faster across one to forty threads. Against PyTorch FP32, cosine similarity is 0.99965, and the greedy decode matches 64 out of 64 tokens.

The 0.99965 is the part that matters for credibility. An assembly implementation that is fast but wrong is easy; the check that it produces the same tokens as the reference is what separates an optimised engine from a demo. The README also reports a cosine of exactly 1.0000000000 across all 21 gradient tensors for the trainer's backward pass, which is the same discipline applied to training.

The bare-metal OS number is the one that made me look twice: 134.9 tok/s on a KVM EPYC, 55.4 tok/s on a Proxmox host with a Xeon E5-2670 v3, and zero gigabytes of disk. That last figure is not a typo. The model is embedded in the image.

Why hand-written kernels still win sometimes

The usual argument against assembly is that compilers are better than people now, and for most code that is true. It stops being true at the boundaries.

A quantised GEMV at batch size one is a memory-bound loop with a specific access pattern. Getting it fast means knowing exactly which registers hold what, how the AVX2 FMA latency chains overlap, and where the data has to be prefetched. A compiler will produce something correct; whether it produces something optimal depends on whether the loop structure survives optimisation.

The second advantage is size. 14,712 bytes fits in L1 instruction cache alongside the weights that are streaming through. A runtime with a dynamic linker and a BLAS library does not.

The third is that there is nothing to install. A static ELF that runs on any x86-64 Linux kernel is the most portable form a program can take, in the sense that matters when you are deploying to a machine where you cannot install anything.

Weights, tokenizer and KV cache inside a 14 KB static binary

No libm means writing expf yourself

The detail that explains most of the binary size is what had to be replaced.

Without libc or libm, there is no expf, no sincosf, no memcpy, no malloc, and no thread creation. All of it is in the repository: the exponential and sine/cosine approximations used in softmax and rotary embeddings, RMSNorm, RoPE, SiLU, the BPE tokenizer, an AVX2+FMA+F16C GEMM and GEMV engine, and a thread pool built on raw clone() and futex() system calls.

That is a lot of surface for one person to get right, and it is where the correctness checks earn their place. An approximation of expf that is off by a few units in the last place will not break a demo; it will shift a softmax distribution, and the output will look fine until it does not. Reporting a 0.99965 cosine against PyTorch FP32 is how you show the approximations are tight enough.

The tokenizer is the other invisible cost. BPE looks simple and is not: merges, byte-level fallback, and the exact pre-tokenisation rules decide whether the model sees the same IDs as the reference implementation. Getting 64 out of 64 greedy tokens to match is a tokenizer test as much as a kernel test.

The caveats worth stating

The comparison is against llama.cpp at Q8_0 on CPU. That is one quantisation, one engine, and one family of processors. Q8_0 is not the quantisation most people run, and the CPU path of llama.cpp is not its fastest path. A GPU comparison would look nothing like this.

The model is 0.6B parameters. Small models are dominated by fixed overheads, which is where a hand-written implementation can win most. The same techniques on a 27B model would still help, but the ratio would change.

The README also names its hardware. The 40-thread figure implies a specific machine; the 55.4 tok/s figure is on a Xeon E5-2670 v3 from 2014. Those are not the same test, and the document treats them as separate results rather than blending them into one headline.

Finally, this is one person's project with an unusual skill set. The value is a floor: the numbers establish what the hardware can do, which is worth knowing the next time an engine claims to be optimised.

What it says about the state of local inference

Two things, and neither is about assembly.

The first is that the gap between a good implementation and a naive one is still large enough to matter. A 0.6B model at 126 tok/s on CPU is fast enough to be useful for classification, extraction and routing, which are the jobs people actually give small models. If that speed is available without a GPU, a lot of pipelines get cheaper.

The second is that verification is becoming the differentiator. Anyone can write a fast loop. Reporting cosine similarity against the reference, exact greedy token matches, gradient checks, and the hardware each number came from is what makes a performance claim worth reading. The same pattern showed up in a tuning skill this week, and in a video tool that measures its own output loudness.

The 14 KB binary is a good headline. The 64 out of 64 matching tokens is the reason to believe it.

Turn ideas into images with ChatPicture

60 free credits every day. Generate, edit, and download — no prompt engineering degree required.

Related articles