News

日本語 · English · 中文

Qwen3-0.6B runs on a 24KB pure assembly OS "llm.asm", released on GitHub—134.9 tok/s on KVM

What to preserve: - Output only the translation. Do not add prefaces, explanations, or annotations. - Do not add words, evaluations, or reasons not present in the original text. Do not omit any content from the original text. - Numbers, units, dates, proper nouns, stock tickers, company names, and product names must remain exactly as in the original (do not change any numbers). - Preserve the structure of Markdown headings, lists, and tables. - For the `{{link:number|display text}}` syntax, keep the number as is and translate only the display text. - For `[text](URL)` links, keep the URL as is and translate only the text. Text to translate (article summary): Alexey Fateev has published a bootable OS called "Phase 2: Bare-Metal Bootable Qwen3-0.6B OS" on his GitHub repository "llm.asm," which runs Qwen/Qwen3-0.6B directly on x86-64 bare metal. The kernel is 24,252 bytes (FAST_Q8=1) and uses no Linux, Windows, C, Rust, or libc. In his measurements, decoding speed reached 134.9 tok/s on QEMU KVM (AMD EPYC 7642, 16 vCPU), with cold boot times between 74 and 94 ms.

Alexey Fateev has released a standalone bootable x86-64 operating system called "Phase 2: Bare-Metal Bootable Qwen3-0.6B OS" on the GitHub repository llm.asm (MIT license), which runs Qwen/Qwen3-0.6B directly on hardware or via KVM. This configuration uses neither Linux, Windows, C, Rust, nor libc. The same repository contains an inference engine of identical design (Phase 1, 01-qwen3-inference) that runs on Linux; this OS (Phase 2) shares its computation components with it.

Kernel Size and Boot Time

According to his explanation, the stripped static Multiboot 1 kernel is 24,252 bytes (FAST_Q8=1, default). The breakdown consists of .text at 17,143 bytes, .rodata at 2,772 bytes, and .bss as 2.1 MiB of NOBITS, with zero dynamic dependencies. With FAST_Q8=0 (conventional Q8_0xFP32), it becomes 23,612 bytes.

In his measurements, cold boot takes 74–94 ms to reach the interactive asm-llm> multi-turn chat. It retains KV-cache across turns, brings all SMP cores online, and binds models .asmbin v2 (614 MiB, FP16 scale) or v1 (649 MiB, FP32 scale) from physical RAM via zero-copy on 2 MiB huge pages.

Performance Measurements by the Author

He claims 100% token-level and byte-level parity between Phase 1 and Phase 2 across 1–32 vCPUs. Additionally, he reports decoding speeds of 134.9 tok/s on QEMU KVM (AMD EPYC 7642, 16 vCPU) — 23.7 tok/s on 1 vCPU, 118.1 tok/s on 8 vCPU, peaking at 136.6 tok/s — and 55.4 tok/s on a Proxmox VE VM with 0 GB disk (Intel Xeon E5-2670 v3, 12 cores).

KVM SMP scaling measurements (FAST_Q8=1, .asmbin v2 FP16 scale, AMD EPYC 7642, 34-token prompt, 64-token generation, greedy) are as follows:

vCPU (KVM)SMP OnlineBoot Complete (ms)Boot → First Token (ms)Prefill (tok/s)Decode (tok/s)Parity with Phase 1
11/173.471161.4831.7223.46 (peak 23.67)Exact match (64/64)
44/484.10425.11104.6778.17 (peak 78.89)Exact match (64/64)
88/884.54316.71157.46118.97Exact match (64/64)
1616/1684.88312.87160.46134.94 (peak 136.63)Exact match (64/64)
2424/2494.27288.75190.67133.07Exact match (64/64)
3232/3289.84313.82167.05132.43 (peak 133.75)Exact match (64/64)

He explains that because boot.asm identity-maps guest RAM using 2 MiB huge pages, it avoids 4 KiB page table walks spanning the 614 MiB model, surpassing Phase 1’s use of Linux mmap() and CPU Q8_0 in llama.cpp across all thread counts.

As real-world measurements on a Proxmox VE VM, he lists the following figures:

PromptPrompt TokensGenerated TokensPrefillDecode
Explanation of CPU cache (3 sentences)2552286.20 ms (87.35 tok/s)920.15 ms (55.43 tok/s)
Alice & Bob apple word problem3996446.86 ms (87.28 tok/s)1770.49 ms (53.66 tok/s)

Configuration and Features

