interplane.Get Omega
Read in your language

aien-train

AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished.

Brought by drakestapleton

branch main Branches Tags History

aien-train / docs / omegalora / CONTRACT.md

54 lines · 2555 bytes Raw Blame History Rendered
1# omegalora: LoRA fine-tuning core in Omega (contract v1)
2
3`native/omegalora/lora.om` is a first-party Omega unit that fine-tunes a frozen base with LoRA
4(low-rank adapters) and checks its own math. It is the f64 reference that later GPU and
5omegallm adapter kernels are compared against. Host CPU only; it does not qualify any chip.
6
7## What it computes
8
9One transformer MLP block shape, all f64:
10
11- `h0 = rmsnorm(x)`, `p1 = (W1 + s B1 A1) h0`, `a1 = silu(p1)`, `n1 = rmsnorm(a1)`,
12 `z = (W2 + s B2 A2) n1`, loss = mean softmax cross-entropy over 64 samples, 12 classes.
13- Shapes: x 16, hidden 24, rank r = 4, alpha = 8, scale s = alpha / r = 2.
14- `W1` (24x16) and `W2` (12x24) are frozen. Only `A1 B1 A2 B2` (304 values) learn.
15- Init follows LoRA: A random, B zero, so step 0 equals the base model exactly.
16- Optimizer: AdamW, beta1 0.9, beta2 0.999, eps 1e-8, weight decay 0.01, lr 0.02, 400 steps.
17- `exp` and `log` are first-party (range reduction plus series); constants and error bounds
18 are Wolfram receipts in `evidence/OMEGALORA/wolfram.txt`.
19- Task: labels come from a hidden teacher `W + U V` with rank 4 changes on both layers, so a
20 rank 4 adapter can represent it exactly.
21
22## Gates (exit codes, decided inside the .om unit)
23
24| exit | meaning |
25|---|---|
26| 0 | all gates pass |
27| 13 | exp(1) or log(10) off by more than 1e-14 |
28| 10 | analytic gradient vs central difference (h = 1e-5, every 3rd parameter, B nonzero): worst relative error above 1e-6 |
29| 11 | training loss after 400 steps is not at most half the starting loss |
30| 12 | accuracy did not rise by at least 0.2 |
31
32## Negative controls
33
34stdin selects a deliberately broken build. The gates must catch each one.
35
36| stdin | break | must exit |
37|---|---|---|
38| 1 | SiLU derivative sign flipped | 10 |
39| 2 | RMSNorm backward sign flipped | 10 |
40| 3 | AdamW step sign flipped | 11 |
41
42## Build and test
43
44`sh tests/omegalora/run.sh` with `OMC` pointing at the pinned seeded omc (omega-mv `e5b32567`,
45sha256 `2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`). The script refuses
46any other compiler, compiles, runs all four builds and writes `evidence/OMEGALORA/run/`.
47
48## Limits
49
50- Host CPU, f64, one block, synthetic teacher data. This is not a language model fine-tune yet.
51- Omega today allows at most 16 live values per function and 6 parameters; the unit is split
52 into small helpers for that reason.
53- Next step: carry the same adapter math into omegallm (`native/omegallm/model.om`) so its
54 checkpoints can take a LoRA adapter, checked against this unit.