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 / tests / omegallm / ORACLE.md

237 lines · 14551 bytes Raw Blame History Source

Omega LLM oracle (v0 and v1)

oracle.py is a referee for docs/omegallm/CONTRACT.md (v0) and docs/omegallm/CONTRACT-V1.md (v1). It uses only the Python 3 standard library (math.exp, math.log, math.sqrt on f64 floats; no numpy). It was written from the contracts, not ported from native/omegallm/*.om. It is for verification only and is never part of the build. The v1 part is described in v1 referee; everything before it is v0 and unchanged.

What it implements

Commands

Run everything on core 8 at nice 19. Core 8 is a Cortex-X925 on the GB10 Grace (MIDR 0x410fd851 in /sys/devices/system/cpu/cpu8/regs/identification/midr_el1).

taskset -c 8 nice -n 19 python3 tests/omegallm/oracle.py selftest
taskset -c 8 nice -n 19 python3 tests/omegallm/oracle.py prep IN TRAIN HELD   # prints P ...
taskset -c 8 nice -n 19 python3 tests/omegallm/oracle.py base TRAIN HELD      # prints B ...
# Cross-checks against an ollm binary. Each writes a JSON receipt with argv, rc, stdout, stderr,
# seconds, the binary sha256 and per-check results.
oracle.py xprep --ollm BIN --data IN --outdir DIR [--receipt R.json]   # sha256 of TRAIN, HELD + stdout
oracle.py xbase --ollm BIN --train TRAIN --held HELD                  # exact micro values
oracle.py xinit --ollm BIN [--cfg small|v0]                           # params bit-for-bit, whole file sha256
oracle.py xgrad --ollm BIN --data DATA [--cfg small|v0] [--batch B]   # loss + every gradient entry
oracle.py xstep --ollm BIN --data DATA [--cfg small|v0]               # train s -> s+1: params, m, v, step
oracle.py xeval --ollm BIN --held HELD [--cfg small|v0]               # eval stdout
# All checks for one binary, with receipts under OUTDIR/LABEL (relative paths, so receipts name none):
DATA=data/TinyStoriesV2-GPT4-valid.txt WORK=scratch-oracle/work tests/omegallm/xcheck.sh BIN LABEL OUTDIR [v0]

selftest checks:

Negative control: flipping the dK sign in the attention backward, or the sign of the one-hot term in the cross-entropy gradient, makes selftest fail. See evidence/OMEGALLM/oracle/README.md.

The cases in xgrad and xstep:

Known answers

The values were computed with Wolfram (query W1):

fnv[s_]:=Fold[Mod[BitXor[#1,#2]*1099511628211,2^64]&,14695981039346656037,ToCharacterCode[s]];
sm[x_]:=Module[{z=Mod[x+16^^9E3779B97F4A7C15,2^64]},z=Mod[BitXor[z,BitShiftRight[z,30]]*16^^BF58476D1CE4E5B9,2^64];
  z=Mod[BitXor[z,BitShiftRight[z,27]]*16^^94D049BB133111EB,2^64];BitXor[z,BitShiftRight[z,31]]];
{fnv[""],fnv["a"],fnv["foobar"],fnv["OLLMCK01"],sm[0],sm[1],sm[2^64-1],sm[42],
 Mod[sm[BitXor[7,Mod[7*16^^9E3779B97F4A7C15,2^64]]],1000], BitShiftRight[sm[47],11]}
-> cbf29ce484222325 af63dc4c8601ec8c 85944171f73967e8 29c48bb36358f164
   e220a8397b1dcdaf 910a2dec89025cc1 e4d971771b652c20 bdd732262feb6e95  533  4352384759967643

Tolerance

xgrad and xstep compare each entry with

err = |got − ref| / max(|ref|, 10⁻³ · max|ref in that tensor|), and require err ≤ 10⁻⁹.

Both sides are f64, but their summation orders differ. The longest reduction behind any gradient entry is at most n = 4096 terms: B·T·(the inner dimension) stays below that in the small config, and the per-entry accumulation over B·T = 1024 positions in v0 does too. The classical worst-case relative bound is γₙ = n·u/(1 − n·u).

The floor of 10⁻³ of the tensor maximum caps the amplification of cancellation in entries near zero at 10³. Wolfram (query W2):

u=2^-53; g[n_]:=n u/(1-n u); {N[u],N[g[4096]],N[10^3 g[4096]],N[10^-9/(10^3 g[4096])]} -> {1.11*10^-16, 4.547*10^-13, 4.547*10^-10, 2.2}

So 10⁻⁹ is 2.2 times the heuristic bound 10³·γ₄₀₉₆. This is a forward-error heuristic, not a proof; the receipts give the observed maximum per tensor.

The loss must also agree to a relative 10⁻⁹, and the printed loss_micro must match exactly. Init must agree bit for bit. Prep must be byte-identical. Base and eval must print the same micro integers.

Contract readings agreed with the core lane

These readings were agreed with OllmCore and are written into CONTRACT.md by that lane:

v1 referee (CONTRACT-V1)

What it implements

The model arithmetic reuses the v0 forward, backward and Adam code. Only the block grouping, the shapes and the file formats are new.

Commands

taskset -c 8 nice -n 19 python3 tests/omegallm/oracle.py selftest-v1
# The ollm command line of CONTRACT-V1 §7; same stdout, files and exit codes as the product:
python3 tests/omegallm/oracle.py ollm bpefit TEXT MERGES V [MAXBYTES]
python3 tests/omegallm/oracle.py ollm train CK DATA UNTIL EVERY [K]          # etc., every §7 command
# Compare a product file with a referee file:
python3 tests/omegallm/oracle.py cmp ck|gr GOT REF   # header bytes exact, payload within the tolerance below
python3 tests/omegallm/oracle.py cmp gline GOT REF   # G line: loss_micro exact, loss bits within the tolerance
python3 tests/omegallm/oracle.py cmp tok|bytes GOT REF
# Every v1 case against a binary; one PASS/FAIL/NOT_RUN line per case, then SUMMARY:
BIN=path/to/ollm DATA=data WORK=scratch-v1-oracle sh tests/omegallm/v1-oracle.sh

selftest-v1 checks:

v1-oracle.sh reads DATA/TinyStoriesV2-GPT4-valid.txt and runs everything on CORE (default 8) at nice 19, the script itself included. Its cases:

The referee's own exit code is checked even without BIN. A referee that refuses where the contract expects success is a FAIL, not a NOT_RUN.

Tolerance

§9.3 (amended) sets these comparison rules:

The longest reduction behind any entry in the small config is far below the 4096 terms the v0 bound assumes:

So the W2 bound carries over unchanged.

sample and eval are compared byte for byte. That goes beyond §9.3; a mismatch there is reported with the first differing byte.

Negative controls

OLLM_ORACLE_MUTANT=NAME, or MUTANT=NAME for the script, plants a defect in the referee. With an honest product, each mutant must produce FAIL lines.

MutantDefectCases that FAIL
tiemaxaties go to the largest areferee-selftest-v1, fit-tie, fit-tie-kat, fit-edge, enc-edge
chunk63long chunks are cut into 63-byte pieces instead of 64referee-selftest-v1, fit-edge, enc-edge
blockscaleblock gradients are scaled by 1/(T·R) instead of 1/(T·B)referee-selftest-v1, grad-g2, grad-g4, data-lazy
bpbv0eval at V > 256 prints v0's loss/ln 2 instead of the §7.1 bits per byteeval-w4-bpb

blockscale passes the train cases. Adam's update m̂/(√v̂ + ε) does not change when the gradient is scaled, apart from ε. So a gradient-scale defect is caught by grad, not by train.

Reversing the order in which blocks are summed (blockrev) changes the result only at rounding level. It is invisible within the tolerance, so it is not a mutant. Only .om against .om comparisons, which are bit-exact (§9.4 K identity), can catch it.

Readings

These are the referee's literal readings of points that CONTRACT-V1 leaves implicit:

Measured

All runs below were on GB10 Grace core 8 (Cortex-X925), at nice 19, using /usr/bin/time.

StepWall timePeak RSSOutput
ollm prep of the valid text0.09 sP 27630 24867 2763 19883834 2220914
ollm bpefit TRAIN V = 5120.94 s145 MBM 512 13055 4975460 19883834
ollm bpeenc TRAIN V = 5121.06 sK 19883834 8320463
the whole v1-oracle.sh, with the referee itself as BIN21.5 s788 MBSUMMARY pass=53 fail=0 not_run=1

In the full-script run, the one NOT_RUN case is v0-v1-ck01, which needs V0BIN.