← Open Source

Beyond Linux, CUDA, and the OS: bare-metal UEFI Ring-0 self-evolving AI OS running Qwen4-35B-A3B on a single RTX 3090 in pure x86-64 NASM & SM86 SASS (150 tok/s, 64K ctx in 22 GB VRAM, Tiny C + hot-reload).

Assembly
Momentum
+306stars in 24 hours+5.2%
6.23k
Stars
919
Forks
+2,922
This week
31
Contributors
Created 2026-11-25 · Updated 2026-12-06 · #49 today
Top developers
alesha-proKevinGriffin-newjpr5
README

llm.asm

Beyond Linux. Beyond CUDA. Beyond the Operating System.

A self-evolving Ring-0 AI operating system and GPU inference engine written in pure x86-64 NASM and hand-assembled NVIDIA Ampere SASS.
Boots straight onto an RTX 3090 from UEFI with zero Linux, zero CUDA, zero NVIDIA driver, and zero libc — running Qwen4-35B-A3B (64K context in 22 GB VRAM) while writing, compiling, and hot-reloading live Ring-0 C apps in a split-pane framebuffer as you interact with them.

Flagship OS · Performance · Architecture · Quick Start · What Else Is in This Repo · Ecosystem · Contributing

Live 1280x800 UEFI GOP framebuffer of llm.asm running Qwen4-35B-A3B at 149.0 tok/s (PEAK 150.6) with live set_theme(preset=cyberpunk) + nvtop GPU HUD, 22398 / 24576 MiB VRAM, x86-64 Ring0 (ZERO OS), and 192.168.1.204:8080 [e1000].


Beyond the OS: Self-Evolving Bare-Metal AI

Modern AI stacks pull in gigabytes of Linux, Python, PyTorch, CUDA runtime, and kernel drivers before generating a single token. llm.asm replaces the entire stack with bare metal: a UEFI Ring-0 executable in x86-64 assembly that brings up the GPU from cold silicon, runs a 35B Mixture-of-Experts model locally, and lets the model modify the live OS and build native apps while you use it.

Zero Stack, Cold Silicon to Tokens

  • No Linux, No CUDA, No nvidia.ko, No libc: Pure UEFI x86-64 Ring-0 bootloader (loader.asm) initializes private page tables, PCIe BAR0, VBIOS FWSEC-FRTS, SEC2, R610 GSP-RM firmware, Ampere GMMU v2, and 0xC7C0 Compute / 0xC7B5 DMA channels.
  • Hand-Assembled SM86 SASS: 26,641 custom 128-bit Ampere SASS instruction slots with 0 scheduler violations across DP4A quantized GEMV, HMMA/IMMA Tensor Core prefill, Gated DeltaNet recurrence, split-K attention, and MoE kernels (qwen35-moe/).
  • 64K Context in 22 GB VRAM: Streams Qwen4-35B-A3B (UD-IQ4_XS + 11 GiB PLE N-gram table via EFI_BLOCK_IO_PROTOCOL, MTP blk.40, 4-stream Hyper-Connections) with a 65,536-token FP16 KV cache inside 22,398 / 24,576 MiB on a single RTX 3090.

Self-Evolving Ring-0 OS & Agent Harness

  • Built-In Tiny C Compiler & RAM-FS: Compiles a Standard-C subset (<os.h> canvas API) in <1 ms directly in Ring-0 RAM into bounds-checked 8-byte bytecode inside a 32 KiB code / 32 KiB data sandbox (500,000-step guard, tiny_c.inc).
  • Atomic In-Place Hot-Reload: The model calls app_write, app_read, app_list, and app_run across 16 RAM-FS slots (app_fs.inc). Compile errors never crash or overwrite a running app, while valid builds hot-reload live into the right pane.
  • Non-Blocking Split-Pane UI (~22 Hz Live Loop): Left pane holds persistent chat; right pane hosts the nvtop GPU HUD (F1), RAM-FS App Launcher (F2), or running C/Web apps (F3, 464x664). wm_bg_pump ticks active apps at ~22 Hz and dispatches keys while Qwen4 generates tokens.
  • Live Themes, Reasoning & Ring-0 :8080 API: set_theme repaints 1280x800 in <2 ms; /effort off|low|high|xhigh switches visible [THINK] reasoning without wiping KV cache; pure-NASM Intel e1000/e1000e TCP/IPv4 serves an OpenAI HTTP/SSE API + editable Web UI on :8080.

