Local & Offline
~10 min readUpdated: November 2026

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

llm.asm Bare-Metal 25KB x86-64 Assembly OS and AVX2 SIMD Kernel Benchmarks in Smoke Monkey

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%.

Technical Review: Smoke Monkey Core Architecture Team
Tested on Node.js 18+ & BunTypeScript 5.x
Quick Answer & Executive Definition

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.

Key Architectural Takeaways
Quick Implementation Examplellm-asm-kvm-harness.ts
llm-asm-kvm-harness.tstypescript
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);
Video Guides

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 / vCPUsllm.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
17.18 tok/s16.63 tok/s20.70 tok/s23.67 tok/s+24.5% (ELF) / +42.3% (OS)
428.12 tok/s51.08 tok/s69.24 tok/s78.89 tok/s+35.6% (ELF) / +54.4% (OS)
853.09 tok/s80.79 tok/s103.64 tok/s118.08 tok/s+28.3% (ELF) / +46.2% (OS)
1677.50 tok/s103.03 tok/s121.86 tok/s134.94 tok/s+18.3% (ELF) / +31.0% (OS)
2491.88 tok/s104.11 tok/s123.72 tok/s132.90 tok/s+18.8% (ELF) / +27.7% (OS)
3296.63 tok/s103.82 tok/s122.51 tok/s133.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.

bash
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 \
  -nographic

Ephemeral 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.

Google Search Questions & Answers

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 guides

Build with Smoke Monkey Harness

Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.

npm install smoke-monkey-harness