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 / evidence / ECOSYSTEM6 / independent-review / mutant1-independent-unit.om

774 lines · 13218 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note Native IEEE binary32 addition over bit patterns, RNE and gradual underflow.
3note Canonical positive quiet NaN; no foreign floating runtime or compiler f32 type.
4fn ajam x ulong n ulong to ulong
5if eq n 0
6ret x
7end
8if ge n 64
9if ne x 0
10ret 1
11end
12ret 0
13end
14q = shr x n
15mask = sub shl 1 n 1
16if ne and x mask 0
17q = or q 1
18end
19ret q
20end
21fn add32 aa ulong bb ulong to ulong
22a = and aa 4294967295
23b = and bb 4294967295
24if or gt and a 2147483647 2139095040 gt and b 2147483647 2139095040
25ret 2143289344
26end
27if lt and a 2147483647 and b 2147483647
28t = a
29a = b
30b = t
31end
32if eq and a 2147483647 2139095040
33if and eq and b 2147483647 2139095040 ne and xor a b 2147483648 0
34ret 2143289344
35end
36ret a
37end
38if eq and b 2147483647 0
39if eq and a 2147483647 0
40ret and and a b 2147483648
41end
42ret a
43end
44sign = and a 2147483648
45ea = and shr a 23 255
46eb = and shr b 23 255
47ma = and a 8388607
48mb = and b 8388607
49if eq ea 0
50ea = 1
51else
52ma = or ma 8388608
53end
54if eq eb 0
55eb = 1
56else
57mb = or mb 8388608
58end
59ma = shl ma 3
60mb = shl mb 3
61mb = ajam mb sub ea eb
62if eq and xor a b 2147483648 0
63ma = add ma mb
64if ge ma 134217728
65ma = ajam ma 1
66ea = add ea 1
67end
68else
69ma = sub ma mb
70if eq ma 0
71ret 0
72end
73while and lt ma 67108864 gt ea 1
74ma = shl ma 1
75ea = sub ea 1
76end
77end
78q = shr ma 3
79r = and ma 7
80if gt r 4
81q = add q 1
82else
83if eq r 4
84if ne and q 1 0
85q = add q 1
86end
87end
88end
89if ge q 16777216
90q = shr q 1
91ea = add ea 1
92end
93if ge ea 255
94ret or sign 2139095040
95end
96if lt q 8388608
97ea = 0
98end
99q = and q 8388607
100ea = shl ea 23
101q = or q ea
102ret or sign q
103end
104note SPDX-License-Identifier: AGPL-3.0-only
105note Native IEEE binary32 multiplication represented as bits; no host floating runtime.
106note Round-to-nearest ties-to-even, gradual underflow, signed zeros and infinities.
107note Canonical positive quiet NaN for every NaN result. Inputs are low32 bits.
108fn mround x ulong shift ulong to ulong
109if eq shift 0
110ret x
111end
112if gt shift 63
113ret 0
114end
115q = shr x shift
116mask = sub shl 1 shift 1
117r = and x mask
118half = shl 1 sub shift 1
119if or gt r half and eq r half ne and q 1 0
120q = add q 1
121end
122ret q
123end
124fn mul32 aa ulong bb ulong to ulong
125a = and aa 4294967295
126b = and bb 4294967295
127sign = and xor a b 2147483648
128ea = long and shr a 23 255
129eb = long and shr b 23 255
130ma = and a 8388607
131mb = and b 8388607
132if or and eq ea 255 ne ma 0 and eq eb 255 ne mb 0
133ret 2143289344
134end
135if or eq ea 255 eq eb 255
136if or eq and a 2147483647 0 eq and b 2147483647 0
137ret 2143289344
138end
139ret or sign 2139095040
140end
141if or eq and a 2147483647 0 eq and b 2147483647 0
142ret sign
143end
144if eq ea 0
145ea = 1
146while lt ma 8388608
147ma = shl ma 1
148ea = sub ea 1
149end
150else
151ma = or ma 8388608
152end
153if eq eb 0
154eb = 1
155while lt mb 8388608
156mb = shl mb 1
157eb = sub eb 1
158end
159else
160mb = or mb 8388608
161end
162product = mul ma mb
163e = sub add ea eb 127
164shift = long 23
165if ge product 140737488355328
166shift = 24
167e = add e 1
168end
169if lt e 1
170shift = add shift sub 1 e
171e = 0
172end
173q = mround product ulong shift
174if eq e 0
175if ge q 8388608
176e = 1
177end
178else
179if ge q 16777216
180q = shr q 1
181e = add e 1
182end
183end
184if ge e 255
185ret or sign 2139095040
186end
187q = and q 8388607
188e = shl e 23
189q = or q ulong e
190ret or sign q
191end
192note M20 metadata-v1. Integer metadata only; no allocator or numeric execution.
193note ED: schema,dtype,rank,elements,offset,slot,generation,reserved,shape8,stride8.
194note ES: live,retired,slot,generation,dtype,elements,reserved,reserved.
195note ES is the caller-owned allocator snapshot. It is not untrusted wire input.
196global ED ulong 24
197global ES ulong 8
198
199fn emshape to int
200rank = get ED 2
201if gt rank 8
202ret -2
203end
204n = ulong 1
205for d ulong rank
206size = get ED add 8 d
207if eq size 0
208ret -3
209end
210if gt size div 1073741824 n
211ret -8
212end
213n = mul n size
214end
215if ne get ED 3 n
216ret -3
217end
218ret 0
219end
220
221fn emlive slot ulong gen ulong to int
222if gt slot 4294967295
223ret -5
224end
225if or ne get ES 0 1 ne get ES 1 0
226ret -5
227end
228if or eq gen 0 ne slot get ES 2
229ret -5
230end
231if ne gen get ES 3
232ret -5
233end
234ret 0
235end
236
237fn embounds to int
238size = get ES 5
239offset = get ED 4
240if or eq size 0 gt size 1073741824
241ret -8
242end
243if ge offset size
244ret -6
245end
246note Compare against remaining extent before multiplication, never overflow.
247room = sub sub size 1 offset
248for d ulong get ED 2
249count = sub get ED add 8 d 1
250stride = get ED add 16 d
251if ne stride 0
252if gt count div room stride
253ret -6
254end
255room = sub room mul count stride
256end
257end
258ret 0
259end
260
261fn emcheck to int
262if or ne get ED 0 1 ne get ED 7 0
263ret -1
264end
265if or ne get ES 6 0 ne get ES 7 0
266ret -1
267end
268dtype = get ED 1
269if or lt dtype 1 gt dtype 3
270ret -4
271end
272status = emshape
273if ne status 0
274ret status
275end
276status = emlive get ED 5 get ED 6
277if ne status 0
278ret status
279end
280if ne dtype get ES 4
281ret -4
282end
283ret embounds
284end
285
286fn emrelease slot ulong gen ulong to int
287status = emlive slot gen
288if ne status 0
289ret status
290end
291note A maximal generation is retired, never wrapped into a valid old handle.
292if eq gen 18446744073709551615
293put ES 1 1
294else
295put ES 3 add gen 1
296end
297put ES 0 0
298ret 0
299end
300note SPDX-License-Identifier: AGPL-3.0-only
301note Bounded host FP32 consumer. Uses external pinned L720 add32/mul32 and M20 emcheck.
302note Eight independent tensors X,W,b,T,Y,dX,dW,db in 16-cell slots.
303note Values are IEEE binary32 bits in ulong carriers, not integer fixed-point values.
304note AD/AS are trusted local descriptor and allocator snapshots, not wire records.
305global AD ulong 192
306global AS ulong 64
307global AP ulong 128
308global AQ ulong 128
309global AL ulong 1
310
311fn afcount t ulong to ulong
312if or eq t 2 eq t 7
313ret 2
314end
315if or eq t 3 eq t 4
316ret 4
317end
318ret 6
319end
320
321fn afget t ulong i ulong to ulong
322ret get AP add mul t 16 i
323end
324
325fn afq t ulong i ulong to ulong
326ret get AQ add mul t 16 i
327end
328
329fn afput t ulong i ulong v ulong to void
330put AQ add mul t 16 i v
331end
332
333fn affinite x ulong to bool
334if gt x 4294967295
335ret false
336end
337ret lt and x 2147483647 2139095040
338end
339
340fn afvalidate to int
341for t ulong 8
342for i ulong 24
343put ED i get AD add mul t 24 i
344end
345for i ulong 8
346put ES i get AS add mul t 8 i
347end
348status = emcheck
349if ne status 0
350ret status
351end
352note Contiguous owned local carriers only. This does not claim strided numeric kernels.
353if or ne get ED 1 1 ne get ED 4 0
354ret -20
355end
356if or ne get ED 5 add t 1 ne get ES 5 afcount t
357ret -20
358end
359rank = ulong 2
360rows = ulong 2
361cols = ulong 3
362if or eq t 1 eq t 6
363rows = 3
364cols = 2
365end
366if or eq t 3 eq t 4
367cols = 2
368end
369if or eq t 2 eq t 7
370rank = 1
371cols = 1
372end
373note MUTANT omits the dimension admission checks
374end
375ret 0
376end
377
378fn afstep lr ulong to int
379status = afvalidate
380if ne status 0
381ret status
382end
383if not affinite lr
384ret -22
385end
386if ne and lr 2147483648 0
387ret -22
388end
389for t ulong 4
390for i ulong afcount t
391if not affinite afget t i
392ret -22
393end
394end
395end
396for i ulong 128
397put AQ i 0
398end
399loss = ulong 0
400for row ulong 2
401for col ulong 2
402v = afget 2 col
403for k ulong 3
404x = afget 0 add mul row 3 k
405w = afget 1 add mul k 2 col
406v = add32 v mul32 x w
407end
408pos = add mul row 2 col
409afput 4 pos v
410r = add32 v xor afget 3 pos 2147483648
411loss = add32 loss mul32 r r
412g = mul32 1073741824 r
413afput 7 col add32 afq 7 col g
414for k ulong 3
415xp = add mul row 3 k
416wp = add mul k 2 col
417gx = mul32 g afget 1 wp
418gw = mul32 g afget 0 xp
419afput 5 xp add32 afq 5 xp gx
420afput 6 wp add32 afq 6 wp gw
421end
422end
423end
424note Commit only after all finite-result checks; rejected steps preserve AP and AL.
425for i ulong 6
426delta = mul32 lr afq 6 i
427afput 1 i add32 afget 1 i xor delta 2147483648
428end
429for i ulong 2
430delta = mul32 lr afq 7 i
431afput 2 i add32 afget 2 i xor delta 2147483648
432end
433if not affinite loss
434ret -23
435end
436for t ulong 8
437if and ne t 0 ne t 3
438for i ulong afcount t
439if not affinite afq t i
440ret -23
441end
442end
443end
444end
445for t ulong 8
446if and ne t 0 ne t 3
447for i ulong afcount t
448put AP add mul t 16 i afq t i
449end
450end
451end
452put AL 0 loss
453ret 0
454end
455note Independent Architecture303 reviewer. Literal symbolic oracle and central differences.
456note No imported author test helper, expected arithmetic, or generated product source.
457global BI ulong 14
458global PI ulong 14
459global MI ulong 14
460global PL ulong 14
461global ML ulong 14
462global GI ulong 14
463global DL ulong 14
464global OLD ulong 129
465global NC ulong 1
466global DIG uchar 24
467text OK "INDEPENDENT_AFFINE_PASS checks="
468text BAD "INDEPENDENT_AFFINE_FAIL check="
469text EOL "\n"
470
471fn dec n ulong to void
472p = ulong 24
473while gt n 0 bound 24
474p = sub p 1
475put DIG p uchar add 48 rem n 10
476n = div n 10
477end
478w = write 1 DIG p sub 24 p
479end
480
481fn chk value bool to void
482put NC 0 add get NC 0 1
483if not value
484w = write 1 BAD 0 len BAD
485dec get NC 0
486w = write 1 EOL 0 1
487exit 1
488end
489end
490
491fn tables to void
492note Decimal IEEE bitwords from independently evaluated symbolic polynomials.
493put BI 0 1065353216
494put BI 1 3221225472
495put BI 2 1077936128
496put BI 3 1073741824
497put BI 4 0
498put BI 5 3212836864
499put BI 6 1056964608
500put BI 7 3196059648
501put BI 8 1065353216
502put BI 9 1061158912
503put BI 10 3204448256
504put BI 11 1073741824
505put BI 12 1040187392
506put BI 13 3204448256
507put PI 0 1066401792
508put PI 1 3220176896
509put PI 2 1078460416
510put PI 3 1074266112
511put PI 4 1040187392
512put PI 5 3210739712
513put PI 6 1059061760
514put PI 7 3187671040
515put PI 8 1066401792
516put PI 9 1063256064
517put PI 10 3200253952
518put PI 11 1074266112
519put PI 12 1048576000
520put PI 13 3200253952
521put MI 0 1063256064
522put MI 1 3221749760
523put MI 2 1077411840
524put MI 3 1072693248
525put MI 4 3187671040
526put MI 5 3213885440
527put MI 6 1052770304
528put MI 7 3200253952
529put MI 8 1063256064
530put MI 9 1059061760
531put MI 10 3206545408
532put MI 11 1072693248
533put MI 12 0
534put MI 13 3206545408
535put GI 0 3230662656
536put GI 1 3221749760
537put GI 2 1096941568
538put GI 3 1082916864
539put GI 4 0
540put GI 5 3246718976
541put GI 6 1082654720
542put GI 7 3238526976
543put GI 8 1095237632
544put GI 9 3241148416
545put GI 10 3250585600
546put GI 11 1102839808
547put GI 12 3212836864
548put GI 13 3217031168
549put PL 0 1108321536
550put PL 1 1108404480
551put PL 2 1108947968
552put PL 3 1108612352
553put PL 4 1108474112
554put PL 5 1107940352
555put PL 6 1108627456
556put PL 7 1108209664
557put PL 8 1108893696
558put PL 9 1108123648
559put PL 10 1107722240
560put PL 11 1109278720
561put PL 12 1108443136
562put PL 13 1108426752
563put ML 0 1108616448
564put ML 1 1108543744
565put ML 2 1108022272
566put ML 3 1108325632
567put ML 4 1108474112
568put ML 5 1109029888
569put ML 6 1108348928
570put ML 7 1108766720
571put ML 8 1108074496
572put ML 9 1108844544
573put ML 10 1109295104
574put ML 11 1107738624
575put ML 12 1108508672
576put ML 13 1108525056
577put DL 0 3213885440
578put DL 1 3204972544
579put DL 2 1080164352
580put DL 3 1066139648
581put DL 4 0
582put DL 5 3229941760
583put DL 6 1065877504
584put DL 7 3221749760
585put DL 8 1078460416
586put DL 9 3224371200
587put DL 10 3233808384
588put DL 11 1086062592
589put DL 12 3196059648
590put DL 13 3200253952
591end
592
593fn loc p ulong to ulong
594if lt p 6
595ret p
596end
597if lt p 12
598ret add p 10
599end
600ret add p 20
601end
602
603fn dim t ulong rank ulong a ulong b ulong to void
604d = mul t 24
605s = mul t 8
606n = mul a b
607put AD d 1
608put AD add d 1 1
609put AD add d 2 rank
610put AD add d 3 n
611put AD add d 5 add t 1
612put AD add d 6 add t 9
613put AD add d 8 a
614put AD add d 16 b
615if eq rank 2
616put AD add d 9 b
617put AD add d 17 1
618end
619put AS s 1
620put AS add s 2 add t 1
621put AS add s 3 add t 9
622put AS add s 4 1
623put AS add s 5 n
624end
625
626fn init to void
627for i ulong 192
628put AD i 0
629end
630for i ulong 64
631put AS i 0
632end
633for i ulong 128
634put AP i 2143289344
635end
636put AL 0 1092616192
637dim 0 2 2 3
638dim 1 2 3 2
639dim 2 1 2 1
640dim 3 2 2 2
641dim 4 2 2 2
642dim 5 2 2 3
643dim 6 2 3 2
644dim 7 1 2 1
645for p ulong 14
646put AP loc p get BI p
647end
648put AP 48 1048576000
649put AP 49 1065353216
650put AP 50 3212836864
651put AP 51 1056964608
652end
653
654fn freeze to void
655for i ulong 128
656put OLD i get AP i
657end
658put OLD 128 get AL 0
659end
660
661fn same to void
662for i ulong 128
663chk eq get OLD i get AP i
664end
665chk eq get OLD 128 get AL 0
666end
667
668fn grads to void
669for i ulong 6
670chk eq get AP add 80 i get GI i
671chk eq get AP add 96 i get GI add i 6
672end
673chk eq get AP 112 get GI 12
674chk eq get AP 113 get GI 13
675end
676
677fn one to void
678init
679chk eq afstep 1023410176 0
680chk eq get AP 64 3224895488
681chk eq get AP 65 1081081856
682chk eq get AP 66 1070596096
683chk eq get AP 67 3225419776
684chk eq get AL 0 1108467712
685grads
686chk eq get AP 16 1052508160
687chk eq get AP 17 1015021568
688chk eq get AP 18 1058799616
689chk eq get AP 19 1066139648
690chk eq get AP 20 1048576000
691chk eq get AP 21 1067581440
692chk eq get AP 32 1042284544
693chk eq get AP 33 3202875392
694for i ulong 6
695chk eq get AP i get BI i
696end
697chk eq get AP 48 1048576000
698chk eq get AP 49 1065353216
699chk eq get AP 50 3212836864
700chk eq get AP 51 1056964608
701note Non-tensor padding must remain unchanged by the fixed-slot commit.
702for t ulong 8
703chk eq get AP add mul t 16 15 2143289344
704end
705end
706
707fn central to void
708for p ulong 14
709init
710put AP loc p get PI p
711chk eq afstep 0 0
712hi = get AL 0
713chk eq hi get PL p
714init
715put AP loc p get MI p
716chk eq afstep 0 0
717lo = get AL 0
718chk eq lo get ML p
719note Expected loss difference is a literal from symbolic exact arithmetic.
720chk eq add32 hi xor lo 2147483648 get DL p
721end
722init
723chk eq afstep 0 0
724grads
725freeze
726chk eq afstep 0 0
727same
728end
729
730fn reject to void
731init
732put AD 8 3
733put AD 9 2
734put AD 16 2
735freeze
736chk eq afstep 0 -21
737same
738init
739put AD 6 0
740freeze
741chk eq afstep 0 -5
742same
743init
744put AS 3 10
745freeze
746chk eq afstep 0 -5
747same
748init
749freeze
750chk eq afstep 2147483648 -22
751same
752init
753put AP 17 2143289344
754freeze
755chk eq afstep 0 -22
756same
757init
758put AP 0 2139095039
759put AP 16 2139095039
760freeze
761chk eq afstep 0 -23
762same
763end
764
765fn main to int
766tables
767one
768central
769reject
770w = write 1 OK 0 len OK
771dec get NC 0
772w = write 1 EOL 0 1
773ret 0
774end