Live 3D wireframe + golden inner cube hot-reloaded in Ring-0 at 138.8 tok/s (9.4K ctx)

Live 3-ball neon Arkanoid with dual lasers compiled by Tiny C at 143.2 tok/s (6.5K ctx)

Verified Bare-Metal Performance

All numbers below were measured on a single NVIDIA RTX 3090 (24 GB GDDR6X) with zero Linux kernel, zero nvidia.ko, and zero CUDA runtime underneath (plus Linux static ELF comparison runs where noted):

Flagship: Qwen4-35B-A3B (UD-IQ4_XS + 11 GiB PLE, MTP blk.40, 64K FP16 KV)

Metric Measured Result Notes
VRAM Footprint (64K FP16 KV) 22,398 / 24,576 MiB 22 GB total on 1x RTX 3090 (65,536 context window + weights + buffers)
Short-Context Decode 145–150 tok/s Peak 153.5 tok/s bare-metal decode (MTP K=1)
Long-Context Decode (12.2K ctx) 134.8 tok/s 121.7 tok/s at 11.3K ctx (up from 79.8 tok/s at 10.1K after batched split-K + batch-2 GEMV/HMMA)
Prompt Prefill (pp512) 3,093 tok/s HMMA Tensor Core prefill (Q5_K, Q6_K, BF16, grouped IQ4_XS/Q5_K MoE)
Custom SM86 SASS Audit 26,641 slots · 0 violations Hand-assembled 128-bit Ampere machine code, verified by sass-toolchain

Additional Verified 00-engine GPU Workloads (RTX 3090)

Mode Model Quant Context Prefill Decode vs llama.cpp CUDA
Bare-Metal UEFI Qwen3.5-35B-A3B Q4_K_M (20.5 GiB) 65,536 (FP16 KV) — 194–226 tok/s Zero Linux / zero nvidia.ko
Bare-Metal UEFI Qwen3-0.6B Q8_0 4,096 — 711.3 tok/s Zero Linux / zero nvidia.ko
Linux Static ELF Qwen3.5-35B-A3B Q4_K_M 65,536 (FP16 KV) 5,609.5 tok/s (pp512) 224.55 tok/s (tg64) +46.3% decode / +9.8% prefill
Linux Static ELF Qwen3.5-0.8B Q8_0 8,192+ 28,935.6 tok/s (pp512) 696.83 tok/s (tg64) +66.8% decode

Boot-to-GPU-to-App Architecture

flowchart LR
    UEFI["UEFI Ring-0 Boot<br/>(loader.asm + BlockIO >4 GiB)"] --> GPU["PCIe BAR0 + VBIOS FWSEC<br/>R610 GSP-RM + GMMU v2 (0xC7C0/0xC7B5)"]
    GPU --> SASS["SM86 SASS Engine<br/>(bm_qwen35 + qwen35-moe + PLE + MTP)"]
    SASS --> HAL["hal/llm_ops.inc + chat_families.inc"]
    HAL --> AGENT["Agent Harness<br/>(/effort + Tool Loop + /reset)"]
    AGENT --> TINYC["Tiny C Compiler + 16-Slot RAM-FS<br/>(tiny_c.inc + app_fs.inc)"]
    TINYC --> FB["1280x800 Split-Pane GOP FB<br/>(Chat + nvtop HUD + ~22 Hz App Canvas)"]
    HAL --> NET["Pure-ASM e1000 TCP/IPv4 (:8080)<br/>(OpenAI SSE + /health + /apps/* + Web UI)"]
Loading
Interactive OS Controls, Slash Commands & Model Tools (Verified in 00-engine/baremetal/os/)

Keyboard Controls (Active Even During Token Generation)

Key Action
TAB / Ctrl+W Switch focus between Left Chat pane and Right Pane
F1 Switch Right Pane to live nvtop GPU HUD (temp, P-state, PCIe link, VRAM, tok/s sparkline)
F2 Switch Right Pane to RAM-FS App Launcher (Up/Down or j/k + Enter, or 1–9 to run)
F3 Switch Right Pane to active C / Web app (preloaded with built-in sysmon on boot)
ESC Return focus to Left Chat pane

Slash Commands

  • /effort off|low|high|xhigh · /think — Set native Qwen4 reasoning effort with live violet [THINK] streaming while preserving the live KV cache
  • /reset — Factory reset: clears KV cache, chat log, theme, RAM-FS apps, and Web UI; restores HUD, chat focus, effort=low, and tools=on
  • /clear — Reset KV cache and clear chat log
  • /tools · /apps · /hud · /focus · /stats · /net · /help · /shell · /reboot · /shutdown

