Back to Home

Qwen on Bare Metal: A 24 KB OS That Needs No Linux

The virtual machine had no disk. Not a small disk, not a thin-provisioned one. Zero gigabytes. Somewhere in a Proxmox cluster, a Xeon E5-2670 v3 handed a few megabytes of memory to a bootloader, and eighty milliseconds later a prompt appeared on a VGA console. A human typed a question. The answer scrolled back one token at a time at 55.4 tokens per second.

No Linux, no Windows, no C runtime, no Rust, no libc, no Python. Just Qwen3-0.6B, the 0.6-billion-parameter model from Alibaba's Qwen family, running on metal.

That demo is the middle chapter of a repository called llm.asm, published this week by a developer working under the handle alesha-pro. The claim is absurd in its plainness: three complete LLM projects in pure x86-64 NASM assembly, assembled with nasm, linked with ld, zero runtime dependencies anywhere in the chain. It climbed the Hacker News front page and stayed there, with 228 points and fifty-plus comments from people who could not agree on whether it was a landmark or a stunt.

A Boot, Then a Sentence

The bare-metal image is 24,252 bytes, and 23,612 on the exact FP32 build. That is smaller than most icon sets, and it contains a transformer.

Getting there is a sequence any operating systems course would recognize, executed without a safety net. Multiboot 1 hands off control. The code sets up four-level paging, switches into Long Mode, enables AVX2, FMA and F16C so the matrix math can use vector registers, installs an IDT, walks the ACPI MADT for the local APICs, and starts 16 to 64 application processors with an INIT-SIPI-SIPI sequence and a spin barrier. Drivers for COM1, an 80x25 VGA console and a PS/2 keyboard are written from scratch. Boot takes 74 to 94 milliseconds.

Then the chat loop starts. Multi-turn conversations keep a KV cache across turns, and slash commands like /clear, /think and /bench work straight from the console.

  • Boot path: Multiboot 1, four-level paging, Long Mode, AVX2 with FMA and F16C, ACPI poweroff
  • Compute: hand-written INT8xINT8 AVX2 matmul, FP16 block scales through F16C, RMSNorm, RoPE, SiLU and softmax, all in assembly
  • Runtime: zero libc, zero libm, zero dynamic section, 24 KB on disk
  • Interface: VGA text console, PS/2 keyboard, serial console, multi-turn KV-cache REPL

The Numbers That Make It More Than a Joke

Novelty projects usually avoid benchmarks, because benchmarks are where the story falls apart. This one leads with them.

On a 16-vCPU QEMU KVM guest on an AMD EPYC 7642, the bare-metal OS decodes at 134.9 tokens per second, peaking at 136.6. On one vCPU it manages 23.7. On the real diskless Proxmox VM, the Xeon pushes 55.4.

The comparison that matters is against llama.cpp, the de facto standard for CPU inference: same Qwen3-0.6B Q8_0 weights, same machine, CPU only, three runs averaged. The 14.7 KB Linux ELF from the project's first phase beats llama.cpp at every thread count from one to forty.

  • 1 thread: 20.70 tok/s versus 16.63, a 24.5 percent lead
  • 4 threads: 69.24 versus 51.08, up 35.6 percent
  • 16 threads: 121.86 versus 103.03, up 18.3 percent
  • 40 threads: 125.86 versus 105.08, up 19.8 percent

Correctness gets the same bluntness. Against PyTorch FP32, the fast path lands at a cosine similarity of 0.99965 and reproduces 64 of 64 greedy tokens exactly, while the exact path matches the Python Q8_0 reference at 1.000000000. Outputs are bit-identical from one thread to forty, and the operating system matches the Linux build token for token across five prompts and across 1 to 32 KVM vCPUs.

Hacker News did what Hacker News does. One commenter asked, straight-faced, for a version with no AI in it. Another replied: is it acceptable if the AI-free operating system was also built by AI?

The serious thread asked whether this is useful at all. A frontier model burns so much compute that the Linux layer above it is rounding error. Fair. But three counterarguments kept surfacing.

  • Attack surface. No kernel, no package manager, no background services, nothing to patch on a Tuesday. A connected inference appliance that cannot be bricked by a font update is a real property, not a vibe.
  • Predictability. With a fixed binary and huge-page identity mapping, latency stops wandering. The bare-metal build picks up roughly another ten percent over the Linux one purely from memory layout.
  • Cost granularity. A token appliance that serves one small model and nothing else is a different product category from a server running an orchestrator to host a chatbot.

The skeptics were not wrong either. A 0.6B model without a harness is a chat box with opinions, and the harness still runs on your laptop. That split is how almost everyone deploys tools today, so the objection lands softer than it first sounds.

The Trilogy Behind It

The operating system is not even the strangest part. Three projects share a 3,857-line assembly core, and the same math, tokenizer and transformer files compile for Linux and for bare metal with a single define that swaps mmap and clone for physical modules and APIC barriers.

The first is a 14,712-byte static Linux ELF running Qwen3-0.6B with a built-in BPE tokenizer, grouped-query attention, QK-norm and SwiGLU. The third is a 32,944-byte Mini-GPT trainer: a register-blocked 6x16 AVX2 SGEMM kernel, a hand-derived backward pass matching PyTorch across all 21 gradient tensors at a cosine of 1.0000000000, decoupled AdamW, and a live 80x24 Unicode Braille loss curve in the terminal.

What sticks is not the byte count. It is the demonstration that the modern inference stack has no hidden magic left. Every piece of what we call an AI runtime, from the exponential function inside softmax to the KV cache layout to the thread pool, fits in a few thousand lines that one determined person can write and then verify against an independent reference.

For anyone who assumed the operating system is load-bearing, a diskless virtual machine answering questions in 74 milliseconds is a quiet correction. The model was never waiting on Linux. We kept it there because it was easier.

Comments

No comments yet. Be the first to share your thoughts!