Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-train/blob/main/evidence/ADTRAIN/oracle/control.wl # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-train / evidence / ADTRAIN / oracle / control.wl` 52 lines ยท 3037 bytes Raw Blame History 1 gbits = {`1012531200`,`3200499712`,`1038315520`,`1057377920`,`3192803328`,`1044633088`,`1072657216`,`1059866112`,`3210915840`,`1051499520`,`3214650560`,`3215344960`,`3179126784`,`3206203264`,`3214120640`,`3221337216`,`3191130112`,`1026220032`,`3196256768`,`3213141312`,`3167682560`,`3209066880`,`3211721344`,`3216259840`,`3208305408`,`3193594880`,`3211001984`,`3221852992`,`3206473216`,`3220845952`,`3205072128`,`3224286976`,`1066432512`,`1050025984`,`1068422656`,`1077000192`,`3213832192`,`1074026496`,`3190120448`,`1082103808`,`3210985600`,`3208587392`,`3212141952`,`3213871040`,`3214739904`,`3190289408`,`3222396032`,`1060899584`,`3205229568`,`1056598016`,`3222220288`,`1052957696`,`3223806656`,`1039037440`,`3227447552`,`1067773184`,`3239437312`,`1054441472`}; 2 kref = {5,7,-3,5,-8,2,0,-4,7,0}; 3 l0bits = `1090364420`; 4 gbits = ReplacePart[gbits, 1 -> BitXor[gbits[[1]], 2^31]]; 5 (* SPDX-License-Identifier: AGPL-3.0-only *) 6 (* adtrain exact-rational gradient oracle (Wolfram Language; verification only). 7 Inputs, prepended by the caller from one run of the suite: 8 gbits = {58 integers} bit patterns of the `G ` rows (run/G.stdout) 9 kref = {10 integers} the `K ` rows (run/D.stdout) 10 l0bits = integer the `L 0 ` row (run/T.stdout) 11 Regenerates the seed-17 data and initial parameters exactly, fixes the relu 12 pattern (x > 0, the tape's rule) from the exact forward, differentiates the 13 exact loss symbolically, and compares every tape value against the declared 14 bound |om - exact| <= 2^-16 Max[1, |exact|]. *) 15 mask64 = 2^64 - 1; 16 xs[x_] := Module[{y = x}, 17 y = BitXor[y, BitAnd[BitShiftLeft[y, 13], mask64]]; 18 y = BitXor[y, BitShiftRight[y, 7]]; 19 BitXor[y, BitAnd[BitShiftLeft[y, 17], mask64]]]; 20 ks = Mod[Rest[NestList[xs, 17, 96]], 17] - 8; 21 xv = Partition[ks[[1 ;; 32]]/8, 4]; 22 tv = Partition[ks[[33 ;; 48]]/8, 2]; 23 w1v = Partition[ks[[49 ;; 80]]/16, 8]; 24 w2v = Partition[ks[[81 ;; 96]]/16, 2]; 25 w1s = Array[a, {4, 8}]; b1s = Array[b, 8]; w2s = Array[c, {8, 2}]; b2s = Array[d, 2]; 26 params = Join[Flatten[w1s], b1s, Flatten[w2s], b2s]; 27 point = Thread[params -> Join[Flatten[w1v], ConstantArray[0, 8], Flatten[w2v], ConstantArray[0, 2]]]; 28 pre = xv . w1s + ConstantArray[b1s, 8]; 29 preV = pre /. point; 30 relu = Map[Boole[# > 0] &, preV, {2}]; 31 y = (relu*pre) . w2s + ConstantArray[b2s, 8]; 32 loss = Total[(y - tv)^2, 2]; 33 gex = D[loss, {params}] /. point; 34 lex = loss /. point; 35 f32[u_] := Module[{s = BitShiftRight[u, 31], e = BitAnd[BitShiftRight[u, 23], 255], 36 m = BitAnd[u, 2^23 - 1]}, 37 (-1)^s If[e == 0, m 2^-149, (2^23 + m) 2^(e - 150)]]; 38 gom = f32 /@ gbits; 39 bound = 2^-16 Max[1, Abs[#]] & /@ gex; 40 diff = Abs[gom - gex]; 41 lom = f32[l0bits]; 42 <|"kMatch" -> (ks[[1 ;; 10]] === kref), 43 "zeroPreActivations" -> Count[Flatten[preV], 0], 44 "reluActive" -> Total[Flatten[relu]], 45 "n" -> Length[gex], 46 "allWithin" -> And @@ Thread[diff <= bound], 47 "exactEqual" -> Count[diff, 0], 48 "maxDiffOverBound" -> N[Max[diff/bound]], 49 "maxAbsDiff" -> N[Max[diff]], 50 "lossExact" -> lex, "lossOm" -> lom, 51 "lossWithin" -> (Abs[lom - lex] <= 2^-16 Max[1, Abs[lex]]), 52 "lossRelErr" -> N[Abs[lom - lex]/Abs[lex]]|>