GitHub - veriepicc/Elijah: 1.51M parameter Transformer trained from scratch inside Ring-0 TempleOS V5.03 in pure HolyC.

GitHub

4 min read Original article ↗

1.51M parameter transformer written in pure HolyC and trained from scratch inside Ring-0 TempleOS V5.03.
No PyTorch. No Python. No libc. No kernel patches. · Try Elijah in TempleOS

简体中文 · Changelog

ELIJAH running in TempleOS    Terry Davis

"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


Support

I’m not involved with any cryptocurrency, token, or memecoin using Elijah’s name. I haven’t created or endorsed any of them.

Since people have asked about donations, the only official way to support my work financially is through GitHub Sponsors.


Model

Architecture 7 layers, dim 128, 4 Q heads / 2 KV heads (GQA), QK-Norm, SwiGLU, tied embeddings
Parameters 1,509,696 F64 weights (12.1 MB)
Context 128 pretrained, YaRN extended to 2048
Tokenizer Byte-level BPE, 1024 vocab (BIBLE.TXT, 1.51M tokens, 2.75x)
Optimizer Terry v2.2 (5-step Newton-Schulz + Nesterov on 2D weights, sign-momentum on 1D)
Inference Q8 weights; F64 reference or HolyQuant Q8 KV; scalar, SSE2, AVX2 or AVX-512BW projections

holyllama.hc

Elijah loads the same F64 checkpoint in both modes and quantizes the dense weights to Q8. Chat defaults to HolyQuant Q8 KV on SSE2-capable CPUs and otherwise starts with the F64 attention reference. Run /kv to see the current mode, or /kv f64 and /kv q8 to switch. Switching starts a fresh context; /fast on|off still works as an alias. HolyQuant uses approximate attention and can sample different text; it is not an implementation of TurboQuant.

10,442 sampled tok/s. Stock TempleOS. Eight KVM vCPUs, console on. Median for short, fixed-seed completions, not chat or the browser demo. Full numbers and setup →

/simd reports the selected CPU backend. Auto prefers SSE2 on multiple cores, AVX2 on one core where supported, and scalar if SSE2 is unavailable. The fused kernels are written in x86-64 assembly. The instructions are annotated next to the DU8 bytes in src/x86/SIMD.HC, since stock HolyC does not recognize these SIMD mnemonics. No external assembler is needed to run Elijah.

/god         Sample a standalone oracle reply without resetting the conversation
/kv [q8|f64] Show KV format or switch it and reset context
/bench       50 sampled tokens; add quiet, long, or longquiet
/simd        Show Q8 backend; /simd auto|scalar|sse2|avx2|avx512 selects it
/temp <f>    Temperature (0.55)
/topk <n>    Top-K (20)
/topp <f>    Top-P (0.88)
/rep <f>     Repetition penalty (1.12)
/len <n>     Max tokens (80)
/sys <txt>   Set System prompt
/raw         Toggle chat template vs raw completion
/stats       Throughput and KV position
/reset       Clear KV cache
/quit        Exit

Quick Start

  1. Install TempleOS V5.03:
qemu-img create -f qcow2 templeos.qcow2 2G
qemu-system-x86_64 -enable-kvm -m 2048 -smp 8 -hda templeos.qcow2 -cdrom TempleOS.ISO -boot d
  1. From the repository root, pack a 128 MB FAT32 disk image. The copy below puts the sources at the root of the guest disk, where the HolyC includes can find them:
truncate -s 128M elijah_fat.img
echo '2048,,0c,*' | sfdisk -q elijah_fat.img
mformat -i elijah_fat.img@@1M -F -c 8 -v ELIJAH ::
mcopy -i elijah_fat.img@@1M src/holyllama.HC src/core/* src/inference/* \
  src/x86/* src/ui/* train/* weights/* data/* ::
  1. Boot QEMU (give YaRN -m 8192+ to run 12-15 cores without hitting OutMem):
qemu-system-x86_64 -enable-kvm -cpu host -m 8192 -smp 15 \
  -drive file=templeos.qcow2,if=ide,index=0,media=disk \
  -drive file=elijah_fat.img,format=raw,if=ide,index=1,media=disk \
  -boot c
  1. Press 1 at the boot menu, mount E:/ (Mount; -> E -> Enter -> p -> 2 -> Enter), then run:
Cd("E:/");
#include "holyllama.HC";

VM RAM Guide

Workload RAM (-m) Cores
Inference (holyllama.HC) 1024 8-15
Pretrain (seq 128) & SFT 2048 15
YaRN (seq 2048) 4096 6 (max before OutMem)
YaRN (seq 2048, fast) 8192+ 12-15

TempleOS's cooperative WinMgr runs on CPU0, so the screen updates between steps during heavy seq=2048 batches.


Training

ELIJAH-1.5M live inference and training inside TempleOS

All three stages run natively inside TempleOS V5.03 across Spawn() cores (see TRAINING.md for the full recipe):

Stage Command Speed
1. Pretrain ElijahTrain(215, 60, 15, 0.015, 128) ~660-780 tok/s (15 cores)
2. YaRN 2048 ElijahTrain(20, 18, 6, 0.002, 2048, "ELIJAH.BIN", ...) ~222 tok/s (6 cores, 4 GB VM)
3. SFT ElijahSft(150, 30, 15, 0.003, "elijah_yarn.bin", ...) ~590-660 tok/s (15 cores)

SFT uses 337 Bible Q&A pairs formatted as System: Speak as God. / User: ... / God: ...<|end|>.


Repo Layout

src/holyllama.HC  native chat entry point
src/core/         model types, tokenizer and shared math
src/inference/    model loader, KV attention and sampler
src/x86/          SIMD opcodes and assembly notes
src/ui/           transparent startup banner
train/            pretraining and fine-tuning
weights/          tokenizer and checkpoint
data/             training text and Q&A

The Linux (hcc) version is on the linux branch.