README
Open on GitHub ↗llm.asm
AI where it doesn't belong: bare metal, Ring -1 hypervisors, and Linux kernel eBPF.
Zero libc. Zero runtime dependencies. Tens of kilobytes.
Projects · Benchmarks · Proof · Quick Start · Ecosystem · Contributing · MIT License
Projects
| Phase | Target | Size | Stack | Headline Result |
|---|---|---|---|---|
01 |
01-qwen3-inference/ · Qwen3-0.6B static ELF |
15.1 KB (15,064 B) |
Pure x86-64 NASM | 126.8 tok/s (40T), +18%..+36% vs llama.cpp CPU, 64/64 PyTorch parity |
02 |
02-baremetal-os/ · Bootable Bare-Metal OS |
27.2 KB (27,164 B) |
Pure x86-64 NASM | 74–94 ms boot, 134.9 tok/s KVM (16 vCPU), Proxmox 0 GB disk (55.4 tok/s) |
03 |
03-minigpt-train/ · Mini-GPT Trainer + TUI |
33.9 KB (33,872 B) |
Pure x86-64 NASM | 27,662 tok/s, 1.0000000000 grad cosine vs PyTorch, 80x24 Braille UI |
04 |
04-ring1-kernel-surgeon/ · Ring -1 SVM Hypervisor |
75.4 KB (75,424 B) |
NASM + zero-libc C | MiniCPM5-2B live kernel crash patcher, 97.54% pass@1 (119/122), 0% dangerous |
05 |
05-ebpf-jev/ · Linux 6.12 eBPF LSM |
21.3 KB (21,280 B) |
eBPF C + INT8 RNN | 5.65 µs median hook, 0 floats, 500/500 0-LSB parity, atomic hot-swap |
06 |
06-zero-app-os/ · Zero-App Ephemeral OS |
113 KB (115,160 B) |
Pure x86-64 NASM | 0 apps, 0 C, 0 GB disk, MiniCPM5-2B writes x86-64 games live + Ring-0 #PF PATCH in ~0.3s |
Benchmarks
Qwen3-0.6B Q8_0 CPU Decode - AMD EPYC 7642 (47C online, CPU-only -ngl 0, .asmbin v2 613.66 MiB vs GGUF 604.15 MiB, pp34 / tg64, 3-run avg):
| Threads | llm.asm (FAST_Q8=0) |
llama.cpp (Q8_0) |
llm.asm (FAST_Q8=1, 15.1 KB) |
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 |
| 24 | 91.88 tok/s | 104.11 tok/s | 123.72 tok/s | 1.19x (+18.8%) | 132.90 tok/s |
| 32 | 96.63 tok/s | 103.82 tok/s | 122.51 tok/s | 1.18x (+18.0%) | 133.75 tok/s |
| 40 | 98.50 tok/s | 105.08 tok/s | 125.86 tok/s (peak 126.81) | 1.20x (+19.8%) | - |
FAST_Q8=1 uses an INT8xINT8 AVX2+F16C kernel (vpmaddubsw/vpmaddwd, .asmbin v2 FP16 block scales via vcvtph2ps), contiguous head-major KV-cache, and parallel GQA; Bare-Metal OS gains another ~10% from 2 MiB huge-page identity mapping (bit-exact across all thread counts).
Proof
|
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 │
├─ Live Sample (step 400) ─────────────────────────────────────────────────────┤
│ ROMEO: │
│ Nay, to lond, in if as my kears, some with death. │
│ │
│ DUKE VINCENTIO: │
╰──────────────────────────────────────────────────────────────────────────────╯
Quick Start
git clone https://github.com/alesha-pro/llm.asm.git && cd llm.asm make all # Builds Phase 1 (asm-llm, test_math), Phase 2 (asm-llm-os.elf), Phase 3 (asm-gpt-train)
- 01 · Qwen3 Inference (
15.1 KB):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 OS (
27.2 KB):make os-run MODEL=models/qwen3-0.6b-q8_0.asmbin SMP=16(ormake os-isofor BIOS+UEFI ISO) → 02-baremetal-os/README.md- USB boot: there is no prebuilt ISO to download - build it with
make os-iso MODEL=models/qwen3-0.6b-q8_0.asmbin(needs thegrub-pc-bin,grub-efi-amd64-bin,mtools,xorrisopackages from the 02 README). It produces a hybrid BIOS+UEFI ISO atbuild/asm-llm-os.iso(~661 MiB); write that file to a USB stick (e.g.dd, Rufus, or balenaEtcher) and boot the machine from USB. Full steps:02-baremetal-os/README.md, Option B.
- USB boot: there is no prebuilt ISO to download - build it with
- 03 · Mini-GPT Trainer (
33.9 KB):./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
-1Kernel Surgeon (75.4 KB):cd 04-ring1-kernel-surgeon && make hv && python3 verifier/kvm_verifier.py --selftest→ 04-ring1-kernel-surgeon/README.md - 05 · Linux
6.12eBPF LSM (21.3 KB):cd 05-ebpf-jev && bash testbed/build.sh && testbed/run_vm.sh verify→ 05-ebpf-jev/README.md - 06 · Zero-App Ephemeral OS (
113 KB, Pure NASM):cd 06-zero-app-os && make && make iso(weights + ready-to-boot ISO on Hugging Face) → 06-zero-app-os/README.md
System Requirements, Repository Layout & Verification Summary
- Requirements: x86-64 CPU with AVX2 + FMA + F16C (Phases 1–2 also build for AVX + SSE4.1 only with
AVX1=1, Sandy / Ivy Bridge: details;make BUILD=build-sse2 SSE2=1 osbuilds the bare-metal OS for any x86-64 CPU, SSE2 only, checked byscripts/check_isa.py --profile sse2),nasm, and GNUbinutils(ld,objcopy). Phase 2 ISOs usegrub-mkrescue(grub-pc-bin,grub-efi-amd64-bin,mtools,xorriso) andqemu-system-x86_64(KVM). Phase 4 requires AMD SVM + NPT (nested=1) and kernel headers; Phase 5 targets Linux6.12(CONFIG_BPF_LSM=y). Python (numpy, optionaltorch/transformers) is only used for offline weight export and reference harnesses. - Repository Map:
shared/(3,857-line shared NASM core reused across Phases 1–3),01-qwen3-inference/,02-baremetal-os/,03-minigpt-train/,04-ring1-kernel-surgeon/,05-ebpf-jev/,06-zero-app-os/,scripts/,assets/,Makefile. - Verification Highlights:
- Phase 1:
FAST_Q8=1matches PyTorch FP32Qwen3-0.6B(cosine = 0.9996517,64/64exact greedy tokens;FAST_Q8=0hits1.000000000vs Python Q8_0), deterministic across1T..40T. - Phase 2: 100% token-exact & byte-identical to Phase 1 across
1..32KVM vCPUs (134.9 tok/sat 16 vCPUs) and real Proxmox VE (55.4 tok/s,0 GBdisk). - Phase 3:
1.0000000000min cosine (3.35e-8worst max diff) across all 21 gradient tensors vs PyTorch CPU; 10-step AdamWmax_loss_diff = 4.77e-7;val_loss 4.19 -> 1.51in 4 min. - Phase 4: MiniCPM5-2B GRPO achieves
97.54%pass@1 (119/122unseen scenarios vs16.39%base,0%dangerous continues) and live Ring-1#PF/#DE/#UDpatching over 24 LAPIC cores. - Phase 5: Passed Linux
6.12.118eBPF verifier (74/5,775/6,035/21,457insns / 1M limit,0floats,0tail calls),500/5000-LSBparity,0false denies / 1,000 across 3,840 unseen workflows (75%strict-gate recall,0.947evasion F1), and live atomic hot-swap. - Phase 6:
115,160 B(113 KB) 100% pure handwritten NASM (19,138lines,0C,0gcc), beatsGCC -O3by+11.6%prefill (277.6vs248.7 tok/s) and+9.6%decode (37.6vs34.3 tok/s) with byte-exact parity,142.8xbare-metal Prefix KV-Cache (13.3s -> 93 ms),90.0%v2.1surgicalPATCH@1, and live 0-shot Flappy Bird / Tetris / Arkanoid on a diskless 2014 Xeon Proxmox VM.
- Phase 1:
Ecosystem
Built on llm.asm:
ringzero- Rustno_stdLimine OS running thellm.asmengine 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.
Building an external port, language binding, or downstream OS on llm.asm? Host it in your own repository and open an issue or PR with a link so we can list it here.
Contributing
We keep main strictly focused on zero-bloat x86-64 assembly, bare-metal OSes, hypervisors, and in-kernel ML with hard numerical verification. Read CONTRIBUTING.md before opening a PR.
License: MIT