According to him, Phase 2 compiles shared/math.asm, shared/matmul.asm, shared/tokenizer.asm, and shared/transformer.asm with -DBARE_METAL -DFAST_Q8=$(FAST_Q8) and combines them with 4,167 lines of bare-metal OS code.

  • Boot and Long Mode (boot.asm, linker.ld): Verifies Multiboot 1 magic (0x2BADB002), zeroes .bss, builds a 4-level identity table of 2 MiB huge pages covering 0..4 GiB (specifying Strong Uncacheable for 0xFE000000..0xFFFFFFFF for Local APIC MMIO), enters 64-bit long mode, sets up an exception IDT with 32 entries, verifies XSAVE + AVX + AVX2 + FMA + F16C via CPUID, and initializes CR0/CR4/XCR0=7/MXCSR.
  • Zero-Copy Weights and Physical Arena (runtime.asm): Directly binds .asmbin by physical address (verifying "ASML" magic), cuts out a 449 MiB KV-cache plus scratch arena from the largest available Multiboot memory map region, and zeros it using AVX2.
  • Bare-Metal SMP (smp.asm): Parses ACPI RSDP to RSDT/XSDT and MADT ("APIC"), includes fallback for Local APIC broadcast, installs position-independent trampolines at 0x8000 for 16→32→64 bit transitions, wakes all AP cores via Local APIC INIT-SIPI-SIPI, enables AVX2/FMA/MXCSR identically on each core, and dispatches matmul_q8_0 and gqa_attn_range via lock-free cache-line separated spin barriers.
  • Hardware Drivers (drivers.asm): Includes COM1 serial (0x3F8, 115200 8N1), 80x25 color VGA (0xB8000), PS/2 keyboard (0x60/0x64), PIT channel 2 + RDTSC-based 20 ms hardware PIT calibration, and ACPI power-off (QEMU/Bochs ACPI S5 ports 0x604, 0xB004, 0x4004 with isa-debug-exit fallback).

The interactive console operates in multi-turn chat mode by default, retaining KV-cache, and supports commands such as /clear, /think, /nothink, /bench, /halt, and /help. Kernel command line parameters include prompt, max_tokens, ctx, threads, think, raw, single_turn, temp, topp, seed, print_tokens, and shutdown.

Building requires an x86-64 CPU with AVX2 + FMA + F16C support and utilizes nasm, binutils, and qemu-system-x86. Creating a BIOS+UEFI hybrid ISO additionally requires grub-pc-bin, grub-efi-amd64-bin, grub-common, mtools, and xorriso. Builds are performed via make os FAST_Q8=1 and make os-check, demonstrating three execution methods: direct boot under QEMU KVM, creation of a hybrid ISO, and deployment to a Proxmox VE VM with 0 GB disk.

A verification script scripts/verify_os.py is provided, reporting 100% agreement with Phase 1 in terms of prompt tokens, generated tokens, and raw UTF-8 bytes across five parity prompts: English technical prompt, English concise prompt, Russian UTF-8, arithmetic word problem, and --think mode.

How to View This

This document publishes only the contents of the repository by Alexey Fateev and measurements conducted by himself. Figures such as a 24,252-byte kernel size, 74–94 ms cold boot time, 134.9 tok/s decode speed on KVM with 16 vCPUs, and 55.4 tok/s on Proxmox VE VM are presented solely as his measurements and claims; no third-party replication or independent measurement results are documented here.

Conditions for comparative values must be verified. The KVM SMP scaling table reflects values under conditions of FAST_Q8=1, .asmbin v2 FP16 scale, AMD EPYC 7642, 34-token prompt, 64-token generation, and greedy decoding. The comparison table with llama.cpp in the repository's overall README presents data under conditions of the same machine (AMD EPYC 7642, CPU-only -ngl 0), same model (Qwen3-0.6B Q8_0, comparing 613.66 MiB .asmbin v2 FP16 scale against 604.15 MiB GGUF Q8_0), 34-token prompt, 64-token generation, and average over three runs, showing FAST_Q8=1 achieving 1.24x (+24.5%) faster on 1 thread and 1.36x (+35.6%) faster on 4 threads. However, the same README notes that while llama.cpp uses batched GEMM for prompt prefill, llm.asm operates via per-token GEMV; thus, this comparison pertains specifically to autoregressive decoding tg64. Since both peak and average values are listed in some places, one must distinguish which value is being referenced when interpreting the numbers.

Although the verification script scripts/verify_os.py is published within the repository, this document does not contain results of third-party executions of this script nor any performance certification by external organizations.

Source: llm.asm Repository (GitHub), README for 02-baremetal-os (GitHub), Phase 1 Inference Engine 01-qwen3-inference (GitHub), Post by Alexey Fateev on X

This article was translated from the Japanese original. 日本語で読む

← Latest articles