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 / adtrain / CONTRACT.md

163 lines · 8322 bytes Raw Blame History Source

adtrain — native autodiff training example

Status: IMPLEMENTED and EXERCISED on the host (aarch64 Linux, DGX Spark) for gates 1–4 and the host arm of gate 5, plus the exact-rational gradient oracle (Wolfram). The GB10 arm of gate 5 is EXERCISED once on the GB10 (one fixture, 75/75 exact). Nothing here is QUALIFIED, MERGED or DEPLOYED. Tracks aien-train #6 (trainer, optimizer, checkpoint) on top of omega-mv #664 (native tape).

What it is

native/adtrain/mlp.om is handwritten seeded .om with native f32 words. It trains a relu MLP by full-batch gradient descent. Gradients come from the native reverse-mode tape native/autodiff664/tape.om (omega-mv); this repository contains no hand-derived derivative. Build order: omega-mv native/ecosystem663/metadata.om, omega-mv native/autodiff664/tape.om, native/adtrain/mlp.om, then the caller (tests/adtrain/main.om). Pins: dependencies.json.

Gates and how each is proven

OMC=<pinned omc> OMEGA=<omega-mv checkout> OUT=<scratch> sh tests/adtrain/run-adtrain.sh ends ADTRAIN_SUITE_PASS. The suite materialises the dependencies from their pinned Git objects and checks every SHA-256 first.

gatemodecheck
1 forward + lossT201 L <step> <loss bits> rows from the tape forward
2 gradients vs independent referenceGtape gradient against a central difference per parameter, ε = 1/64 (rule below); ≥ 50 checked, none failing
2 (second reference)D + host armC M21 tape on the same inputs, value-exact
3 updates reduce lossTloss[200] < loss[0] and loss[200] < loss[100], in the program (exit 88) and again on the printed bits by the runner
4 checkpoint/resumeS, Rtrain to 120, save, fresh process loads and continues to 200; L 120..200 and all P rows cmp-identical to the uninterrupted T run
5 CPU/GPU agreementDfixture replayed by omega-mv tests/test_omega_ad_fixture.c: host arm (M20 CPU table) PASS; GB10 arm tests/run_ad_chip.sh PASS 75/75 max_ulp=0 on the GB10, sign-flip control FAIL (evidence/ADTRAIN/gb10/)
golden receiptsT, S, GSHA-256 of run/T.stdout, the step-120 checkpoint and run/G.stdout equal docs/adtrain/golden.json (PR #42's evidence/ADTRAIN receipts); fails as golden-T-stdout, golden-ck120 or golden-G-stdout

Gates 1–4 are self-consistency checks: a trainer that is wrong but consistent with itself (a parameter never updated, another learning rate in the update only, a different data hash) passes them. The golden gates bind the run to the recorded trajectory, checkpoint and gradient rows of the pinned build, so such a trainer fails. Any intended change to the trainer, data or compiler pin needs new receipts and a new golden.json in the same change. The negative controls of these gates (one hex digit changed, entry missing or duplicated, another gradient-check step) are tests/adtrain/replay/mutants-golden.txt, run by tests/adtrain/replay/run-replay.sh (evidence/ADTRAIN-GOLDEN-20261107/).

Central-difference rule (si19 qfdone, extended for small gradients): d = (f(p+ε) − f(p−ε))·32, with ε = 1/64 from dgeps in tests/adtrain/main.om, its own constant: it equals the learning rate but does not follow it, so a change of mllr is caught by the golden gates and not through the finite-difference step. The check passes iff |g| ≥ 1/64 and 16·|d − g| ≤ |g|, or |g| < 1/64 and |d − g| ≤ 1/64. A parameter is skipped when either perturbation changes the relu pattern. Observed: 58 checked, 0 skipped, 0 failed.

Declared tolerances for gate 5: PASS is 0 ULP on all 75 values (Y, loss, dW1, db1, dW2, db2). PASS_TOL allows at most 2 ULP. Anything else is FAIL. Observed on the host: exact=75/75 max_ulp=0 verdict=PASS. The --mutant-sign control (expected dW1 negated) FAILs as required.

Checkpoint adtrain.ck

The image is 536 bytes of u64 little-endian words:

wordcontent
0magic: the bytes of the text ADCKPT01
1version 1
2step
358
4lr bits
5loss bits
6data hash (FNV-1a 64 over the X and T bit patterns)
70
8–65the 58 parameters (f32 bits, zero-extended)
66FNV-1a 64 over bytes 0..527

Saving uses fopen (create/truncate, 0600), a full write, fsync and fclose. The load (mode R) refuses, leaving every parameter unchanged, in these cases:

There is no rename host word, so atomic publication is not claimed; the checksum rejects a torn image. The suite exercises each refusal path:

imageexit
seed-29 image66
truncated to 535 bytes65
byte 96 flipped (parameter mantissa, checksum only)65
byte 100 flipped (zero-extension padding)65

A plain byte flip only ever reaches the checksum, so the two flip cases above both exercise the checksum check. tests/adtrain/replay/run-replay.sh (DRA-14 replay, evidence/ADTRAIN-REPLAY-20261107/) forges re-checksummed images (replay/ckforge.om) that reach each structural check on its own, and removes one check at a time to show that each carries its refusal.

Exit codes

codemeaning
1gradient check failed
65corrupt checkpoint
66data binding mismatch
74file I/O
86non-finite loss or parameter
87tape refusal or unexpected node id
88loss not reduced
90bad mode byte

Compiled mutants (tests/adtrain/mutate.om)

modefaultobserved
0update direction reversedT exits 86
1data-hash check removedthe seed-29 image then loads (exit 0)
2checksum check removedthe byte-96 image then loads (exit 0)

Each mutant compiles with rc 0. Modes 1 and 2 show that the two checks carry the refusals; without them the load is wrongly accepted.

Exact-rational gradient oracle (gate 2, third reference)

tests/adtrain/gradient.wl regenerates the seed-17 data with the same xorshift64, binds to the K <i> <k> rows of mode D, fixes the relu pattern (x > 0) from the exact forward, differentiates the exact loss symbolically and compares every G row against |g − g_exact| ≤ 2^-16·max(1, |g_exact|). It ran on the hosted Wolfram service (WolframLanguageEvaluator). Observed: the K rows match, 58/58 gradients equal the exact values, and the step-0 loss equals 4155649/524288 exactly. A copy with one gradient's sign bit flipped reports allWithin False. The exactness comes from the small dyadic data: every binary32 operation of this step is exact. No pre-activation is exactly 0, so this oracle does not exercise the relu rule at 0; tests/autodiff664 does. Evidence: evidence/ADTRAIN/oracle.json, evidence/ADTRAIN/oracle/.

GB10 arm (gate 5)

Ran once on 2026-10-29 at 17:07Z, in a window Drake authorised. The slot came from CodexStackCompare on ~/handoffs/BOARD.md. Run conditions: GB10_CHIP_RUN=1 and /tmp/aien-gb10.lock, omega-mv 965fb762, physics 6d7cf0d4. Result: AD_FIXTURE_CHIP: exact=75/75 max_ulp=0 verdict=PASS; the sign-flip control fails. The native tape runs on the host; the GB10 replays the same step through the C M21 tape over the M20 GB10 realization. Receipt and limits: evidence/ADTRAIN/gb10/README.md.

Not claimed

General training, GPU launch from .om (omega-mv #638 / CUDApp #35), performance, atomic checkpoint publication, or hardware qualification.