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 / native / neuralese / nl1r-task / evidence / task.om

878 lines · 13287 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note Extension of affine.om staged explicit SGD; historical bytes remain immutable.
3note Globals are bounded scratch state. Receiver never reads NX or NT.
4global NP f64 83
5global NG f64 83
6global NC f64 83
7global NX f64 4
8global NT f64 4
9global NA f64 4
10global NH f64 4
11global NZ f64 4
12global NO f64 4
13global ND f64 4
14global NU f64 8
15global NV f64 8
16global NE f64 8
17global NSH ulong 4
18global RNG ulong 1
19
20fn nsoft x f64 to f64
21ret div x add 1.0f64 fabs x
22end
23fn nslope x f64 to f64
24d = add 1.0f64 fabs x
25ret div 1.0f64 mul d d
26end
27fn nrelu x f64 to f64
28if gt x 0.0f64
29ret x
30end
31ret 0.0f64
32end
33fn nshape arm ulong to int
34if gt arm 3
35ret 1
36end
37put NSH 0 arm
38put NSH 1 3
39put NSH 2 31
40if eq arm 1
41put NSH 1 4
42put NSH 2 40
43end
44if eq arm 2
45put NSH 2 83
46end
47if eq arm 3
48put NSH 1 1
49put NSH 2 0
50end
51put NSH 3 0
52ret 0
53end
54fn nrand to ulong
55x = get RNG 0
56x = and xor x shl x 13 4294967295
57x = xor x shr x 17
58x = and xor x shl x 5 4294967295
59put RNG 0 x
60ret x
61end
62fn ninit seed ulong to void
63put RNG 0 seed
64for i ulong get NSH 2
65v = sub long rem nrand 33 16
66put NP i div f64 v 64.0f64
67end
68put NSH 3 0
69end
70fn ninput id ulong target ulong to void
71for j ulong 4
72put NX j f64 and shr id j 1
73put NT j f64 and shr target j 1
74end
75end
76fn nsend to void
77d = get NSH 1
78for k ulong d
79v = get NP add mul 4 d k
80for j ulong 4
81v = add v mul get NX j get NP add mul j d k
82end
83put NA k v
84put NH k nsoft v
85end
86end
87fn nhidden to void
88for k ulong 8
89v = get NP add 39 k
90for j ulong 3
91v = add v mul get NH j get NP add 15 add mul j 8 k
92end
93put NU k v
94put NV k nrelu v
95end
96end
97fn nrecv to void
98d = get NSH 1
99if eq get NSH 0 2
100nhidden
101end
102for j ulong 4
103v = 0.0f64
104if eq get NSH 0 2
105v = get NP add 79 j
106for k ulong 8
107v = add v mul get NV k get NP add 47 add mul k 4 j
108end
109else
110v = get NP add mul 9 d j
111for k ulong d
112v = add v mul get NH k get NP add mul 5 d add mul k 4 j
113end
114end
115put NZ j v
116put NO j mul 0.5f64 add 1.0f64 nsoft v
117end
118end
119fn nloss to f64
120v = 0.0f64
121for j ulong 4
122r = sub get NO j get NT j
123v = add v mul r r
124end
125ret v
126end
127fn ngout j ulong to f64
128ret mul sub get NO j get NT j nslope get NZ j
129end
130fn ngaff to void
131d = get NSH 1
132for j ulong 4
133v = ngout j
134put NG add mul 9 d j v
135for k ulong d
136p = add mul 5 d add mul k 4 j
137put NG p mul v get NH k
138put ND k add get ND k mul v get NP p
139end
140end
141end
142fn ngnon to void
143for j ulong 4
144v = ngout j
145put NG add 79 j v
146for k ulong 8
147p = add 47 add mul k 4 j
148put NG p mul v get NV k
149put NE k add get NE k mul v get NP p
150end
151end
152for k ulong 8
153v = 0.0f64
154note ReLU subgradient is exactly zero at zero.
155if gt get NU k 0.0f64
156v = get NE k
157end
158put NG add 39 k v
159for j ulong 3
160p = add 15 add mul j 8 k
161put NG p mul v get NH j
162put ND j add get ND j mul v get NP p
163end
164end
165end
166fn ngrad to void
167for i ulong get NSH 2
168put NG i 0.0f64
169end
170for k ulong 4
171put ND k 0.0f64
172end
173for k ulong 8
174put NE k 0.0f64
175end
176if eq get NSH 0 2
177ngnon
178else
179ngaff
180end
181d = get NSH 1
182for k ulong d
183v = mul get ND k nslope get NA k
184put NG add mul 4 d k v
185for j ulong 4
186put NG add mul j d k mul v get NX j
187end
188end
189end
190fn nstep lr f64 to int
191if not and ge lr 0.0f64 le lr 1.0f64
192ret 1
193end
194for i ulong get NSH 2
195v = sub get NP i mul lr get NG i
196if not le fabs v 1000000.0f64
197ret 2
198end
199put NC i v
200end
201note No parameter mutation until every candidate has passed admission.
202for i ulong get NSH 2
203put NP i get NC i
204end
205put NSH 3 add get NSH 3 1
206ret 0
207end
208fn ntrain mask ulong to int
209if eq get NSH 0 3
210ret 0
211end
212for epoch ulong 2000
213for id ulong 16
214if ne and shr mask id 1 0
215ninput id id
216nsend
217nrecv
218ngrad
219rc = nstep 0.1f64
220if ne rc 0
221ret rc
222end
223end
224end
225end
226ret 0
227end
228
229note SPDX-License-Identifier: AGPL-3.0-only
230note FINAL-C32 payload is actual little-endian bytes, not merely declared precision.
231global WB uchar 32
232global WI uchar 729
233global WH f64 4
234global AR uchar 32
235global CFG ulong 4
236text COM ","
237text NL "\n"
238text CT "C,1,"
239text PT "P,"
240text RT "R,"
241text TT "T,"
242text DONE "END\n"
243
244fn outnum n ulong to void
245v = n
246i = ulong 32
247while gt i 0 bound 33
248i = sub i 1
249put AR i uchar add rem v 10 48
250v = div v 10
251if eq v 0
252break
253end
254end
255z = write 1 AR i sub 32 i
256if ne z long sub 32 i
257exit 80
258end
259end
260fn sep to void
261z = write 1 COM 0 1
262if ne z 1
263exit 80
264end
265end
266fn newline to void
267z = write 1 NL 0 1
268if ne z 1
269exit 80
270end
271end
272fn field n ulong to void
273outnum n
274sep
275end
276fn argnum ix ulong to ulong
277n = argread ix AR 0 32
278if or le n 0 gt n 10
279exit 90
280end
281v = ulong 0
282for i ulong ulong n
283c = get AR i
284if or lt c 48 gt c 57
285exit 90
286end
287v = add mul v 10 ulong sub c 48
288end
289ret v
290end
291fn wput k ulong v ulong to void
292for b ulong 8
293put WB add mul k 8 b uchar and shr v mul b 8 255
294end
295end
296fn wget k ulong to ulong
297v = ulong 0
298for b ulong 8
299v = or v shl ulong get WB add mul k 8 b mul b 8
300end
301ret v
302end
303fn iload off ulong to ulong
304v = ulong 0
305for b ulong 8
306v = or v shl ulong get WI add off b mul b 8
307end
308ret v
309end
310fn npack to void
311for b ulong 32
312put WB b uchar 0
313end
314if eq get NSH 0 3
315put WB 0 uchar get CFG 3
316else
317for k ulong get NSH 1
318wput k bitcast ulong get NH k
319end
320end
321end
322fn ndecode schema ulong dim ulong bytes ulong codec ulong to int
323if ne schema 1
324ret 2
325end
326if or ne dim get NSH 1 ne bytes wirelen
327ret 2
328end
329if eq get NSH 0 3
330if gt get WB 0 15
331ret 2
332end
333for j ulong 4
334put NO j f64 and shr ulong get WB 0 j 1
335end
336ret 0
337end
338for k ulong dim
339v = bitcast f64 wget k
340if not le fabs v 1.0f64
341ret 2
342end
343put WH k v
344end
345note All coordinates validated before changing receiver state or output.
346for k ulong dim
347put NH k get WH k
348end
349if eq codec 2
350ncodec
351else
352nrecv
353end
354ret 0
355end
356fn wirelen to ulong
357if eq get NSH 0 3
358ret 1
359end
360ret mul get NSH 1 8
361end
362fn npert q ulong to void
363if eq get NSH 0 3
364if eq q 3
365put WB 0 xor get WB 0 uchar 1
366end
367if eq q 4
368v = ulong get WB 0
369v = or and v 12 or shl and v 1 1 shr and v 2 1
370put WB 0 uchar v
371end
372if eq q 5
373put WB 0 uchar 0
374end
375ret
376end
377for k ulong get NSH 1
378v = bitcast f64 wget k
379if or eq q 1 eq q 2
380factor = 16.0f64
381if eq q 2
382factor = 32.0f64
383end
384r = div f64 long add mul fabs v factor 0.5f64 factor
385if lt v 0.0f64
386r = neg r
387end
388v = r
389end
390if and eq q 3 eq k 0
391v = neg v
392end
393if eq q 5
394v = 0.0f64
395end
396wput k bitcast ulong v
397end
398if eq q 4
399v = wget 0
400wput 0 wget 1
401wput 1 v
402end
403end
404fn nload to int
405n = ulong 0
406while lt n 729 bound 730
407z = read 0 WI n sub 729 n
408if lt z 0
409ret 2
410end
411if eq z 0
412break
413end
414n = add n ulong z
415end
416if ne n add 64 mul get NSH 2 8
417ret 2
418end
419if or ne iload 0 1 ne iload 8 get NSH 0
420ret 2
421end
422if or ne iload 16 get NSH 1 ne iload 24 get NSH 2
423ret 2
424end
425if or ne iload 32 get CFG 0 ne iload 40 get CFG 1
426ret 2
427end
428if or ne iload 56 0 gt iload 48 32000
429ret 2
430end
431for i ulong get NSH 2
432v = bitcast f64 iload add 64 mul i 8
433if not le fabs v 1000000.0f64
434ret 2
435end
436put NC i v
437end
438for i ulong get NSH 2
439put NP i get NC i
440end
441put NSH 3 iload 48
442ret 0
443end
444fn nconstruct mode ulong to int
445for i ulong get NSH 2
446put NP i 0.0f64
447end
448if eq mode 1
449if ne get NSH 0 1
450ret 2
451end
452for j ulong 4
453put NP add mul j 4 j 2.0f64
454put NP add 16 j -1.0f64
455put NP add 20 add mul j 4 j 1.0f64
456end
457ret 0
458end
459if or ne get NSH 0 2 not or eq mode 2 eq mode 3
460ret 2
461end
462if eq mode 2
463ret 0
464end
465put NP 0 2.0f64
466put NP 3 1.0f64
467put NP 7 1.0f64
468put NP 11 1.0f64
469put NP 15 1.0f64
470put NP 16 1.0f64
471put NP 17 1.0f64
472put NP 26 1.0f64
473put NP 35 1.0f64
474put NP 40 -0.5f64
475put NP 41 neg div 2.0f64 3.0f64
476put NP 51 12.0f64
477put NP 55 -12.0f64
478put NP 48 4.0f64
479put NP 52 -16.0f64
480put NP 56 36.0f64
481put NP 61 4.0f64
482put NP 66 4.0f64
483for j ulong 4
484put NP add 79 j -1.0f64
485end
486ret 0
487end
488fn ncodec to void
489t = mul get NH 0 3.0f64
490a = nrelu sub t 1.0f64
491b = nrelu sub t 2.0f64
492put NO 0 sub a b
493put NO 1 add sub t mul 2.0f64 a mul 2.0f64 b
494put NO 2 get NH 1
495put NO 3 get NH 2
496end
497fn codeenc to void
498put NH 0 div add mul 2.0f64 get NX 0 get NX 1 3.0f64
499put NH 1 get NX 2
500put NH 2 get NX 3
501end
502
503note SPDX-License-Identifier: AGPL-3.0-only
504note Frozen NL6-NL1R-20261028-1; imports unchanged capacity.om and wire.om.
505note TC is shared task, seed, split; receiver reads only task plus explicit context.
506global TC ulong 3
507global TL ulong 1
508
509fn tpar id ulong to ulong
510ret and xor xor id shr id 1 xor shr id 2 shr id 3 1
511end
512fn tactive j ulong to bool
513if eq get TC 0 1
514ret eq j 0
515end
516if eq get TC 0 2
517ret ge j 2
518end
519ret true
520end
521fn tprep id ulong to void
522ninput id id
523if eq get TC 0 1
524put NT 0 f64 tpar id
525end
526nsend
527nrecv
528note Inactive residuals are zero; their targets are not learned or communicated.
529for j ulong 4
530if not tactive j
531put NT j get NO j
532end
533end
534end
535fn tloss id ulong to f64
536tprep id
537ret nloss
538end
539fn ttrain mask ulong to int
540for epoch ulong 2000
541for id ulong 16
542if ne and shr mask id 1 0
543tprep id
544ngrad
545rc = nstep 0.1f64
546if ne rc 0
547ret rc
548end
549end
550end
551end
552ret 0
553end
554fn tclear to void
555for i ulong 32
556put WB i uchar 0
557end
558put TL 0 0
559end
560fn tencode id ulong arm ulong variant ulong to int
561tclear
562if or gt id 15 or gt arm 4 gt variant 2
563ret 2
564end
565if or eq variant 2 eq arm 3
566ret 0
567end
568src = id
569if eq variant 1
570src = and add id 1 15
571end
572if eq arm 0
573v = src
574if eq get TC 0 1
575v = tpar src
576end
577if eq get TC 0 2
578v = shr src 2
579end
580put WB 0 uchar v
581put TL 0 1
582ret 0
583end
584if eq arm 4
585for j ulong 4
586put WB j uchar add and shr src j 1 48
587end
588put TL 0 4
589ret 0
590end
591ninput src src
592nsend
593v = ulong 0
594for j ulong 4
595h = get NH j
596if not le fabs h 1.0f64
597ret 2
598end
599q = ulong 0
600if eq arm 1
601note Exact frozen inference quantizer; not a straight-through training rule.
602r = add div mul 3.0f64 add h 1.0f64 2.0f64 0.5f64
603q = ulong r
604if gt q 3
605q = 3
606end
607v = or v shl q mul j 2
608else
609if ge h 0.0f64
610q = 1
611end
612v = or v shl q j
613end
614end
615put WB 0 uchar v
616put TL 0 1
617ret 0
618end
619fn tcanon context ulong to void
620if eq get TC 0 1
621for j ulong 3
622put NO add j 1 0.0f64
623end
624end
625if eq get TC 0 2
626put NO 0 f64 and context 1
627put NO 1 f64 and shr context 1 1
628end
629end
630fn tbits value ulong context ulong to void
631for j ulong 4
632put NO j f64 and shr value j 1
633end
634tcanon context
635end
636fn tvalid arm ulong variant ulong context ulong bytes ulong to bool
637if or gt get TC 0 2 or gt arm 4 gt variant 2
638ret false
639end
640if eq variant 2
641ret false
642end
643if eq get TC 0 2
644if gt context 3
645ret false
646end
647else
648if ne context 0
649ret false
650end
651end
652want = ulong 1
653if eq arm 3
654want = 0
655end
656if eq arm 4
657want = 4
658end
659ret eq bytes want
660end
661fn tdecode schema ulong arm ulong variant ulong context ulong bytes ulong effect ulong to int
662note No sample ID, sender NX/NT, or training mask is consulted by this receiver.
663if or ne schema 2 ne effect 0
664ret 2
665end
666if or ne get NSH 0 1 or ne get NSH 1 4 ne get NSH 2 40
667ret 2
668end
669if not tvalid arm variant context bytes
670ret 2
671end
672v = ulong get WB 0
673if eq arm 0
674limit = ulong 15
675if eq get TC 0 1
676limit = 1
677end
678if eq get TC 0 2
679limit = 3
680end
681if gt v limit
682ret 2
683end
684if eq get TC 0 2
685v = shl v 2
686end
687tbits v context
688ret 0
689end
690if eq arm 4
691v = 0
692for j ulong 4
693c = get WB j
694if not or eq c 48 eq c 49
695ret 2
696end
697v = or v shl ulong sub c 48 j
698end
699if eq get TC 0 1
700v = tpar v
701end
702tbits v context
703ret 0
704end
705if and eq arm 2 gt v 15
706ret 2
707end
708for j ulong 4
709h = 0.0f64
710if eq arm 1
711q = and shr v mul j 2 3
712h = div sub mul 2.0f64 f64 q 3.0f64 3.0f64
713end
714if eq arm 2
715h = sub mul 2.0f64 f64 and shr v j 1 1.0f64
716end
717put WH j h
718end
719note All schema, context, shape and bytes validated before output/state commit.
720for j ulong 4
721put NH j get WH j
722end
723nrecv
724tcanon context
725ret 0
726end
727fn tabst rc int to ulong
728if ne rc 0
729ret 1
730end
731for j ulong 4
732if and tactive j lt fabs sub get NO j 0.5f64 0.1f64
733ret 1
734end
735end
736ret 0
737end
738
739note SPDX-License-Identifier: AGPL-3.0-only
740text TCH "C,2,"
741fn thead to void
742z = write 1 TCH 0 len TCH
743if ne z long len TCH
744exit 80
745end
746field get TC 0
747field get TC 1
748field get TC 2
749field 4
750field 40
751field get NSH 3
752outnum 0
753newline
754for i ulong 40
755z = write 1 PT 0 len PT
756if ne z long len PT
757exit 80
758end
759field i
760outnum bitcast ulong get NP i
761newline
762end
763end
764fn trow id ulong arm ulong variant ulong enc long dec long rc int to void
765z = write 1 RT 0 len RT
766if ne z long len RT
767exit 80
768end
769field id
770field arm
771field variant
772field get TL 0
773for i ulong 32
774field ulong get WB i
775end
776for j ulong 4
777field bitcast ulong get NO j
778end
779for j ulong 4
780p = ulong 0
781if ge get NO j 0.5f64
782p = 1
783end
784field p
785end
786field tabst rc
787field ulong enc
788field ulong dec
789field ulong rc
790context = ulong 0
791if eq get TC 0 2
792context = and id 3
793end
794field context
795outnum 0
796newline
797end
798fn tcases to int
799for id ulong 16
800context = ulong 0
801if eq get TC 0 2
802context = and id 3
803end
804for arm ulong 5
805for variant ulong 3
806start = monons
807rc = tencode id arm variant
808if ne rc 0
809ret rc
810end
811mid = monons
812note Refused raw records are canonical zeros; decoder itself is atomic on refusal.
813for j ulong 4
814put NO j 0.0f64
815end
816rc = tdecode 2 arm variant context get TL 0 0
817finish = monons
818if eq variant 2
819if ne rc 2
820ret 71
821end
822else
823if ne rc 0
824ret rc
825end
826end
827trow id arm variant sub mid start sub finish mid rc
828end
829end
830end
831ret 0
832end
833fn main to int
834if ne argcnt 4
835ret 90
836end
837task = argnum 1
838seed = argnum 2
839mask = argnum 3
840if or gt task 2 or eq seed 0 gt seed 4294967295
841ret 90
842end
843if or eq mask 0 gt mask 65535
844ret 90
845end
846put TC 0 task
847put TC 1 seed
848put TC 2 mask
849rc = nshape 1
850if ne rc 0
851ret rc
852end
853ninit seed
854start = monons
855rc = ttrain mask
856finish = monons
857if ne rc 0
858ret rc
859end
860thead
861rc = tcases
862if ne rc 0
863ret rc
864end
865note T is measured training only; per-row encode/decode and judge costs are separate.
866z = write 1 TT 0 len TT
867if ne z long len TT
868ret 80
869end
870field ulong start
871outnum ulong finish
872newline
873z = write 1 DONE 0 len DONE
874if ne z long len DONE
875ret 80
876end
877ret 0
878end