Built-In Agent Tools (agent_harness.inc)

  • inspect_os() — Live theme, GPU telemetry, IP address, active pane/app, and installed apps
  • set_theme({...}) — Instant RAM palette update (default, matrix, doom, cyberpunk, amber, solar, or custom colors)
  • app_write(name, code, lang="c"|"web", open=true) · app_read(name) · app_list() · app_run(name) — Atomic Ring-0 C compile & hot-reload (<os.h> canvas 464x664) or HTML/JS served at GET /apps/<name>
  • read_web_ui() · patch_web_ui(...) — Live-edit the :8080 Ring-0 Web Chat UI in RAM (64 KiB buffer)

Quick Start

1. Build the Zero-Linux Bare-Metal AI OS (UEFI ISO for RTX 30xx / Ampere)

# Build host dependencies (no gcc, clang, libc, or CUDA toolkit needed)
sudo apt-get install nasm binutils dosfstools mtools xorriso python3

git clone https://github.com/alesha-pro/llm.asm.git && cd llm.asm

# Qwen4-35B-A3B (primary GGUF + 11 GiB PLE N-gram shard) -> bootable UEFI ISO:
make -C 00-engine/baremetal iso \
  GGUF=/path/to/Qwen4-35B-A3B-UD-IQ4_XS.gguf \
  PLE_GGUF=/path/to/Qwen4-35B-A3B-PLE.gguf \
  TARGET=nvidia-ga10x \
  ISO_OUT=llm-asm-qwen4.iso

# Single-GGUF models (e.g. Qwen3.5-35B-A3B):
make -C 00-engine iso MODEL=/path/to/Qwen3.5-35B-A3B-Q4_K_M.gguf TARGET=nvidia-ga10x OUT=llm-asm-35b.iso

Write the resulting ISO to a USB drive or attach it as a UEFI CD-ROM (q35, OVMF, VFIO GPU passthrough, RAM >= 1.5x total GGUF/PLE size, standard VGA/GOP 1280x800 + optional COM1 serial). Attach an Intel e1000/e1000e NIC (8086:100E, 10D3, 100F, 1004) to expose :8080 (GET /, GET /apps/<name>, GET /health, GET /v1/models, POST /v1/chat/completions) via DHCPv4 with 192.168.1.250/24 fallback.

2. Build Static Linux GPU Binaries (Zero libc, Zero libcuda.so)

cd 00-engine
make                   # Builds asm-llm-gpu, qwen35, multi-arch, asm-llm-server, llm-asm, asm-llm-gpu-os, BOOTX64.EFI
make verify-static     # Verifies 0 dynamic libs, 0 libc, non-executable RW stack
make test-cpu          # Runs HTTP server, CLI, and scheduler CPU test suites

./bin/llm-asm serve /path/to/model.gguf -- --port 8080

3. Build Core Pure-ASM CPU, Bare-Metal CPU OS & Trainer Phases (01–03)

make all               # Builds Phase 1 (asm-llm, test_math), Phase 2 (asm-llm-os.elf), Phase 3 (asm-gpt-train)

What Else Is in This Repo

Beyond the flagship bare-metal GPU OS, llm.asm spans seven zero-bloat low-level AI systems across bare metal, Ring -1 hypervisors, Linux 6.12 eBPF, and pure x86-64 assembly:

