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
aien-train / docs / omegese45 / PIPELINE.md
| 1 | # omegese45 pipeline: data, core model, training |
| 2 | |
| 3 | Pipeline lane of [aien-train#45](https://github.com/aien-dev/aien-train/issues/45). This lane owns: |
| 4 | |
| 5 | - `native/omegese45/data/gen.om` (episode generator); |
| 6 | - `native/omegese45/core/{model,ckpt,run,cli}.om` (core model, checkpoint, training and decode CLI); |
| 7 | - `tests/omegese45/core/` (build, suite, oracle); |
| 8 | - the receipts under [`evidence/OMEGESE45/pipeline/`](../../evidence/OMEGESE45/pipeline/). |
| 9 | |
| 10 | The vocabulary (R45, 41 ids), grammar, reference policy and exit codes belong to the contract lane |
| 11 | and are used unchanged (`native/omegese45/{vocab,msg}.om`, `docs/omegese45/vocab.tsv`). The command |
| 12 | line is documented in [CORE-CLI.md](CORE-CLI.md). |
| 13 | |
| 14 | Status words: IMPLEMENTED (code exists), EXERCISED (run, with a receipt), NOT_RUN. Every |
| 15 | measurement below was taken on the **GB10 Spark Grace CPU, cores 10-14 (Cortex-A725), nice 19, |
| 16 | ionice idle**. The programs are single-threaded. No GPU was used. |
| 17 | |
| 18 | ## 1. Status |
| 19 | |
| 20 | | Item | Status | Receipt | |
| 21 | |---|---|---| |
| 22 | | Generator `oe45gen`, deterministic, contract-valid, follows the reference policy | EXERCISED | `evidence/OMEGESE45/pipeline/data/`, `suite/` | |
| 23 | | Dense core model, forward and backward in `.om` | EXERCISED (gradient check 639/639 entries) | `suite/grad.stdout` | |
| 24 | | Two-phase training from random weights, 400,000 steps | EXERCISED, 23:52 wall | `train/r1/` | |
| 25 | | Reproducibility (second run byte-identical) | EXERCISED | `train/repro-cmp.txt` | |
| 26 | | Checkpoint `OE45CK01`: resume after kill -9, fallback, 51/52 | EXERCISED | `suite/` | |
| 27 | | Decode U and G, `batch` over the full dev set | EXERCISED | `batch/` | |
| 28 | | Mutants (gradient sign flip, target shifted by one) | EXERCISED, both KILLED | `suite/run-core.log` | |
| 29 | | Transformer core | NOT_RUN: softmax needs `exp`, and omc bf54b19f has only the float intrinsics fsqrt, fabs, fmin and fmax (interface §0). This is an extension proposal. | none | |
| 30 | | GPU training or inference | NOT_RUN: no GPU window was requested; this lane is CPU-only by assignment. | none | |
| 31 | | Native tape reuse (`native/autodiff664/tape.om`) | NOT_RUN (does not fit, see §5) | none | |
| 32 | |
| 33 | No reinforcement learning of any kind is used. Phase 1 is self-supervised next-token prediction and |
| 34 | phase 2 is supervised next-token prediction masked to A and P positions. Both use the reference-policy |
| 35 | episodes as targets, with no reward signal, no sampling-based objective and no policy gradient. |
| 36 | |
| 37 | ## 2. Data |
| 38 | |
| 39 | | Split | Command | Episodes | `.ids` sha256 | `.oe45` sha256 | |
| 40 | |---|---|---|---|---| |
| 41 | | train | `oe45gen 4501 20000 train.oe45 train.ids` | 20000 | `76120f4d436edabb9745e568706d613a542e25b59d61965a42bf9488a92f4228` (1,516,027 B) | `609cb1aac900c001a5474c7ff352c1f58d70d384a9ee6af3072ff4baf7af2940` (4,476,414 B) | |
| 42 | | dev | `oe45gen 4502 1000 dev.oe45 dev.ids` | 1000 | `041741b42bd5d02193afd193c0790b979e911603374920d1b2c124ff36c281cf` (76,482 B) | `8396a07bc33e32228625a504d8b8d73503c4d7ceee23b9235fdd1a6da2122d54` (225,668 B) | |
| 43 | |
| 44 | The files are regenerated, not committed. Regenerating them with the head-built binary gives |
| 45 | byte-identical files (`cmp`, receipt `data/`). The stdout counters are in |
| 46 | `data/gen-4501-20000.stdout` and `data/gen-4502-1000.stdout`. |
| 47 | |
| 48 | Lineage (interface §7) is (generator unit sha256, lineage seed). The generator unit is |
| 49 | `native/omegese45/data/gen.om`. The training lineage used sha256 |
| 50 | `2d44ac9c560062e6cd9557393ebe269ab325fdeca03749956f2cbf3637878e58`. |
| 51 | The final source sha256 is `2c61fadcb93d736cfeec894462c84d1053510c4ddf88cb945fb0d3dbf50aebcb`; |
| 52 | the only change is correcting its documentation citation and labeling the outcomes as synthetic. |
| 53 | The lineage seeds are 4501 (train) and 4502 (dev). Each episode is generated by the reference |
| 54 | policy of interface §3 from one goal: |
| 55 | |
| 56 | - The goal kind is `mm` or `pair`, each with probability 1/2. |
| 57 | - Each of the three dimensions is drawn independently: |
| 58 | - 8%: an edge value 0x000, 0x001, 0x100 or 0x101, 2% each; |
| 59 | - 4%: uniform in 0x101..0xfff; |
| 60 | - 88%: uniform in 0x001..0x100. |
| 61 | The admitted range is 1..256, so a dimension is out of range with probability 2% + 2% + 4% = 8%. |
| 62 | - Seeds are uniform in 0..0xffff. |
| 63 | - Each job attempt has a synthetic outcome drawn for training coverage: |
| 64 | - 55%: `res ok`; |
| 65 | - 15%: `res fail transport`; |
| 66 | - 2% each: the 15 other class × code pairs, namely refused × {replay, budget, worker, transport, |
| 67 | receipt, recomp, verdict, io} and fail × {replay, budget, worker, receipt, recomp, verdict, io}. |
| 68 | - The first `fail transport` of a job is retried once. |
| 69 | |
| 70 | These are **grammar-coverage probabilities**, not a measured or predicted runtime distribution. |
| 71 | In particular, `res refused {transport receipt recomp verdict io}` and `res fail {replay budget worker}` |
| 72 | are legal R messages for grammar coverage but unreachable through the Aienet-0 exit map (interface §5). |
| 73 | At run time only that exit map may produce R; the model never produces `res` (interface §0). |
| 74 | |
| 75 | Generator stdout begins `oe45gen v1 SEED COUNT`, then 26 coverage counters in this order |
| 76 | (`gen.om`, coverage-line declaration): `mm pair oob retry stop okep e000 e001 e100 e101`, |
| 77 | then `refused replay budget worker transport receipt recomp verdict io`, |
| 78 | then `fail replay budget worker transport receipt recomp verdict io`. |
| 79 | |
| 80 | The generator implements the v1.3 episode pin: an out-of-bound G yields only `act refuse bound end` |
| 81 | then `rep refused bound end`. In-bound goals use only A-job/R pairs then P. The core prefix parser |
| 82 | accepts G, G (A-job R)*, or G A-refuse as decode points; it refuses any P inside a prefix, a refuse |
| 83 | after an A or R, and any message after a refuse. Decoding deliberately does not encode this policy |
| 84 | in the message DFA (interface §3); hive must still reject an inappropriate predicted message kind. |
| 85 | |
| 86 | ### Outcome distribution checked with Wolfram |
| 87 | |
| 88 | Expected counts follow from the generator: |
| 89 | |
| 90 | - P(admit) = 0.92³. |
| 91 | - P(job ok) = 0.55 + 0.15 · 0.55 = 0.6325, since one retry is allowed after a transport failure. |
| 92 | - `mm` has one job and `pair` has two. |
| 93 | |
| 94 | WolframLanguageEvaluator query and raw result are in |
| 95 | [`wolfram-distribution.txt`](../../evidence/OMEGESE45/pipeline/wolfram-distribution.txt). Its expressions |
| 96 | are `oob = n (1-adm); okep = (n/2) adm (pj + pj^2); retry = (n/2) adm (15/100 + 15/100 (1+pj));` |
| 97 | `attempts = (n/2) adm (115/100 + 115/100 (1+pj)); stop = n adm-okep`. |
| 98 | At n=20000 the returned expected counts are: oob 4426.24, okep 8040.39, retry 3074.84, |
| 99 | stop 7533.37, attempts 23573.8, fail transport 3536.07 and each other pair 471.476. |
| 100 | |
| 101 | | Train counter (seed 4501, N 20000) | Observed | Expected | (obs − exp)/√exp | |
| 102 | |---|---|---|---| |
| 103 | | out-of-range goals | 4461 | 4426.24 | 0.522 | |
| 104 | | episodes ending `rep ok` | 8059 | 8040.39 | 0.208 | |
| 105 | | transport retries | 3042 | 3074.84 | −0.592 | |
| 106 | | episodes stopped by an outcome | 7480 | 7533.37 | −0.615 | |
| 107 | | `fail transport` outcomes | 3495 | 3536.07 | −0.691 | |
| 108 | |
| 109 | The 15 other outcome pairs total 7027 observations. Query: |
| 110 | |
| 111 | ``` |
| 112 | others = {481,456,538,456,459,482,473,472,448,474,430,474,459,493,432}; e = 471.4761168; |
| 113 | x2 = Total[(others - e)^2/e]; {Total[others], N[x2, 5], N[1 - CDF[ChiSquareDistribution[15], x2], 4]} |
| 114 | -> {7027, 20.6279, 0.1491} |
| 115 | ``` |
| 116 | |
| 117 | The uniformity test on the same counts, with 14 degrees of freedom around their own mean, gives p = 0.1160. |
| 118 | |
| 119 | Dev (seed 4502, N 1000), with the same expressions and n = 1000. The observed counts are |
| 120 | {oob 210, okep 401, retry 158, stop 389}, the expected counts {221.312, 402.020, 153.742, 376.668}, |
| 121 | and the z-scores {−0.760, −0.051, 0.343, 0.635}. |
| 122 | |
| 123 | All |z| are below 1 and the χ² p-value is 0.149, so the counters agree with the declared |
| 124 | distribution. The reference policy itself is checked episode by episode by the independent |
| 125 | oracle (`oracle.py policy` prints `POLICY n 0`) and by the in-`.om` contract validator (`vgen`). |
| 126 | |
| 127 | ## 3. Model |
| 128 | |
| 129 | The model is a dense next-token model over the R45 ids. Each position t predicts id[t] from a causal |
| 130 | input built only from ids at positions < t: |
| 131 | |
| 132 | - head slot p (0 ≤ p < 30, p < t): the one-hot of id[p], at feature p·41 + id; |
| 133 | - tail slot k (0 ≤ k < 64, k < t): the one-hot of id[t−1−k], at feature (30 + k)·41 + id. |
| 134 | |
| 135 | There are (30 + 64) · 41 = 3854 inputs. The longest goal is 30 ids and the longest message 31, so the |
| 136 | head slots cover the whole goal and the 64 tail slots cover the last two messages. The network is one |
| 137 | hidden layer of 256 ReLU units followed by 41 linear outputs, with 3854·256 + 256 + 256·41 + 41 = 997,417 |
| 138 | parameters (Wolfram: `3854*256 + 256 + 256*41 + 41 -> 997417`). |
| 139 | |
| 140 | - **Initialization (algorithm 1).** splitmix64 seeded with 45 generates W1 and then W2 in payload |
| 141 | order. Each value is u = ((r >> 40) − 2²³) · 2⁻²³, scaled by 1/8 for W1 and 1/16 for W2. The biases |
| 142 | are 0. Every value is a dyadic rational and exact in binary32. |
| 143 | - **Loss.** Squared error between the 41 outputs and the one-hot target id[t]. |
| 144 | - **Update rule.** Plain SGD, one update per trained position, with learning rate 2⁻⁷ = 0.0078125 |
| 145 | (`lrbits 1006632960`). |
| 146 | - **Phases.** |
| 147 | - Phase 1 is self-supervised. It trains every position t ≥ 1 of every episode for P1 = 20,000 steps, |
| 148 | one episode per step, which is one epoch (1,496,027 positions). |
| 149 | - Phase 2 is supervised. It trains only the positions of messages whose frame id is `act` or `rep` |
| 150 | (the A/P mask), up to TOTAL = 400,000 steps. |
| 151 | - **Epoch order.** A Fisher-Yates permutation per epoch, drawn from splitmix64 seeded with |
| 152 | order + 1000003 · epoch (order = 7). It is rebuilt from the step count alone, which is what makes |
| 153 | resume exact. |
| 154 | - **Decoding.** Greedy argmax. |
| 155 | - U (unguided) takes the argmax over all ids and validates the message afterwards. |
| 156 | - G (guided) restricts the argmax to the ids the grammar allows (`ocmask`). |
| 157 | |
| 158 | The decode budget is 31 ids (interface §6). |
| 159 | |
| 160 | The step-0 checkpoint is fully determined by (seed 45, algorithm 1). Its payload sha256 is |
| 161 | `6e2e8efebdad7a09535ef0ef7eb90e8cd72a066b693a89e5ebb4da5c32841c1b`, the same in the suite fixture and in |
| 162 | the full run. |
| 163 | |
| 164 | ### Tests (`tests/omegese45/core/run-core.sh`) |
| 165 | |
| 166 | | Check | What fails it | |
| 167 | |---|---| |
| 168 | | gradient check | At three positions of episode 0, central differences (ε = 2⁻⁶) must agree with the backward pass within 0.001 + 0.01·\|g\| at every sampled parameter entry (639 in total; rc 86 otherwise). | |
| 169 | | loss decrease | The summed loss over the first 50 training episodes must fall after one SGD pass over them (rc 87 otherwise). | |
| 170 | | target and mask | The `(episode, t, target, mask)` dump must match `oracle.py mask` byte for byte. | |
| 171 | | causal no-leak | Changing every id at positions ≥ t must not change the output at t, and changing id t must change the output at t + 1 (control). | |
| 172 | | kill -9 and resume | `timeout -s KILL 2` in mid-run, then resuming, must give `ck.a` and `ck.b` byte-identical to an uninterrupted run. | |
| 173 | | data binding | Training with a different `.ids` file must exit 54. | |
| 174 | | round trip | Load then save must reproduce the payload bytes exactly. | |
| 175 | | corrupt slots | A corrupt, header-flipped or truncated newest slot must fall back to the older slot. Both slots corrupt or an empty directory must exit 51; a wrong vocab pin must exit 52. | |
| 176 | | decode | G on step-0 and trained checkpoints never emits an invalid message. U is invalid (50) or over budget (53) when it should be. A bad prefix or header must exit 40. The refuse prefix must be accepted. | |
| 177 | | mutant 0: opgy sign flip in `oploss` | Must be KILLED by the gradient check (rc 86, `GC 639 362`). | |
| 178 | | mutant 1: `optgt` reads t + 1 | Must be KILLED by the target/mask oracle comparison. | |
| 179 | |
| 180 | The suite ran to `OE45_CORE_PASS` in 14.89 s wall (`suite/run-core.log`). |
| 181 | |
| 182 | ## 4. Training run (issue #45 checkpoint) |
| 183 | |
| 184 | ```sh |
| 185 | P="taskset -c 10-14 nice -n 19 ionice -c3" |
| 186 | $P oe45core init ck train.ids 45 20000 400000 7 7 |
| 187 | /usr/bin/time -v $P oe45core train ck train.ids 400000 20000 |
| 188 | oe45core evaldev ck dev.ids |
| 189 | ``` |
| 190 | |
| 191 | The full script is `evidence/OMEGESE45/pipeline/train/final.sh`. The two runs r1 and r2 ran in parallel. |
| 192 | |
| 193 | | Measure | Value | Source | |
| 194 | |---|---|---| |
| 195 | | wall time | 23:52.05 (r1), 23:51.72 (r2) | `train/r*/time.txt` | |
| 196 | | user / system CPU | 1429.84 s / 0.91 s, 99% of one core | `train/r1/time.txt` | |
| 197 | | per step (one episode) | 3.5746 ms (Wolfram `1000*1429.84/400000`) | | |
| 198 | | max RSS | 9600 KB | `train/r1/time.txt` | |
| 199 | | checkpoint | 3,989,908 B per slot (Wolfram `4*997417 + 240`) | | |
| 200 | | step-0 `ck.a` sha256 | `02d85006cd96c9c450c66147538a286b07954964fa14552fb40501fcf77225f2` | `train/r1/sha.txt` | |
| 201 | | trained `ck.a` (gen 21, step 400000) sha256 | `2ebb99de9a0aa04dfba95e0f008e392b99c3f4c4c3836086e24cf7b3a8204058` | `train/r1/sha.txt` | |
| 202 | | trained `ck.b` (gen 20, step 380000) sha256 | `71118b656eb3aa8ac5a5d75e5d5a35710d49a44e78bfcbba88cfcec81a25892e` | `train/r1/sha.txt` | |
| 203 | | reproducibility | r2 `step0.ck`, `ck.a`, `ck.b` and `train.out` are byte-identical to r1 | `train/repro-cmp.txt` | |
| 204 | |
| 205 | Mean loss per trained position is the summed pre-update loss from the `T` lines divided by the |
| 206 | positions; the binary32 bits were decoded with Wolfram (`ImportByteArray[…, "Real32"]`): |
| 207 | |
| 208 | - 0.287741 in phase 1, up to step 20000; |
| 209 | - 0.0712697 for steps 20000..40000; |
| 210 | - 0.0137037 for steps 380000..400000. |
| 211 | |
| 212 | Dev results, from 2410 A/P messages in 1000 episodes (`D step episodes positions correct messages exactU exactG`): |
| 213 | |
| 214 | | Checkpoint | Teacher-forced correct positions | Exact messages, U | Exact messages, G | |
| 215 | |---|---|---|---| |
| 216 | | step 0 | 1564 / 44233 (3.536%) | 0 / 2410 | 159 / 2410 (6.598%) | |
| 217 | | step 400000 | 43793 / 44233 (99.005%) | 2116 / 2410 (87.80%) | 2116 / 2410 (87.80%) | |
| 218 | |
| 219 | The percentages are from Wolfram (`N[43793/44233]`, `N[2116/2410]` and so on). These are pipeline |
| 220 | self-checks on the dev split. The sealed evaluation and the reported metrics belong to the eval lane. |
| 221 | |
| 222 | ### Tuning |
| 223 | |
| 224 | Each tuning run used the same data. Dev exact-G is shown at 10k / 20k / 30k / 40k steps |
| 225 | (`evidence/OMEGESE45/pipeline/train/tune-*/dev.out`). |
| 226 | |
| 227 | | lr | P1 | Exact G at 10k / 20k / 30k / 40k | |
| 228 | |---|---|---| |
| 229 | | 2⁻¹⁰ | 20000 | 258 / 496 / 765 / 1107 | |
| 230 | | 2⁻⁸ | 20000 | 795 / 1378 / 1565 / 1614 | |
| 231 | | 2⁻⁸ | 5000 | 824 / 1463 / 1596 / 1590 | |
| 232 | | 2⁻⁷ | 20000 | 991 / 1566 / 1659 / 1797 | |
| 233 | | 2⁻⁶ | 20000 | 830 / 1116 / 1615 / 1712 | |
| 234 | |
| 235 | 2⁻⁷ with one full self-supervised epoch was chosen. The 400,000-step total fits the 45-minute limit. |
| 236 | |
| 237 | ### Batch decode over the full dev set |
| 238 | |
| 239 | `oracle.py prefixes dev.oe45 1000` writes 2410 prefixes. Each one ends just before an A or P |
| 240 | message: after a G, after an R, or after `act refuse` (whose P follows directly). `oe45core batch` |
| 241 | decodes them, and `oe45test vok` counts the results (`evidence/OMEGESE45/pipeline/batch/summary.txt`). |
| 242 | |
| 243 | | Checkpoint | Mode | Wall | Valid ok | err 50 | err 53 | Exact vs reference | |
| 244 | |---|---|---|---|---|---|---| |
| 245 | | step 0 | U | 3.64 s | 0 | 94 | 2316 | 0 | |
| 246 | | step 0 | G | 1.12 s | 2410 | 0 | 0 | 159 | |
| 247 | | step 400000 | U | 1.69 s | 2410 | 0 | 0 | 2116 | |
| 248 | | step 400000 | G | 1.70 s | 2410 | 0 | 0 | 2116 | |
| 249 | |
| 250 | Batch exact counts equal the `evaldev` counts. The trained model's G errors by expected message type |
| 251 | (`batch/errors-by-type-ck-G.txt`) are: |
| 252 | |
| 253 | | Expected message | Errors | |
| 254 | |---|---| |
| 255 | | `act job` | 148 / 1200 | |
| 256 | | `act refuse` | 7 / 210 | |
| 257 | | `rep ok` | 139 / 401 | |
| 258 | | `rep refused` | 0 / 402 | |
| 259 | | `rep fail` | 0 / 197 | |
| 260 | |
| 261 | The errors are concentrated in copying the hexadecimal operands. Guided decoding guarantees validity, |
| 262 | not binding: the contract lane's binding check (exit 41/42) stays the gate before dispatch. |
| 263 | |
| 264 | ## 5. Design notes |
| 265 | |
| 266 | - **Why not the native tape.** `native/autodiff664/tape.om` at omega-mv `965fb762` (sha256 |
| 267 | `1b4ed431…a708bde`) has these limits: "rank 2 only, at most 32 nodes, 64 elements per node" (line 3), |
| 268 | and value and gradient arenas of 2048 binary32 each (`global TV f32 2048`, `TG f32 2048`). The first |
| 269 | weight matrix alone has 3854 × 256 = 986,624 elements. Forward and backward are therefore written out |
| 270 | in `model.om` and checked against central differences instead. The squared-error loss is the one |
| 271 | interface §6 names as tape-compatible. |
| 272 | - **Why PACK5 is not reused.** `native/ecosystem5/pack.om` (`docs/ecosystem5/CONTRACT.md`) is |
| 273 | composed with Omega L775/L776 admission units and pinned to a different compiler (sha256 |
| 274 | `191b776e…98e9`). Its inputs are admitted public examples, not generated episodes. The idea taken |
| 275 | from it is the supervised-target mask: phase 2 masks the loss to A/P messages (`opmask`). |
| 276 | - **No transformer.** This is a dense model, as interface §6 prescribes for the first step. The |
| 277 | transformer is NOT_RUN, as stated in §1. |
| 278 | - **Branch base.** `feat/45-pipeline` starts at main `5aaeb65` plus contract `80cc357`. It includes |
| 279 | only the pipeline commits and the refuse-prefix fix from `00d66c37`. The unused PR #42 merge was |
| 280 | removed by reconstructing this new branch; the old `feat/45-native-pipeline` is not rewritten. |
| 281 | PR #42's build/suite convention was consulted, but its code is not a dependency. |
| 282 | - **Dependencies.** `native/omegese45/core/dependencies.json` records: |
| 283 | - the compiler pin; |
| 284 | - the SHA-256 unit (omega-mv `bf54b19f`, `om/sha256/sha256-om2.om`, sha256 `dbf002dd…94bb`), used for |
| 285 | the vocab pin, the data binding and the payload digests; |
| 286 | - the oracle; |
| 287 | - each host tool with its version and role. |
| 288 | |
| 289 | The `sed` rewrite of `export fn` to `fn` is the one host step in the build path. Its replacement |
| 290 | proposal is an omc unit-link mode that accepts exported library units. |
| 291 | |
| 292 | ## 6. Checkpoint locations for the demo and eval lanes |
| 293 | |
| 294 | The checkpoints are too large to commit (3.99 MB per slot) and are regenerated by the commands in §4. |
| 295 | |
| 296 | - Step 0: `/tmp/op45w/final/ck0/ck.a`, sha256 `02d85006…77225f2`. |
| 297 | - Trained: `/tmp/op45w/final/ck/` (`ck.a` `2ebb99de…8204058` is the newest; `ck.b` is `71118b65…25892e`). |