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 / si19 / selmain.om

622 lines · 10644 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note aien-train#25 ORIG-2 driver. First stdin byte selects the mode.
3note T train: config (64 bytes = 8 LE words: kind, seed, lr code 0|8|10|12, max epochs,
4note patience, control, stop-at epoch, eval partition flags bit0 TRAIN bit1 DEV bit2 TEST,
5note bit3 = v2 admission: ORIG1-CONTRACT-v2.md, oxadm2, workload-family splits 0 TRAIN,
6note 1 VALIDATION, 2 HELD-OUT; the image records it in SS[20]), then the allow-list block
7note (4096 bytes, zero padded), then omexp-v1 records to EOF.
8note Admission: config -> allow-list status -> oxload|oxadm2 -> train -> image on fd 3 ->
9note key=value report on stdout (-> evaluation of the flagged partitions with SB).
10note R resume: config, allow-list, one image (length fixed by the config kind), records.
11note E evaluate: like R without training and without an image; sleval per flagged partition
12note per core class (0, 1, 2, 3 = all) on stdout, per-record lines on fd 4:
13note seq fam core M N model rule ref static near oracle cost_model cost_oracle
14note cost_rule cost_ref cost_static cost_near; v2 appends press calls split cell.
15note R and E refuse (68) an image whose SS[20] differs from the config's v2 bit.
16note C compare two images of one kind byte for byte: exit 0 identical, 1 different.
17note G fixture: 16 bytes (seed, count), SYNTHETIC records to fd 3, identity on stdout.
18note Exit: 64 bad mode, 65 image refused, 66 dataset refused, 67 unauthorized, 68 config
19note invalid, 74 I/O, 86 non-finite update (from slstep).
20global SM uchar 1
21global SK uchar 64
22global SD uchar 24
23text MREF "SELECT checkpoint refused status=-"
24text MDAT "SELECT dataset refused status=-"
25text MUNA "SELECT dataset unauthorized status=-"
26text MIDN "SELECT_IDENTICAL bytes="
27text MDIF "SELECT_DIFFERENT first_byte="
28text MKIN "kind="
29text MNPA "nparams="
30text MSEE "seed="
31text MIFN "init_fnv="
32text MLR "lr="
33text MLRB "lr_bits="
34text MCTL "control="
35text MEPO "epochs="
36text MUPD "updates="
37text MCUR "cursor="
38text MMU "mu16="
39text MSH "sh="
40text MNTR "ntrain="
41text MTLS "train_loss_sum="
42text MTLD "train_loss_dec="
43text MDLS "dev_loss_sum="
44text MDLD "dev_loss_dec="
45text MBEP "best_epoch="
46text MSTL "stale_epochs="
47text MFFN "final_params_fnv="
48text MBFN "best_params_fnv="
49text MDFN "data_fnv="
50text MREC "records="
51text MIMB "image_bytes="
52text MIMF "image_fnv="
53text MALW "allow="
54text MSTA "status=ok"
55text MBND "data_bound=yes"
56text MUNB "data_bound=no"
57text MEVL "eval part="
58text MCOR " core="
59text MCOL "eval_columns=n model oracle rule ref static near affine top1 win_rule loss_rule win_near loss_near win_static loss_static win_ref loss_ref"
60text MGB "bytes="
61text MGL "load_status="
62text MFNV "fnv="
63text MBIG "big"
64text MNEG "-"
65text MSP " "
66text MNL "\n"
67text MV2 "v2_admitted="
68text MV2T " train="
69text MV2V " validation="
70text MV2H " heldout="
71text MV2R " refused="
72
73fn snl to void
74w = write 1 MNL 0 1
75end
76
77fn ssp to void
78w = write 1 MSP 0 1
79end
80
81fn skw i ulong to ulong
82note Config word i (little-endian) from SK.
83v = ulong 0
84for k ulong 8
85v = or v shl ulong get SK add mul i 8 k mul k 8
86end
87ret v
88end
89
90fn snum fd int n ulong to void
91note Decimal ulong to any fd through the driver's own digit buffer.
92p = ulong 24
93if eq n 0
94p = 23
95put SD 23 48
96end
97while gt n 0 bound 24
98p = sub p 1
99put SD p uchar add 48 rem n 10
100n = div n 10
101end
102w = write fd SD p sub 24 p
103if ne w long sub 24 p
104exit 74
105end
106end
107
108fn ssnum x long to void
109if lt x 0
110w = write 1 MNEG 0 1
111x = neg x
112end
113wnum ulong x
114end
115
116fn sdec x ulong to void
117note Binary32 bits as a signed decimal; magnitudes of 2^33 and above print as big.
118if ne and x 2147483648 0
119w = write 1 MNEG 0 1
120x = and x 2147483647
121end
122if ge and shr x 23 255 160
123w = write 1 MBIG 0 len MBIG
124ret
125end
126wdec x
127end
128
129fn srdcfg n ulong to ulong
130o = ulong 0
131while lt o n bound 64
132r = read 0 SK o sub n o
133if lt r 0
134exit 74
135end
136if eq r 0
137ret o
138end
139o = add o ulong r
140end
141ret o
142end
143
144fn srdlb to ulong
145note The allow-list block: 4096 bytes, zero padded; returns the used length.
146o = ulong 0
147while lt o 4096 bound 4096
148r = read 0 LB o sub 4096 o
149if lt r 0
150exit 74
151end
152if eq r 0
153ret o
154end
155o = add o ulong r
156end
157n = ulong 0
158for i ulong 4096
159if ne get LB i 0
160n = add i 1
161end
162end
163ret n
164end
165
166fn srdimg n ulong to ulong
167note Exactly up to n image bytes into SI[0..n); never reads past them.
168o = ulong 0
169while lt o n bound 999999
170r = read 0 SI o sub n o
171if lt r 0
172exit 74
173end
174if eq r 0
175ret o
176end
177o = add o ulong r
178end
179ret o
180end
181
182fn srdrb to ulong
183note Records to end of input into RB; 524289 means more than the capacity arrived.
184o = ulong 0
185while lt o 524288 bound 999999
186r = read 0 RB o sub 524288 o
187if lt r 0
188exit 74
189end
190if eq r 0
191ret o
192end
193o = add o ulong r
194end
195r = read 0 SM 0 1
196if ne r 0
197ret 524289
198end
199ret o
200end
201
202fn swimg n ulong to void
203o = ulong 0
204while lt o n bound 999999
205w = write 3 SI o sub n o
206if le w 0
207exit 74
208end
209o = add o ulong w
210end
211end
212
213fn slrcode lr ulong to ulong
214if eq lr wmbits 1 8
215ret 8
216end
217if eq lr wmbits 1 10
218ret 10
219end
220if eq lr wmbits 1 12
221ret 12
222end
223ret 0
224end
225
226fn scfgok to bool
227note kind 1|2, lr code 0|8|10|12, epochs and stop <= 64, control <= 2, flags < 8.
228k = skw 0
229if or lt k 1 gt k 2
230ret false
231end
232k = skw 2
233if and ne k 0 and ne k 8 and ne k 10 ne k 12
234ret false
235end
236if or gt skw 3 64 gt skw 6 64
237ret false
238end
239if or gt skw 5 2 gt skw 7 15
240ret false
241end
242ret true
243end
244
245fn slrbits code ulong to ulong
246if eq code 0
247ret 0
248end
249ret wmbits 1 code
250end
251
252fn skv1 to void
253w = write 1 MKIN 0 len MKIN
254wnum get SS 0
255snl
256w = write 1 MNPA 0 len MNPA
257wnum get SS 15
258snl
259w = write 1 MSEE 0 len MSEE
260wnum get SS 2
261snl
262w = write 1 MIFN 0 len MIFN
263wnum get SS 19
264snl
265w = write 1 MLR 0 len MLR
266wnum slrcode get SS 3
267snl
268w = write 1 MLRB 0 len MLRB
269wnum get SS 3
270snl
271w = write 1 MCTL 0 len MCTL
272wnum get SS 16
273snl
274w = write 1 MEPO 0 len MEPO
275wnum get SS 4
276snl
277w = write 1 MUPD 0 len MUPD
278wnum get SS 6
279snl
280w = write 1 MCUR 0 len MCUR
281wnum get SS 5
282snl
283end
284
285fn skv2 to void
286w = write 1 MMU 0 len MMU
287ssnum wsdec get SS 8
288snl
289w = write 1 MSH 0 len MSH
290wnum get SS 9
291snl
292w = write 1 MNTR 0 len MNTR
293wnum get SS 10
294snl
295w = write 1 MTLS 0 len MTLS
296wnum get SS 17
297snl
298w = write 1 MTLD 0 len MTLD
299sdec get SS 17
300snl
301w = write 1 MDLS 0 len MDLS
302wnum get SS 13
303snl
304w = write 1 MDLD 0 len MDLD
305sdec get SS 13
306snl
307w = write 1 MBEP 0 len MBEP
308wnum get SS 18
309snl
310w = write 1 MSTL 0 len MSTL
311wnum get SS 14
312snl
313end
314
315fn skv3 n ulong to void
316w = write 1 MFFN 0 len MFFN
317wnum slfnvp get SS 15
318snl
319w = write 1 MBFN 0 len MBFN
320wnum slfnvb get SS 15
321snl
322w = write 1 MDFN 0 len MDFN
323wnum get SS 11
324snl
325w = write 1 MREC 0 len MREC
326wnum get RC 0
327snl
328w = write 1 MIMB 0 len MIMB
329wnum n
330snl
331w = write 1 MIMF 0 len MIMF
332wnum sifnv 0 sub n 8
333snl
334end
335
336fn sreport n ulong to void
337skv1
338skv2
339skv3 n
340w = write 1 MSTA 0 len MSTA
341snl
342end
343
344fn scostcol r ulong a ulong to void
345w = write 4 MSP 0 1
346snum 4 oxcost r a
347end
348
349fn v2cols r ulong to void
350note The v2 columns of a per-record line: pressure, calls, split, workload family.
351w = write 4 MSP 0 1
352snum 4 oxpress r
353w = write 4 MSP 0 1
354snum 4 oxword r 7
355w = write 4 MSP 0 1
356snum 4 oxpart r
357w = write 4 MSP 0 1
358snum 4 oxcell r
359end
360
361fn srecline r ulong to void
362note One per-record line on fd 4 (the model uses the current SP).
363m = slpick r
364snum 4 oxseq r
365w = write 4 MSP 0 1
366snum 4 oxfam r
367w = write 4 MSP 0 1
368snum 4 oxcore r
369w = write 4 MSP 0 1
370snum 4 oxm r
371w = write 4 MSP 0 1
372snum 4 oxn r
373w = write 4 MSP 0 1
374snum 4 m
375w = write 4 MSP 0 1
376snum 4 oxrule r
377w = write 4 MSP 0 1
378snum 4 0
379w = write 4 MSP 0 1
380snum 4 slstat r
381w = write 4 MSP 0 1
382snum 4 slnear r
383w = write 4 MSP 0 1
384snum 4 oxbest r
385w = write 4 MSP 0 1
386snum 4 oxcost r m
387w = write 4 MSP 0 1
388snum 4 oxcost r oxbest r
389scostcol r oxrule r
390scostcol r 0
391scostcol r slstat r
392scostcol r slnear r
393if ne and skw 7 8 0
394v2cols r
395end
396w = write 4 MNL 0 1
397end
398
399fn sv2line to void
400w = write 1 MV2 0 len MV2
401wnum get RC 10
402w = write 1 MV2T 0 len MV2T
403wnum get RC 4
404w = write 1 MV2V 0 len MV2V
405wnum get RC 5
406w = write 1 MV2H 0 len MV2H
407wnum get RC 6
408w = write 1 MV2R 0 len MV2R
409wnum sub get RC 0 get RC 10
410snl
411end
412
413fn sevline part ulong core ulong to void
414slevalc part core
415w = write 1 MEVL 0 len MEVL
416wnum part
417w = write 1 MCOR 0 len MCOR
418wnum core
419for k ulong 17
420ssp
421wnum get SE k
422end
423snl
424end
425
426fn sevals flags ulong to void
427w = write 1 MCOL 0 len MCOL
428snl
429for p ulong 3
430if ne and shr flags p 1 0
431for c ulong 4
432sevline p c
433end
434for r ulong get RC 0
435if eq oxpart r p
436srecline r
437end
438end
439end
440end
441end
442
443fn sadmit n ulong lbn ulong to int
444note Allow-list status (67) then record admission (66); 0 when admitted.
445st = oxallow lbn oxfnv n
446if lt st 0
447w = write 1 MUNA 0 len MUNA
448wnum ulong neg long st
449snl
450ret 67
451end
452w = write 1 MALW 0 len MALW
453wnum ulong st
454snl
455if eq and skw 7 8 0
456st = oxload n
457else
458st = oxadm2 n
459end
460if ne st 0
461w = write 1 MDAT 0 len MDAT
462wnum ulong neg long st
463snl
464ret 66
465end
466if ne and skw 7 8 0
467sv2line
468end
469ret 0
470end
471
472fn srun m ulong to int
473note T (84), R (82) and E (69): read the stream in admission order, then act.
474if ne srdcfg 64 64
475ret 68
476end
477if not scfgok
478ret 68
479end
480lbn = srdlb
481img = ulong 0
482if ne m 84
483img = sllen skw 0
484if ne srdimg img img
485ret 65
486end
487end
488n = srdrb
489if gt n 524288
490ret 66
491end
492st = sadmit n lbn
493if ne st 0
494ret st
495end
496if eq m 84
497slinit skw 0 skw 1 slrbits skw 2 skw 5
498if ne and skw 7 8 0
499put SS 20 1
500end
501slnorm
502else
503if eq m 69
504st = sladmit 0 img
505else
506st = slload 0 img
507end
508if ne st 0
509w = write 1 MREF 0 len MREF
510wnum ulong neg long st
511snl
512ret 65
513end
514if ne get SS 0 skw 0
515ret 68
516end
517if ne get SS 20 shr and skw 7 8 3
518ret 68
519end
520if eq m 69
521if slbound 0
522w = write 1 MBND 0 len MBND
523else
524w = write 1 MUNB 0 len MUNB
525end
526snl
527end
528end
529if ne m 69
530sltrain skw 3 skw 4 skw 6
531img = slsave 0
532swimg img
533end
534sreport img
535if ne skw 7 0
536slbest
537sevals skw 7
538end
539ret 0
540end
541
542fn scompare to int
543n = srdimg 32768
544if eq n 32768
545r = read 0 SM 0 1
546if ne r 0
547ret 1
548end
549end
550k = siget 16
551if or lt k 1 gt k 2
552ret 1
553end
554k = sllen k
555if ne n mul 2 k
556w = write 1 MDIF 0 len MDIF
557wnum n
558snl
559ret 1
560end
561for i ulong k
562if ne get SI i get SI add k i
563w = write 1 MDIF 0 len MDIF
564wnum i
565snl
566ret 1
567end
568end
569w = write 1 MIDN 0 len MIDN
570wnum k
571ssp
572w = write 1 MFNV 0 len MFNV
573wnum siget sub k 8
574snl
575ret 0
576end
577
578fn sgen to int
579if ne srdcfg 16 16
580ret 68
581end
582n = sxgen skw 0 skw 1
583o = ulong 0
584while lt o n bound 999999
585w = write 3 RB o sub n o
586if le w 0
587exit 74
588end
589o = add o ulong w
590end
591w = write 1 MREC 0 len MREC
592wnum skw 1
593snl
594w = write 1 MGB 0 len MGB
595wnum n
596snl
597w = write 1 MFNV 0 len MFNV
598wnum oxfnv n
599snl
600w = write 1 MGL 0 len MGL
601ssnum long oxload n
602snl
603ret 0
604end
605
606fn main to int
607r = read 0 SM 0 1
608if ne r 1
609ret 64
610end
611m = get SM 0
612if eq m 71
613ret sgen
614end
615if eq m 67
616ret scompare
617end
618if or eq m 84 or eq m 82 eq m 69
619ret srun ulong m
620end
621ret 64
622end