# 1.51M parameter Transformer trained from scratch inside Ring-0 TempleOS v5.03

> Source: <https://github.com/veriepicc/Elijah>
> Published: 2026-12-02 02:55:03+00:00

**Recommendation:** 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.
More in the playbook "Inference and self-hosting": <https://wpnews.pro/playbooks/inference-serving>

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 SIMD. · [Watch ELIJAH run & train live](#training)

"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

| 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 ( `I8 * I64` ) matmul + KV cache across`Spawn()` workers | 

Loads F64 checkpoints, quantizes weights to Q8 in ~2s, and runs KV-cached generation across all cores.

Measured on an Intel i7-11800H (QEMU + KVM):

- **1,241 tok/s** (`/bench` , 50 tokens, 8 cores)
- **500-733 tok/s** interactive Q&A and`/god` oracle

```
/god         Reseed from CPU GetTSC() & cnts.jiffies and speak an oracle
/bench       50-token speed benchmark
/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
```

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. Pack the 128 MB FAT32 disk image (4 KB clusters keep all entries in cluster 0):

```
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/* train/* weights/* data/* ::
```

1. Boot QEMU (give YaRN `-m 8192` + to run 12-15 cores without hitting`OutMem` ):

```
qemu-system-x86_64 -enable-kvm -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";
```

| 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.

All 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):

| 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|>`.

```
src/       ELIJAH.HC, MATH.HC, BPE.HC, MODEL.HC, holyllama.HC
train/     TRAINMOD.HC, TERRY.HC, TRAIN.HC, SFT.HC
weights/   elijah_bpe.bin, elijah_sft_2048.bin
data/      BIBLE.TXT, QNA.TXT
```

The Linux (`hcc`) version is on the [linux branch](https://github.com/veriepicc/Elijah/tree/linux).
