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 / mutant2-independent-unit.om

784 lines · 13306 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
373if or ne get ED 2 rank ne get ED 8 rows
374ret -21
375end
376if ne get ED 16 cols
377ret -21
378end
379if eq rank 2
380if or ne get ED 9 cols ne get ED 17 1
381ret -21
382end
383end
384end
385ret 0
386end
387
388fn afstep lr ulong to int
389status = afvalidate
390if ne status 0
391ret status
392end
393if not affinite lr
394ret -22
395end
396if ne and lr 2147483648 0
397ret -22
398end
399for t ulong 4
400for i ulong afcount t
401if not affinite afget t i
402ret -22
403end
404end
405end
406for i ulong 128
407put AQ i 0
408end
409loss = ulong 0
410for row ulong 2
411for col ulong 2
412v = afget 2 col
413for k ulong 3
414x = afget 0 add mul row 3 k
415w = afget 1 add mul k 2 col
416v = add32 v mul32 x w
417end
418pos = add mul row 2 col
419afput 4 pos v
420r = add32 v xor afget 3 pos 2147483648
421loss = add32 loss mul32 r r
422g = mul32 1073741824 r
423afput 7 col add32 afq 7 col g
424for k ulong 3
425xp = add mul row 3 k
426wp = add mul k 2 col
427gx = mul32 g afget 1 wp
428gw = mul32 g afget 0 xp
429afput 5 xp add32 afq 5 xp gx
430afput 6 wp add32 afq 6 wp gw
431end
432end
433end
434note Commit only after all finite-result checks; rejected steps preserve AP and AL.
435for i ulong 6
436delta = mul32 lr afq 6 i
437afput 1 i add32 afget 1 i delta
438end
439for i ulong 2
440delta = mul32 lr afq 7 i
441afput 2 i add32 afget 2 i xor delta 2147483648
442end
443if not affinite loss
444ret -23
445end
446for t ulong 8
447if and ne t 0 ne t 3
448for i ulong afcount t
449if not affinite afq t i
450ret -23
451end
452end
453end
454end
455for t ulong 8
456if and ne t 0 ne t 3
457for i ulong afcount t
458put AP add mul t 16 i afq t i
459end
460end
461end
462put AL 0 loss
463ret 0
464end
465note Independent Architecture303 reviewer. Literal symbolic oracle and central differences.
466note No imported author test helper, expected arithmetic, or generated product source.
467global BI ulong 14
468global PI ulong 14
469global MI ulong 14
470global PL ulong 14
471global ML ulong 14
472global GI ulong 14
473global DL ulong 14
474global OLD ulong 129
475global NC ulong 1
476global DIG uchar 24
477text OK "INDEPENDENT_AFFINE_PASS checks="
478text BAD "INDEPENDENT_AFFINE_FAIL check="
479text EOL "\n"
480
481fn dec n ulong to void
482p = ulong 24
483while gt n 0 bound 24
484p = sub p 1
485put DIG p uchar add 48 rem n 10
486n = div n 10
487end
488w = write 1 DIG p sub 24 p
489end
490
491fn chk value bool to void
492put NC 0 add get NC 0 1
493if not value
494w = write 1 BAD 0 len BAD
495dec get NC 0
496w = write 1 EOL 0 1
497exit 1
498end
499end
500
501fn tables to void
502note Decimal IEEE bitwords from independently evaluated symbolic polynomials.
503put BI 0 1065353216
504put BI 1 3221225472
505put BI 2 1077936128
506put BI 3 1073741824
507put BI 4 0
508put BI 5 3212836864
509put BI 6 1056964608
510put BI 7 3196059648
511put BI 8 1065353216
512put BI 9 1061158912
513put BI 10 3204448256
514put BI 11 1073741824
515put BI 12 1040187392
516put BI 13 3204448256
517put PI 0 1066401792
518put PI 1 3220176896
519put PI 2 1078460416
520put PI 3 1074266112
521put PI 4 1040187392
522put PI 5 3210739712
523put PI 6 1059061760
524put PI 7 3187671040
525put PI 8 1066401792
526put PI 9 1063256064
527put PI 10 3200253952
528put PI 11 1074266112
529put PI 12 1048576000
530put PI 13 3200253952
531put MI 0 1063256064
532put MI 1 3221749760
533put MI 2 1077411840
534put MI 3 1072693248
535put MI 4 3187671040
536put MI 5 3213885440
537put MI 6 1052770304
538put MI 7 3200253952
539put MI 8 1063256064
540put MI 9 1059061760
541put MI 10 3206545408
542put MI 11 1072693248
543put MI 12 0
544put MI 13 3206545408
545put GI 0 3230662656
546put GI 1 3221749760
547put GI 2 1096941568
548put GI 3 1082916864
549put GI 4 0
550put GI 5 3246718976
551put GI 6 1082654720
552put GI 7 3238526976
553put GI 8 1095237632
554put GI 9 3241148416
555put GI 10 3250585600
556put GI 11 1102839808
557put GI 12 3212836864
558put GI 13 3217031168
559put PL 0 1108321536
560put PL 1 1108404480
561put PL 2 1108947968
562put PL 3 1108612352
563put PL 4 1108474112
564put PL 5 1107940352
565put PL 6 1108627456
566put PL 7 1108209664
567put PL 8 1108893696
568put PL 9 1108123648
569put PL 10 1107722240
570put PL 11 1109278720
571put PL 12 1108443136
572put PL 13 1108426752
573put ML 0 1108616448
574put ML 1 1108543744
575put ML 2 1108022272
576put ML 3 1108325632
577put ML 4 1108474112
578put ML 5 1109029888
579put ML 6 1108348928
580put ML 7 1108766720
581put ML 8 1108074496
582put ML 9 1108844544
583put ML 10 1109295104
584put ML 11 1107738624
585put ML 12 1108508672
586put ML 13 1108525056
587put DL 0 3213885440
588put DL 1 3204972544
589put DL 2 1080164352
590put DL 3 1066139648
591put DL 4 0
592put DL 5 3229941760
593put DL 6 1065877504
594put DL 7 3221749760
595put DL 8 1078460416
596put DL 9 3224371200
597put DL 10 3233808384
598put DL 11 1086062592
599put DL 12 3196059648
600put DL 13 3200253952
601end
602
603fn loc p ulong to ulong
604if lt p 6
605ret p
606end
607if lt p 12
608ret add p 10
609end
610ret add p 20
611end
612
613fn dim t ulong rank ulong a ulong b ulong to void
614d = mul t 24
615s = mul t 8
616n = mul a b
617put AD d 1
618put AD add d 1 1
619put AD add d 2 rank
620put AD add d 3 n
621put AD add d 5 add t 1
622put AD add d 6 add t 9
623put AD add d 8 a
624put AD add d 16 b
625if eq rank 2
626put AD add d 9 b
627put AD add d 17 1
628end
629put AS s 1
630put AS add s 2 add t 1
631put AS add s 3 add t 9
632put AS add s 4 1
633put AS add s 5 n
634end
635
636fn init to void
637for i ulong 192
638put AD i 0
639end
640for i ulong 64
641put AS i 0
642end
643for i ulong 128
644put AP i 2143289344
645end
646put AL 0 1092616192
647dim 0 2 2 3
648dim 1 2 3 2
649dim 2 1 2 1
650dim 3 2 2 2
651dim 4 2 2 2
652dim 5 2 2 3
653dim 6 2 3 2
654dim 7 1 2 1
655for p ulong 14
656put AP loc p get BI p
657end
658put AP 48 1048576000
659put AP 49 1065353216
660put AP 50 3212836864
661put AP 51 1056964608
662end
663
664fn freeze to void
665for i ulong 128
666put OLD i get AP i
667end
668put OLD 128 get AL 0
669end
670
671fn same to void
672for i ulong 128
673chk eq get OLD i get AP i
674end
675chk eq get OLD 128 get AL 0
676end
677
678fn grads to void
679for i ulong 6
680chk eq get AP add 80 i get GI i
681chk eq get AP add 96 i get GI add i 6
682end
683chk eq get AP 112 get GI 12
684chk eq get AP 113 get GI 13
685end
686
687fn one to void
688init
689chk eq afstep 1023410176 0
690chk eq get AP 64 3224895488
691chk eq get AP 65 1081081856
692chk eq get AP 66 1070596096
693chk eq get AP 67 3225419776
694chk eq get AL 0 1108467712
695grads
696chk eq get AP 16 1052508160
697chk eq get AP 17 1015021568
698chk eq get AP 18 1058799616
699chk eq get AP 19 1066139648
700chk eq get AP 20 1048576000
701chk eq get AP 21 1067581440
702chk eq get AP 32 1042284544
703chk eq get AP 33 3202875392
704for i ulong 6
705chk eq get AP i get BI i
706end
707chk eq get AP 48 1048576000
708chk eq get AP 49 1065353216
709chk eq get AP 50 3212836864
710chk eq get AP 51 1056964608
711note Non-tensor padding must remain unchanged by the fixed-slot commit.
712for t ulong 8
713chk eq get AP add mul t 16 15 2143289344
714end
715end
716
717fn central to void
718for p ulong 14
719init
720put AP loc p get PI p
721chk eq afstep 0 0
722hi = get AL 0
723chk eq hi get PL p
724init
725put AP loc p get MI p
726chk eq afstep 0 0
727lo = get AL 0
728chk eq lo get ML p
729note Expected loss difference is a literal from symbolic exact arithmetic.
730chk eq add32 hi xor lo 2147483648 get DL p
731end
732init
733chk eq afstep 0 0
734grads
735freeze
736chk eq afstep 0 0
737same
738end
739
740fn reject to void
741init
742put AD 8 3
743put AD 9 2
744put AD 16 2
745freeze
746chk eq afstep 0 -21
747same
748init
749put AD 6 0
750freeze
751chk eq afstep 0 -5
752same
753init
754put AS 3 10
755freeze
756chk eq afstep 0 -5
757same
758init
759freeze
760chk eq afstep 2147483648 -22
761same
762init
763put AP 17 2143289344
764freeze
765chk eq afstep 0 -22
766same
767init
768put AP 0 2139095039
769put AP 16 2139095039
770freeze
771chk eq afstep 0 -23
772same
773end
774
775fn main to int
776tables
777one
778central
779reject
780w = write 1 OK 0 len OK
781dec get NC 0
782w = write 1 EOL 0 1
783ret 0
784end