Module What It Is Stack & Size Verified Highlights
00-engine/ Bare-Metal GPU OS & Static GPU Engines Pure x86-64 NASM + SM86/SM89 SASS (BOOTX64_QWEN35.EFI / BOOTX64.EFI) Flagship UEFI AI OS (Qwen4-35B-A3B & Qwen3.5-35B-A3B), static Linux /dev/nvidia* engines, llm-asm CLI, epoll HTTP/SSE server, paged/radix scheduler, sass-toolchain, and Ada SM89 unified target
01-qwen3-inference/ Qwen3-0.6B Linux CPU Engine 33.2 KB (33,248 B) pure x86-64 NASM 126.8 tok/s peak on EPYC 7642 (40T), +18%..+36% vs llama.cpp CPU, 64/64 PyTorch greedy parity, supports .asmbin v1/v2 (Q8_0) & v4 (Q4_0/Q4_K), optional AVX1=1 fallback
02-baremetal-os/ Bootable SMP CPU Bare-Metal OS 50 KB (50,668 B) pure x86-64 NASM 74–94 ms cold boot, 134.9 tok/s KVM (16 vCPUs), Proxmox 0 GB disk (55.4 tok/s), built-in usb2ps2.asm xHCI USB driver, SSE2=1 / AVX1=1 / CHAT_SESSIONS=1..4 builds, os-qwen35 for Qwen3.5-2B
03-minigpt-train/ From-Scratch Mini-GPT Trainer + TUI 33.9 KB (33,872 B) pure x86-64 NASM 27,662 tok/s training (24T EPYC 7642), 1.0000000000 gradient cosine across all 21 tensors vs PyTorch CPU, live 80x24 UTF-8 Braille TUI
04-ring1-kernel-surgeon/ Ring -1 AMD SVM Kernel Surgeon 75.4 KB (75,424 B) NASM + freestanding zero-libc C Type-1 hypervisor running MiniCPM5-2B across 24 NPT-isolated LAPIC cores to live-patch Linux Ring-0 #PF/#DE/#UD faults (97.54% pass@1, 0% dangerous)
05-ebpf-jev/ Linux 6.12 eBPF LSM Recurrent Guard 21.3 KB (21,280 B) INT8 RNN in eBPF C 5.65 µs median hook latency, 0 floats, 21,457 verified insns, 500/500 0-LSB parity, h[32] across fork/exec, atomic weight hot-swap
06-zero-app-os/ Zero-App Ephemeral CPU OS 116 KB (119,256 B, 19,363 lines NASM) 0 preinstalled apps, 0 C, 0 GB disk: MiniCPM5-2B generates x86-64 games (uasm.asm) into a Ring-3 W^X/NX sandbox + Ring-0 #PF/#UD self-healing (ISO & weights)
shared/ Shared x86-64 Assembly Core 12,323 lines across 14 NASM files Reusable math.asm, matmul.asm, matmul_sse2.asm, transformer.asm, tokenizer.asm, pretok.asm, threads.asm, usb2ps2.asm, ctxshift.asm, and syscalls.asm
scripts/ & tests/ Tooling, Exporters & QA Harnesses Python + Shell + C++ reference .asmbin exporters, ISO/UEFI image builders, ISA profile checks (check_isa.py), differential parity & benchmark suites
CPU Benchmarks, Bare-Metal CPU OS Screenshots, Braille TUI & Build Quick Reference

Qwen3-0.6B Q8_0 CPU Decode (AMD EPYC 7642, CPU-only, .asmbin v2 613.66 MiB, pp34 / tg64, 3-run avg)

Threads llm.asm (FAST_Q8=0) llama.cpp (Q8_0) llm.asm (FAST_Q8=1) vs llama.cpp Bare-Metal OS KVM
1 7.18 tok/s 16.63 tok/s 20.70 tok/s 1.24x (+24.5%) 23.67 tok/s
4 28.12 tok/s 51.08 tok/s 69.24 tok/s 1.36x (+35.6%) 78.89 tok/s
8 53.09 tok/s 80.79 tok/s 103.64 tok/s 1.28x (+28.3%) 118.08 tok/s
16 77.50 tok/s 103.03 tok/s 121.86 tok/s 1.18x (+18.3%) 134.94 tok/s
40 98.50 tok/s 105.08 tok/s 125.86 tok/s (peak 126.81) 1.20x (+19.8%) —

Phase 2 Bare-Metal CPU OS Captures


Phase 2: QEMU KVM · AMD EPYC 7642 (16 vCPUs)

Phase 2: Proxmox VE · Intel Xeon E5-2670 v3 (0 GB Disk)

Phase 3 Live 80x24 UTF-8 Braille TUI (build/asm-gpt-train, Pure Assembly)

