llm.asm: Qwen3-0.6B Runs in 15 KB of Pure Assembly

What llm.asm actually is

On November 25, 2026, GitHub user alesha-pro published llm.asm; seven days later it had 4,683 stars and 726 forks. It promises Qwen3-0.6B inference, a bootable bare-metal OS, and a from-scratch Mini-GPT trainer, all in pure x86-64 NASM assembly, with zero C, zero libc, and zero dependencies.

The repo holds six phases, and the first three matter most: a Qwen3-0.6B inference engine in a 15.1 KB static binary, a bootable OS of 27.2 KB that runs the same model with no Linux underneath, and a Mini-GPT trainer of 33.9 KB with a live Braille interface that draws the loss curve as it trains. Later phases add a Ring -1 hypervisor, an eBPF security monitor for Linux 6.12, and a zero-app OS, though phases 4 and 5 mix in some C, so the pure-assembly claim applies strictly to phases 1 through 3 and 6. (The repo description lists the older launch sizes of 12, 22, and 32 KB.)




The same OS booting as a Proxmox VM with no disk attached. Source: alesha-pro/llm.asm (GitHub, MIT). 


Why pure assembly changes the numbers

A normal inference engine carries a runtime: llama.cpp is a large C++ codebase with a build system, threading code, and platform layers. llm.asm skips all of that. No libc to link, no allocator to call, no framework between the weights and the CPU. The matrix math is written by hand against AVX2, FMA, and F16C, with an INT8 kernel on vpmaddubsw and vpmaddwd, a contiguous head-major KV cache, and parallel grouped-query attention.

The README benchmark pits the fast INT8 path against llama.cpp running Q8_0 on an AMD EPYC 7642, same weights on both sides. At one thread it hits 20.70 tokens per second against 16.63; at 40 threads it peaks at 126.8 against 105.08, a lead of 18 to 36 percent across the range. The bare-metal OS reaches 134.9 on 16 KVM vCPUs, credited to 2 MiB huge-page identity mapping.

The parity check matters as much as the speed. The fast path matches PyTorch FP32 output with a cosine similarity of 0.9996517 and 64 out of 64 identical greedy tokens; the slower exact path hits 1.000000000. The trainer's gradients match PyTorch with a minimum cosine of 1.0000000000 across all 21 tensors. These are the author's own numbers on one machine, not yet independently repeated, but the method is plain enough to reproduce.

How to run it

You need an x86-64 CPU with AVX2, FMA, and F16C, plus nasm and GNU binutils. Fallback builds cover older CPUs with AVX and SSE4.1 only, and the bare-metal OS even builds for SSE2-only machines. Python only converts weights and runs reference checks, never inference.

Clone the repo and build everything:

git clone https://github.com/alesha-pro/llm.asm.git && cd llm.asm
make all

Then convert the Qwen3-0.6B weights from BF16 into the project's own .asmbin format and start a chat:

python3 scripts/export_weights.py --model-dir models/qwen3-0.6b-bf16 --out models/qwen3-0.6b-q8_0.asmbin --scale-dtype fp16
./build/asm-llm -m models/qwen3-0.6b-q8_0.asmbin --chat -t 16

The weights are another matter: around 614 MiB converted, about 40,000 times the binary, so grab the Qwen3-0.6B release from Hugging Face first. Chat mode keeps the KV cache between turns.

The bare-metal OS and the trainer

Phase 2 is the part that gets people talking: one command boots the model as its own OS under QEMU with KVM:

make os-run MODEL=models/qwen3-0.6b-q8_0.asmbin SMP=16

Boot takes 74 to 94 milliseconds, landing you in a chat prompt on the VGA console with no disk image and no Linux kernel in the path. The same ISO runs on a real Proxmox VM with zero gigabytes of disk, at 55.4 tokens per second on an older Intel Xeon E5-2670 v3. A hybrid BIOS/UEFI ISO from make os-iso can be written to a USB stick to boot real hardware.


Qwen3-0.6B running on the bare-metal llm.asm OS under QEMU/KVM. Source: alesha-pro/llm.asm (GitHub, MIT).

Phase 3 trains a small GPT from scratch on TinyShakespeare, in assembly with AdamW, drawing a live 80 by 24 Braille chart of the loss curve as it works:

./build/asm-gpt-train --data data/tinyshakespeare.txt --steps 400 --seq 128 -t 16 --save checkpoints/shakespeare.ckpt

It is a teaching tool more than a training rig: a 2.7-million-parameter Shakespeare model will not write your emails, but gradient descent in a 34 KB binary with no framework makes the mechanics unusually visible.

What it cannot do

Small binaries invite big claims, so here are the limits. First, Qwen3-0.6B is the smallest in the family: fine for short chat and simple questions, but it will lose track of long context and hard reasoning. A separate kernel runs Qwen3.5-2B; there is no 7B or 32B option.

Second, it is x86-64 only, with community ports for AArch64, RISC-V, and native macOS on Apple silicon living in other repositories. There is no GPU path, so for serving many users at once, a GPU engine is still the right tool; our comparison of vLLM, Ollama, llama.cpp, and SGLang covers that ground.

Third, there is no tool use, no agent loop, and no API server: a chat binary and an OS, not a platform. The benchmarks come from the author on one 47-core server CPU, so your laptop will be slower, and nobody has published an independent rerun. And the project is one week old, with 120 commits on main; early issues already mention thread-count quirks and a trainer that accepts invalid settings without complaint.

Who should try it

If you write systems code, build inference engines, or teach operating systems, this repo is worth an evening. The shared NASM core is about 3,857 lines reused across the first three phases, small enough to read end to end, and it shows what hand-tuned INT8 kernels and cache layout can buy on CPU.

If you just want a local chatbot, skip it. Running an open model locally with Ollama takes twenty minutes and gives you a bigger model, an API, and a community. For the smallest footprint on weak hardware, running a model on a Raspberry Pi 5 with llama.cpp is the closer match. Before picking any of these, check how much VRAM a local model needs: the weights, not the engine, decide the hardware.

llm.asm will not replace your inference stack. It shows what happens when someone strips that stack to nothing and writes the rest by hand: a 15 KB program that talks back and boots its own OS in under a tenth of a second.

Comments

Popular posts from this blog

Open-Source AI Weekly: Bonsai, GigaChat 4 Lead

Claude Claims Proof of Riemann Hypothesis After 167 Years

How to Build an AI Agent with LangGraph in 30 Minutes