Skip to content
المشاريع

حول

استدلال Qwen3-0.6B ‏(12 كيلوبايت)، ونظام تشغيل قابل للإقلاع على العتاد مباشرةً ‏(22 كيلوبايت)، ومدرّب Mini-GPT مبني من الصفر مع واجهة TUI مباشرة باستخدام برايل ‏(32 كيلوبايت)، وكل ذلك بتجميع x86-64 NASM نقي بنسبة 100%. بلا C، وبلا libc، وبلا أي تبعيات.

الذكاء الاصطناعي وتعلّم الآلة

كيف تُقاس هذه الأرقام

5,518 نجمة840 التفرعات +598 خلال 24 ساعة

النمو المقاس للنجوم

خلال 24 ساعة
+٥٩٨
خلال 7 أيام
جارٍ جمع السجل
خلال 15 يومًا
جارٍ جمع السجل
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

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
00 00-engine/ · Zero-Linux Bare-Metal GPU Engine & UEFI OS (Qwen3.6-35B-A3B / Qwen3.5-35B-A3B) 528 KB (BOOTX64.EFI) Pure x86-64 NASM + SM86 SASS 204–234 tok/s bare-metal RTX 3090 (64K ctx), +44..46% vs llama.cpp CUDA, live nvtop HUD + Ring-0 e1000 OpenAI API & Web Chat
01 01-qwen3-inference/ · Qwen3-0.6B static ELF 33.2 KB (33,248 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 39.2 KB (39,188 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, 21.2 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).

Prompt prefill runs in batches of 32 tokens (each weight row streamed once per batch, logits bit-identical to token-by-token prefill): 667-token prompt on a Ryzen 9 7900, 60.8 -> 163.7 tok/s at 2 threads (2.7x) and 52.2 -> 372.0 tok/s at 8 threads (7.1x) vs --no-batch; decode, measured above, is unchanged.


Proof

Bare-Metal Qwen3-0.6B OS VGA Console
Phase 2: QEMU KVM · AMD EPYC 7642 (16 vCPUs)
Proxmox VE VM 0 GB Disk Intel Xeon VGA Console
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)
  • 00 · Bare-Metal GPU Engine & UEFI OS (528 KB, Pure NASM + SM86 SASS): make -C 00-engine engine (zero-libc Linux binaries) or make -C 00-engine/baremetal qwen35-efi (Zero-Linux UEFI ISO for RTX 3090, Qwen3.6-35B-A3B / Qwen3.5-35B-A3B + e1000 OpenAI API & Web Chat) → 00-engine/README.md
  • 01 · Qwen3 Inference (33.2 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 (39.2 KB): make os-run MODEL=models/qwen3-0.6b-q8_0.asmbin SMP=16 (or make os-iso for BIOS+UEFI ISO; Qwen3.5-2B runs on a separate kernel, make os-qwen35) → 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 the grub-pc-bin, grub-efi-amd64-bin, mtools, xorriso packages from the 02 README). It produces a hybrid BIOS+UEFI ISO at build/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.
  • 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 -1 Kernel 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.12 eBPF 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 os builds the bare-metal OS for any x86-64 CPU, SSE2 only, checked by scripts/check_isa.py --profile sse2), nasm, and GNU binutils (ld, objcopy). Phase 2 ISOs use grub-mkrescue (grub-pc-bin, grub-efi-amd64-bin, mtools, xorriso) and qemu-system-x86_64 (KVM). Phase 4 requires AMD SVM + NPT (nested=1) and kernel headers; Phase 5 targets Linux 6.12 (CONFIG_BPF_LSM=y). Python (numpy, optional torch/transformers) is only used for offline weight export and reference harnesses.
  • Repository Map: 00-engine/ (Zero-Linux Bare-Metal GPU Engine, SM86 SASS kernels, UEFI OS, e1000 TCP/HTTP/SSE stack, HAL & porting guide), 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=1 matches PyTorch FP32 Qwen3-0.6B (cosine = 0.9996517, 64/64 exact greedy tokens; FAST_Q8=0 hits 1.000000000 vs Python Q8_0), deterministic across 1T..40T.
    • Phase 2: 100% token-exact & byte-identical to Phase 1 across 1..32 KVM vCPUs (134.9 tok/s at 16 vCPUs) and real Proxmox VE (55.4 tok/s, 0 GB disk).
    • Phase 3: 1.0000000000 min cosine (3.35e-8 worst max diff) across all 21 gradient tensors vs PyTorch CPU; 10-step AdamW max_loss_diff = 4.77e-7; val_loss 4.19 -> 1.51 in 4 min.
    • Phase 4: MiniCPM5-2B GRPO achieves 97.54% pass@1 (119/122 unseen scenarios vs 16.39% base, 0% dangerous continues) and live Ring -1 #PF/#DE/#UD patching over 24 LAPIC cores.
    • Phase 5: Passed Linux 6.12.118 eBPF verifier (74 / 5,775 / 6,035 / 21,457 insns / 1M limit, 0 floats, 0 tail calls), 500/500 0-LSB parity, 0 false denies / 1,000 across 3,840 unseen workflows (75% strict-gate recall, 0.947 evasion F1), and live atomic hot-swap.
    • Phase 6: 115,160 B (113 KB) 100% pure handwritten NASM (19,138 lines, 0 C, 0 gcc), beats GCC -O3 by +11.6% prefill (277.6 vs 248.7 tok/s) and +9.6% decode (37.6 vs 34.3 tok/s) with byte-exact parity, 142.8x bare-metal Prefix KV-Cache (13.3s -> 93 ms), 90.0% v2.1 surgical PATCH@1, and live 0-shot Flappy Bird / Tetris / Arkanoid on a diskless 2014 Xeon Proxmox VM.

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.

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


Star History

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…