╭──────────────────────────────────────────────────────────────────────────────╮
│ asm-gpt-train │ 100% Pure x86-64 Assembly (Zero libc, AVX2+FMA)              │
│ L=6 D=192 H=6 FF=512 V=65 │ params=2681664 │ B=16 T=128 │ threads=20         │
├──────────────────────────────────────────────────────────────────────────────┤
│ Loss Curve (0..400)    ⣿⣿⣿ train   ◆ val    best_val=1.8399                  │
│ 4.34 ┤◆   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·  │
│      │⡇                                                                      │
│ 3.61 ┤⢱   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·  │
│      │ ⢱                                                                     │
│ 2.87 ┤· ⠣⣀·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·  │
│      │    ⠑⠢⠤⣀◆                                                              │
│ 2.14 ┤·   ·   ·⠉⠉⠑⠒⠒⠢⠤⠤◆⠤⣀⣀⣀⡀⣀⣀◆  ·   · ◆ ·   ·   ·   ·   ·   ·   ·   ·   ·  │
│      │                      ⠈  ⠉⠉⠉⠊⠉⠊⠒⠊⠒⠊⠒⠔⠒⠢⠤⠤⠔⠢◆⠤⠤⠤⢄⣀⣀⢄◆⣀⣀⣀⣀⡀⣀⣀⢀◆⡀ ⡀⢀   ⣀◆ │
│ 1.40 ┤·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ·   ⠈  ⠁⠁⠈⠉⠈⠁⠉⠉⠉·⠈ │
│      └step 0 ───────────────────────── 200 ────────────────────────── 400    │
├──────────────────────────────────────────────────────────────────────────────┤
│ Step 400/400 [████████████████████████████] 100% │ elapsed 35.2s             │
│ loss=1.6604  val=1.8399  best=1.8399  gnorm=0.53  lr=0.000200  25470 tok/s   │
╰──────────────────────────────────────────────────────────────────────────────╯

Quick Per-Phase Commands

  • 01 · Qwen3 CPU Inference: python3 scripts/export_weights.py --model-dir models/qwen3-0.6b-bf16 --out models/qwen3-0.6b-q8_0.asmbin --scale-dtype fp16 && ./build/asm-llm -m models/qwen3-0.6b-q8_0.asmbin --chat -t 16 → 01-qwen3-inference/README.md
  • 02 · Bare-Metal CPU OS: make os-run MODEL=models/qwen3-0.6b-q8_0.asmbin SMP=16 (make os-iso for hybrid BIOS+UEFI USB ISO; make os-qwen35 for Qwen3.5-2B; make BUILD=build-sse2 SSE2=1 os for SSE2 baseline) → 02-baremetal-os/README.md
  • 03 · Mini-GPT Trainer: ./build/asm-gpt-train --data data/tinyshakespeare.txt --steps 400 --seq 128 -t 16 --save checkpoints/shakespeare.ckpt → 03-minigpt-train/README.md
  • 04 · Ring -1 Kernel Surgeon: cd 04-ring1-kernel-surgeon && make hv && python3 verifier/kvm_verifier.py --selftest → 04-ring1-kernel-surgeon/README.md
  • 05 · Linux 6.12 eBPF LSM: cd 05-ebpf-jev && bash testbed/build.sh && testbed/run_vm.sh verify → 05-ebpf-jev/README.md
  • 06 · Zero-App Ephemeral OS: cd 06-zero-app-os && make && make iso → 06-zero-app-os/README.md

Ecosystem

Built on llm.asm:

  • ringzero — Rust no_std Limine OS running the llm.asm engine in ring 0.
  • jpr5/llm.asm — AArch64 Linux port of Phase 01 in pure A64 assembly (AWS Graviton, Apple silicon), byte-identical to the x86 engine in its exact mode, plus an HTTP front end and amd64/arm64 container images.
  • sapotero/llm.asm-macos — native macOS (Apple silicon) port of Phase 01 in AArch64 assembly.
  • sidx04/llm.asm (riscv branch) — RISC-V (RV64GC, LP64D) Linux port of Phase 01 in pure riscv64 assembly, built on the AArch64 port above.
  • pochi111222/llm.asm-extended — UEFI-native bare-metal OS based on llm.asm, with 64-bit memory management above 4 GiB and 1-4 core inference.

Want to port llm.asm to a new GPU (RTX 4090 sm89, RTX 5090 sm120, AMD RDNA3, Intel Arc)? Start with 00-engine/PORTING_GPU.md and 00-engine/PORTING_SM89.md. Building an external port, language binding, or downstream OS? Host it in your own repository and open an issue or PR with a link to list it here.

Contributing

We keep main strictly focused on zero-bloat x86-64 assembly, hand-assembled GPU SASS, bare-metal OSes, hypervisors, and in-kernel ML with hard numerical verification. Read CONTRIBUTING.md before opening a PR.

License: MIT


Star History

Nearby in the ranking

AI Rank for iPhone

Follow AI model rankings

Download on the App Store