llm.asm: 25KB Bare-Metal x86-64 Assembly OS for Local LLM Inference

Phase 2 of `llm.asm` (`alesha-pro/llm.asm`) is a bootable x86-64 operating system written in 100% pure NASM assembly that runs `Qwen3-0.6B` with zero Linux kernel, C, Rust, or `libc`. Weighing just 25,404 bytes (`FAST_Q8=1`) and booting in 74–94 ms, it reaches 134.9 tok/s on 16-vCPU QEMU KVM—outperforming `llama.cpp` CPU decode by 18%–36%.
llm.asm: 25KB Bare-Metal x86-64 Assembly OS for Local LLM Inference: Phase 2 of `llm.asm` (`alesha-pro/llm.asm`) is a bootable x86-64 operating system written in 100% pure NASM assembly that runs `Qwen3-0.6B` with zero Linux kernel, C, Rust, or `libc`. Weighing just 25,404 bytes (`FAST_Q8=1`) and booting in 74–94 ms, it reaches 134.9 tok/s on 16-vCPU QEMU KVM—outperforming `llama.cpp` CPU decode by 18%–36%. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.
- 25,404-Byte Multiboot 1 Kernel: Zero Linux, zero Rust, zero C, and zero `libc`—`.text` is 18,151 B and `.rodata` is 2,900 B with zero dynamic dependencies.
- 74–94 ms Cold Boot to REPL: Boots directly into 64-bit Long Mode across all SMP cores with persistent multi-turn KV-cache (`449 MiB` arena on `2 MiB` huge pages).
- 18%–36% Faster Than llama.cpp CPU: `FAST_Q8=1` pairs an INT8xINT8 AVX2+F16C kernel (`vpmaddubsw`/`vpmaddwd`) with `.asmbin` v2 FP16 block scales (`vcvtph2ps`).
- Diskless Proxmox VE Deployment: Runs live at 55.4 tok/s on a `0 GB` disk Intel Xeon VM from a `~661 MiB` hybrid BIOS+UEFI ISO over VGA and COM1 serial.
import { createAgent } from '@smoke-monkey/harness';const bareMetalAgent = createAgent({agentId: 'llm-asm-baremetal-runner',provider: 'custom',baseUrl: 'http://127.0.0.1:8080/v1',model: 'qwen3-0.6b-q8_0.asmbin',workspacePath: process.cwd(),permissions: {read_file: 'allow',write_file: 'allow',run_command: 'ask',},});async function runBareMetalBenchmark() {const result = await bareMetalAgent.run('Execute `make os FAST_Q8=1` in llm.asm, boot asm-llm-os.elf on QEMU KVM with 16 vCPUs, and parse tok/s parity against Phase 1.');console.log('Bare-Metal OS Telemetry:', result.summary);}runBareMetalBenchmark().catch(console.error);
Watch: Related Video Guides
llm.asm GitHub Tutorial: Train Mini-GPT and Run Qwen3 in Pure Assembly
llm.asm GitHub Overview: Pure x86-64 Assembly for LLM Inference and Training
What Is llm.asm? Bare-Metal x86-64 Inference Without an OS
Phase 2 of llm.asm (02-baremetal-os/) is a standalone, bootable x86-64 operating system implemented entirely in NASM assembly that boots directly into an interactive Qwen3-0.6B multi-turn chat REPL. Stripped to 25,404 bytes (FAST_Q8=1) or 24,764 bytes (FAST_Q8=0), the kernel contains no dynamic sections, no C runtime, and no OS scheduler interference.
At boot, boot.asm switches from Multiboot 1 32-bit entry into 64-bit Long Mode, brings all SMP cores online, and binds the 613.66 MiB .asmbin v2 model file directly from physical RAM using 2 MiB huge-page identity mapping. That huge-page layout and zero-syscall execution yield an extra ~10% throughput bump over the Phase 1 Linux static ELF (15.1 KB) while keeping bit-exact token parity.
llm.asm vs llama.cpp CPU Decode Benchmarks (AMD EPYC 7642)
On an AMD EPYC 7642 running Qwen3-0.6B Q8_0 (pp34 / tg64, CPU-only -ngl 0, 3-run average), llm.asm (FAST_Q8=1) and the Bare-Metal OS consistently outpace llama.cpp across every thread count.
| Threads / vCPUs | llm.asm (FAST_Q8=0) | llama.cpp (Q8_0) | llm.asm (FAST_Q8=1, 15.1 KB) | Bare-Metal OS KVM (25.4 KB) | Speedup vs llama.cpp |
|---|---|---|---|---|---|
| 1 | 7.18 tok/s | 16.63 tok/s | 20.70 tok/s | 23.67 tok/s | +24.5% (ELF) / +42.3% (OS) |
| 4 | 28.12 tok/s | 51.08 tok/s | 69.24 tok/s | 78.89 tok/s | +35.6% (ELF) / +54.4% (OS) |
| 8 | 53.09 tok/s | 80.79 tok/s | 103.64 tok/s | 118.08 tok/s | +28.3% (ELF) / +46.2% (OS) |
| 16 | 77.50 tok/s | 103.03 tok/s | 121.86 tok/s | 134.94 tok/s | +18.3% (ELF) / +31.0% (OS) |
| 24 | 91.88 tok/s | 104.11 tok/s | 123.72 tok/s | 132.90 tok/s | +18.8% (ELF) / +27.7% (OS) |
| 32 | 96.63 tok/s | 103.82 tok/s | 122.51 tok/s | 133.75 tok/s | +18.0% (ELF) / +28.8% (OS) |
On a diskless (0 GB storage) Proxmox VE VM powered by Intel Xeon E5-2670 v3 (12 cores, 2 GiB RAM), the hybrid BIOS+UEFI ISO (~661 MiB) sustains 55.4 tok/s with zero hard disks attached.
Required CPU Instruction Set
Target hardware or QEMU guests must expose `AVX2 + FMA + F16C` (`-cpu host` in QEMU KVM or `--cpu host` in Proxmox `qm create`) and at least 2 GiB non-ballooned RAM for the 649 MiB model plus 449 MiB KV-cache arena.
Building & Booting the 25KB Assembly OS in QEMU KVM
Compile the kernel with nasm and binutils, export Qwen3-0.6B to .asmbin v2 (FP16 block scales), and boot directly over COM1 serial in under 100 ms.
git clone https://github.com/alesha-pro/llm.asm.git && cd llm.asm
make os FAST_Q8=1 && make os-check
# Instant ~85 ms QEMU KVM boot with 16 vCPUs over serial console
qemu-system-x86_64 -enable-kvm -cpu host -m 2G -smp 16 \
-kernel build/asm-llm-os.elf \
-initrd models/qwen3-0.6b-q8_0.asmbin \
-nographicEphemeral Micro-VM Verification with Smoke Monkey Harness
For security-sensitive builds and deterministic evals, Smoke Monkey Harness pairs well with sub-100ms bare-metal or micro-VM sandboxes: spinning up an isolated KVM guest over CMDLINE='prompt="..." shutdown=1' executes single-turn inference and halts cleanly via ACPI without host OS contamination.
Frequently Asked Questions
Q:How fast does the llm.asm bare-metal OS boot and run Qwen3-0.6B?
It cold-boots in 74–94 milliseconds to an interactive prompt and reaches 134.94 tok/s at 16 vCPUs on AMD EPYC 7642 QEMU KVM (78.89 tok/s at 4 vCPUs, up to +54.4% faster than `llama.cpp` CPU).
Q:Why is the Bare-Metal OS ~10% faster than the Phase 1 Linux binary?
Phase 2 maps `.asmbin` v2 weights across 2 MiB huge pages in identity-mapped physical RAM and eliminates Linux scheduler and syscall overhead while maintaining 100% token-exact parity.
Q:Does the 25KB OS support multi-turn conversations?
Yes. The `asm-llm>` console maintains a persistent head-major KV-cache (`ctx=X/2048`), prefilling only new chat turns and supporting `/clear` or `/reset` commands over both PS/2 VGA and COM1 serial.
Q:Can llm.asm boot on real hypervisors without virtual disks?
Yes. `make os-iso` packages the 25 KB kernel, GRUB2 config, and model weights into a ~661 MiB hybrid BIOS+UEFI ISO that runs on a 0 GB disk Proxmox VE VM.
Related Alternatives & Comparisons
Related Architecture Guides
View all guidesBest Open Source Coding Agents in 2026: Free, Local & Fully Hackable Harnesses
MCP Server Security Best Practices: Hardening Model Context Protocol Agents in 2026
Open Source Coding Agent Harness: Build a Forkable, Local AI Engineering Runtime
Build with Smoke Monkey Harness
Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.