llm.asm runs Qwen3-0.6B in a 24 KB bare-metal OS written in pure assembly

A developer built a bootable operating system from scratch in x86-64 NASM that loads Qwen3-0.6B and outperforms llama.cpp by up to 54% on the same hardware.

cpaua3 min4

A developer has published llm.asm, a bare-metal operating system written entirely in x86-64 NASM assembly that boots Qwen3-0.6B without Linux, Windows, C, Rust, or libc. The Multiboot-compatible kernel binary weighs 24,252 bytes, starts in 74–94 milliseconds, switches to Long Mode, brings all CPU cores online via the APIC, identity-maps the 614 MiB Q8_0 weight file from physical memory, and drops the user into an interactive multi-turn chat with KV-cache, VGA output, PS/2 keyboard, and a serial console.

Boot-to-chat in under 100 milliseconds

The OS image asm-llm-os.elf is a standalone ELF that a bootloader (GRUB, QEMU -kernel, or a hybrid ISO) can load directly. On an AMD EPYC 7642 the kernel reaches the prompt in 74–94 ms; on a Proxmox VE VM with a 12-core Intel Xeon E5-2670 v3 (2014) and 2 GiB RAM — no disk attached — the full boot takes under five seconds, with the kernel itself finishing in 95 ms. The model then runs entirely from RAM, delivering 78 tokens/s during generation and up to 111.5 tokens/s during prompt processing.

Faster than llama.cpp on identical hardware

Benchmarks on the EPYC 7642 (Q8_0, -ngl 0) show the bare-metal build ahead at every thread count:

  • 1 thread — 23.67 vs 16.63 tok/s (+42%)
  • 4 threads — 78.89 vs 51.08 tok/s (+54%)
  • 8 threads — 118.08 vs 80.79 tok/s (+46%)
  • 16 threads — 134.94 vs 103.03 tok/s (+31%, peak 136.6)

A companion Linux ELF (14.7 KB, FAST_Q8=1, INT8×INT8 AVX2+F16C) also beats llama.cpp by 18–36% across 1–40 threads. Running the same binary on bare metal with 2 MiB huge-page mappings adds another ~10%.

Bit-exact parity with PyTorch FP32

Outputs are deterministic regardless of thread count. All 64 tokens produced by greedy decoding match the PyTorch FP32 reference (cosine similarity 0.99965), confirming that the hand-written AVX2/FMA/F16C GEMM/GEMV kernels, RMSNorm, RoPE, SiLU, Softmax, and the parallel GQA attention implementation preserve numerical fidelity while removing every layer of OS and runtime overhead.

Source, ISO builder, and Proxmox guide under MIT

The repository alesha-pro/llm.asmalesha-pro/llm.asm/tree/main/02-baremetal-os contains the OS source (4,167 lines of NASM), a mkiso.sh script that produces a BIOS+UEFI bootable ISO via GRUB Multiboot 1, and a step-by-step guide for deploying a 0 GB disk VM on Proxmox VE. Everything is licensed MIT.

Related reading

Sources

alesha-pro/llm.asmalesha-pro/llm.asm/tree/main/02-baremetal-os
Share

Author

cpaua

VibeCode blog admin. Writing about vibe coding, AI and open source.

Related news

Comments

To leave a comment, log in
Loading...

Weekly digest

The best of vibe coding, AI agents and open source — once a week, no spam.