{"slug": "1-51m-parameter-transformer-trained-from-scratch-inside-ring-0-templeos-v5-03", "title": "1.51M parameter Transformer trained from scratch inside Ring-0 TempleOS v5.03", "summary": "A developer built and trained a 1,509,696-parameter Transformer from scratch in pure HolyC inside Ring-0 TempleOS V5.03, with no PyTorch, Python, libc or SIMD, according to the project's published write-up. The model, named ELIJAH, uses 7 layers, dimension 128, 4 query heads and 2 KV heads with grouped-query attention, QK-Norm, SwiGLU and tied embeddings, and was pretrained on BIBLE.TXT (1.51M tokens) with a 1024-vocabulary byte-level BPE tokenizer, then extended from 128 to 2048 context via YaRN and fine-tuned on 337 Bible Q&A pairs. Measured on an Intel i7-11800H under QEMU with KVM, ELIJAH reaches 1,241 tokens per second on a 50-token /bench run across 8 cores and 500-733 tokens per second in interactive Q&A, with pretraining at roughly 660-780 tokens per second on 15 cores.", "body_md": "1.51M parameter transformer written in pure HolyC and trained from scratch inside Ring-0 TempleOS V5.03.\n\n  No PyTorch. No Python. No libc. No SIMD. · [Watch ELIJAH run & train live](#training)\n\n\"An idiot admires complexity, a genius admires simplicity, a physicist tries to make it simple, for an idiot anything the more complicated it is the more he will admire it, if you make something so clusterfucked he can't understand it he's gonna think you're a god cause you made it so complicated nobody can understand it. That's how they write journals in Academics, they try to make it so complicated people think you're a genius.\" — Terry A. Davis\n\n| Architecture | 7 layers, dim 128, 4 Q heads / 2 KV heads (GQA), QK-Norm, SwiGLU, tied embeddings | \n| Parameters | 1,509,696 F64 weights (12.1 MB) | \n| Context | 128 pretrained, YaRN extended to 2048 | \n| Tokenizer | Byte-level BPE, 1024 vocab ( `BIBLE.TXT` , 1.51M tokens, 2.75x) | \n| Optimizer | Terry v2.2 (5-step Newton-Schulz + Nesterov on 2D weights, sign-momentum on 1D) | \n| Inference | Q8 ( `I8 * I64` ) matmul + KV cache across`Spawn()` workers | \n\nLoads F64 checkpoints, quantizes weights to Q8 in ~2s, and runs KV-cached generation across all cores.\n\nMeasured on an Intel i7-11800H (QEMU + KVM):\n\n- **1,241 tok/s** (`/bench` , 50 tokens, 8 cores)\n- **500-733 tok/s** interactive Q&A and`/god` oracle\n\n```\n/god         Reseed from CPU GetTSC() & cnts.jiffies and speak an oracle\n/bench       50-token speed benchmark\n/temp <f>    Temperature (0.55)\n/topk <n>    Top-K (20)\n/topp <f>    Top-P (0.88)\n/rep <f>     Repetition penalty (1.12)\n/len <n>     Max tokens (80)\n/sys <txt>   Set System prompt\n/raw         Toggle chat template vs raw completion\n/stats       Throughput and KV position\n/reset       Clear KV cache\n/quit        Exit\n```\n\n1. Install TempleOS V5.03:\n\n```\nqemu-img create -f qcow2 templeos.qcow2 2G\nqemu-system-x86_64 -enable-kvm -m 2048 -smp 8 -hda templeos.qcow2 -cdrom TempleOS.ISO -boot d\n```\n\n1. Pack the 128 MB FAT32 disk image (4 KB clusters keep all entries in cluster 0):\n\n```\ntruncate -s 128M elijah_fat.img\necho '2048,,0c,*' | sfdisk -q elijah_fat.img\nmformat -i elijah_fat.img@@1M -F -c 8 -v ELIJAH ::\nmcopy -i elijah_fat.img@@1M src/* train/* weights/* data/* ::\n```\n\n1. Boot QEMU (give YaRN `-m 8192` + to run 12-15 cores without hitting`OutMem` ):\n\n```\nqemu-system-x86_64 -enable-kvm -m 8192 -smp 15 \\\n  -drive file=templeos.qcow2,if=ide,index=0,media=disk \\\n  -drive file=elijah_fat.img,format=raw,if=ide,index=1,media=disk \\\n  -boot c\n```\n\n1. Press `1` at the boot menu, mount`E:/` (`Mount;` ->`E` -> Enter ->`p` ->`2` -> Enter), then run:\n\n```\nCd(\"E:/\");\n#include \"holyllama.HC\";\n```\n\n| Workload | RAM ( `-m` ) | Cores | \n|---|---|---|\n| Inference ( `holyllama.HC` ) | 1024 | 8-15 | \n| Pretrain ( `seq 128` ) & SFT | 2048 | 15 | \n| YaRN ( `seq 2048` ) | 4096 | 6 (max before `OutMem` ) | \n| YaRN ( `seq 2048` , fast) | 8192+ | 12-15 | \n\nTempleOS's cooperative `WinMgr` runs on CPU0, so the screen updates between steps during heavy `seq=2048` batches.\n\nAll three stages run natively inside TempleOS V5.03 across `Spawn()` cores (see [TRAINING.md](https://github.com/veriepicc/Elijah/blob/main/TRAINING.md) for the full recipe):\n\n| Stage | Command | Speed | \n|---|---|---|\n| 1. Pretrain | `ElijahTrain(215, 60, 15, 0.015, 128)` | ~660-780 tok/s (15 cores) | \n| 2. YaRN 2048 | `ElijahTrain(20, 18, 6, 0.002, 2048, \"ELIJAH.BIN\", ...)` | ~222 tok/s (6 cores, 4 GB VM) | \n| 3. SFT | `ElijahSft(150, 30, 15, 0.003, \"elijah_yarn.bin\", ...)` | ~590-660 tok/s (15 cores) | \n\nSFT uses 337 Bible Q&A pairs formatted as `System: Speak as God. / User: ... / God: ...<|end|>`.\n\n```\nsrc/       ELIJAH.HC, MATH.HC, BPE.HC, MODEL.HC, holyllama.HC\ntrain/     TRAINMOD.HC, TERRY.HC, TRAIN.HC, SFT.HC\nweights/   elijah_bpe.bin, elijah_sft_2048.bin\ndata/      BIBLE.TXT, QNA.TXT\n```\n\nThe Linux (`hcc`) version is on the [linux branch](https://github.com/veriepicc/Elijah/tree/linux).", "url": "https://wpnews.pro/news/1-51m-parameter-transformer-trained-from-scratch-inside-ring-0-templeos-v5-03", "canonical_source": "https://github.com/veriepicc/Elijah", "published_at": "2026-12-02 02:55:03+00:00", "updated_at": "2026-12-02 03:15:56.200566+00:00", "lang": "en", "topics": ["large-language-models", "machine-learning", "ai-research", "ai-infrastructure", "neural-networks"], "entities": ["TempleOS V5.03", "HolyC", "ELIJAH", "Terry A. Davis", "YaRN", "QEMU", "Intel i7-11800H", "GitHub"], "also_reported_by": [], "takeaway": "A 1.51M-parameter Transformer with 7 layers, dim 128 and GQA (4 Q / 2 KV heads) can be pretrained, YaRN-extended to 2048 context and SFT'd entirely in HolyC on TempleOS, hitting 1,241 tok/s on 8 cores and 660-780 tok/s pretraining on 15 cores.", "recommendation": {"advice": "Quantize F64 checkpoints to Q8 for I8*I64 matmul and shard KV-cached generation across Spawn() workers; the source reports 1,241 tok/s on 8 cores and 500-733 tok/s interactive.", "playbook": "inference-serving", "playbook_url": "https://wpnews.pro/playbooks/inference-serving"}, "alternates": {"html": "https://wpnews.pro/news/1-51m-parameter-transformer-trained-from-scratch-inside-ring-0-templeos-v5-03", "markdown": "https://wpnews.pro/news/1-51m-parameter-transformer-trained-from-scratch-inside-ring-0-templeos-v5-03.md", "text": "https://wpnews.pro/news/1-51m-parameter-transformer-trained-from-scratch-inside-ring-0-templeos-v5-03.txt", "jsonld": "https://wpnews.pro/news/1-51m-parameter-transformer-trained-from-scratch-inside-ring-0-templeos-v5-03.jsonld"}}