llm.asm runs Qwen3-0.6B from a 14 KB assembly binary, and boots it as its own operating system
Three projects in pure x86-64 assembly: a Qwen3 inference engine, a bootable kernel that does nothing else, and a small GPT trainer. The author reports faster decoding than llama.cpp.
llm.asm, published November 25 by GitHub user alesha-pro, is 17,252 lines of x86-64 NASM assembly with no C, no libc and no runtime dependencies. It contains a program that runs Qwen3-0.6B, a kernel that boots straight into a chat prompt with the same model, and a trainer for a small GPT. The inference binary is 14,712 bytes. The author’s own benchmark has it decoding faster than llama.cpp on a CPU.
How it works
The executable holds only code. The weights and tokenizer live in a separate file of about 614 MiB that a one-time Python script exports from the original checkpoint, laid out so the program can map it into memory and use it in place. Weights are 8-bit integers with a scale for every 32 values.
Everything else is written by hand: the BPE tokenizer, the chat template, the attention and normalization math, even the exponential and sine functions. The thread pool is built directly on the Linux clone and futex system calls.
The speed comes from the default matrix kernel. It quantizes the activations to 8 bits once per multiplication, so the inner loop multiplies bytes by bytes using AVX2 integer instructions. It needs AVX2, FMA and F16C, which the README translates as Intel Haswell or newer, and it does not need AVX-512.
The kernel version is 24,252 bytes. It boots through Multiboot, switches to 64-bit mode, wakes the other cores itself and drives a text screen, keyboard and serial port. There is no disk or filesystem: the bootloader hands it the model as a blob already in RAM. The README reports 74 to 94 ms from boot to prompt.
The third project trains a 2.7M-parameter character model with a hand-written backward pass and AdamW. The README says its gradients match PyTorch’s across all 21 tensors.
The numbers
All from the README, measured by the author on an AMD EPYC 7642, CPU only, generating 64 tokens, in tokens per second.
| Threads | llm.asm | llama.cpp Q8_0 | Booted kernel, under KVM |
|---|---|---|---|
| 1 | 20.70 | 16.63 | 23.67 |
| 8 | 103.64 | 80.79 | 118.08 |
| 16 | 121.86 | 103.03 | 134.94 |
The fine print is also the author’s. The comparison is decoding only. For reading the prompt, llm.asm goes one token at a time and llama.cpp batches: the README gives 26.7 to 160.8 tokens per second against 56 to 1,113. The llama.cpp version is not stated. The fast kernel is not bit-exact with full precision; the README reports the same 64 greedy tokens as PyTorch on one prompt. Context is fixed at 2,048 tokens. And every “bare-metal” figure was measured in a virtual machine. The README reports no run on a physical computer.
Try it yourself
The repo is MIT-licensed and builds with nasm and binutils on x86-64 Linux. You export the model once with Python, then run the binary, or boot the kernel in QEMU with the model attached; the README recommends 2 GiB of RAM for that.
We have not built or booted any of it. This is based on the README files and the commit log. The same author wrote the ledger of 115 inference experiments we covered on November 22.