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/native/neuralese/verify.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 / native / neuralese / verify.wl`
18 lines ยท 3061 bytes Raw Blame History
1 (* The inserted exact-gradient oracle is independent, not a host trainer. *)
2 __GRAD_SOURCE__;
3 fromBits[n_Integer] := Module[{sgn,e,m},sgn=If[BitAnd[BitShiftRight[n,63],1]==1,-1,1]; e=BitAnd[BitShiftRight[n,52],2047]; m=BitAnd[n,2^52-1]; If[e==0,sgn m 2^-1074,sgn (2^52+m) 2^(e-1075)]];
4 gdata=Map[ToExpression,ImportString[__GDATA__,"RawJSON"],{2}]; fdata=Map[ToExpression,ImportString[__FDATA__,"RawJSON"],{2}]; pdata=Map[ToExpression,ImportString[__PDATA__,"RawJSON"],{2}];
5 ngrad=fromBits/@gdata[[All,3]]; nupdate=fromBits/@gdata[[All,4]];
6 gerr=Max[Abs[ngrad-grad]]; uerr=Max[Abs[nupdate-(p0-grad/10)]];
7 hw=Nest[KroneckerProduct[{{1,1},{1,-1}},#]&,{{1}},3]; he=hw[[All,{2,3,5,8}]]/Sqrt[8];
8 ferr[r_] := Module[{xx,hh,expected},xx=Reverse[IntegerDigits[r[[1]],2,4]]; hh=xx.Transpose[he]; If[r[[2]]!=0,hh=Round[r[[2]] hh]/r[[2]]]; expected=hh.he; Abs[fromBits[r[[4]]]-expected[[r[[3]]+1]]]];
9 fe=Max[ferr/@fdata]; predictions=And@@Map[(#[[5]]==Reverse[IntegerDigits[#[[1]],2,4]][[#[[3]]+1]])&,fdata];
10 s={{1,1,1,0},{1,0,0,1},{0,1,1,1}}; sh=s.Transpose[he];
11 qcurve=Table[{q,N[Max[Abs[Flatten[(Round[q sh]/q).he-s]]]]},{q,{1,2,4,8,16,32,64}}];
12 coords=Map[(fromBits/@#[[7;;9]])&,pdata];
13 num[x_] := ToString[N[x],InputForm];
14 qpoints=StringRiffle[(num[40+65 Log[2,#[[1]]]]<>","<>num[240-240 #[[2]]])&/@qcurve," "];
15 qplot="";
16 pdots=StringJoin[MapThread[("num[240+160 #1[[1]]]<> "\" cy=\""<>num[140-100 #1[[2]]]<> "\" r=\"4\" fill=\"hsl("<>num[180 (#1[[3]]+1)]<>",70%,40%)\"/>num[246+160 #1[[1]]]<> "\" y=\""<>num[140-100 #1[[2]]]<> "\" font-size=\"10\">"<>ToString[#2]<>"")&,{coords,pdata[[All,4]]}]];
17 pplot="";
18 ExportString[<|"status"->If[gerr<10^-12&&uerr<10^-12&&fe<10^-12&&predictions,"PASS","FAIL"],"scope"->"EXERCISED independent comparison of native binary64 carriers with exact Wolfram oracle","gradientCount"->Length[gdata],"gradientMaxError"->N[gerr,18],"updateMaxError"->N[uerr,18],"fixedFeatureCount"->Length[fdata],"fixedMaxError"->N[fe,18],"fixedPredictionsCorrect"->predictions,"quantizationPlotSVG"->qplot,"learnedMessagePlotSVG"->pplot|>,"RawJSON"]