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 / omegese45 / core / cli.om

440 lines · 6794 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note oe45core command line (aien-train #45, pipeline lane); docs/omegese45/CORE-CLI.md.
3note Build order: SHA unit (export words removed), vocab.om, msg.om, core/model.om,
4note core/ckpt.om, core/run.om, core/cli.om.
5note init CKDIR TRAIN.ids SEED P1 TOTAL ORDER LRSH step-0 checkpoint (lr = 2^-LRSH)
6note train CKDIR TRAIN.ids UNTIL EVERY resume and train to step UNTIL
7note evaldev CKDIR DEV.ids dev metrics line
8note decode CKDIR U|G EPFILE one message line; rc 0 50 53 (40 prefix)
9note batch CKDIR U|G INFILE OUTFILE one result line per prefix; rc 0
10note info CKDIR header line of the loaded slot
11note Exits: 0 ok, 2 usage or malformed data file, 40 invalid prefix, 50 DECODE_INVALID,
12note 51 CKPT_REFUSED, 52 CKPT_VOCAB, 53 DECODE_BUDGET, 54 training data differs from the
13note checkpoint binding, 70 file I/O.
14const OPOBN ulong 4194304
15global opob uchar 4194305
16global opon ulong 1
17global opcm uchar 16
18text ophd "oe45 v1\n"
19text opdl "D "
20text opil "I "
21
22note --- output buffer (batch) ---
23fn opoc c uchar to void
24n = get opon 0
25if ge n OPOBN
26exit 2
27end
28put opob n c
29put opon 0 add n 1
30end
31
32fn opon10 v ulong to void
33b = new uchar 24 0
34p = ulong 24
35if eq v 0
36opoc 48
37ret
38end
39while gt v 0 bound 24
40p = sub p 1
41put b p uchar add 48 rem v 10
42v = div v 10
43end
44for i ulong sub 24 p
45opoc get b add p i
46end
47end
48
49note Word of id into the buffer; digits follow `0x` or a digit without a space.
50fn opow id ulong pv ulong first bool to void
51dg = and ge id 25 lt id OPV
52if not or first and dg ge pv 24
53opoc 32
54end
55o = get ocwo id
56for j ulong get ocwl id
57opoc get ocvtsv add o j
58end
59end
60
61note Emitted ids opseq[s, s + n) as words.
62fn opowds s ulong n ulong to void
63pv = ulong 0
64for i ulong n
65id = ulong get opseq add s i
66opow id pv eq i 0
67pv = id
68end
69end
70
71note --- prefix parsing ---
72note Parse the OE45 v1 prefix in opdb[a, b) into opseq / opsl. The first line must be
73note `oe45 v1`; each further line one message valid under the contract validator; the
74note sequence G (A R)* or G followed by a final `act refuse C end` (interface ยง3: a refuse
75note comes only right after G and gets no R; its P is decoded next). Ends in G, R or that
76note refuse A (kind 5 below). 0 or 40.
77fn opprefix a ulong b ulong to ulong
78if not ophdr a b
79ret 40
80end
81p = add a 8
82n = ulong 0
83lk = ulong 0
84while lt p b bound 200
85e = p
86while and lt e b ne get opdb e 10 bound 4097
87e = add e 1
88end
89if or ge e b gt sub e p 4095
90ret 40
91end
92for i ulong sub e p
93put ocin i get opdb add p i
94end
95k = ocvline sub e p 0
96if lt k 0
97ret 40
98end
99c = get ocnids 0
100if not opnextk lk ulong k
101ret 40
102end
103if and and eq k 2 eq get ocids 1 9 ne lk 1
104ret 40
105end
106if gt add n c OPMAXL
107ret 40
108end
109for i ulong c
110put opseq add n i uchar get ocids i
111end
112n = add n c
113lk = ulong k
114if and eq k 2 eq get ocids 1 9
115lk = ulong 5
116end
117p = add e 1
118end
119if not or or eq lk 1 eq lk 3 eq lk 5
120ret 40
121end
122put opsl 0 n
123ret 0
124end
125
126note Kind k may follow kind lk in a prefix (0 = nothing yet; 5 = a refuse A, which ends it).
127fn opnextk lk ulong k ulong to bool
128if eq lk 0
129ret eq k 1
130end
131if or eq lk 1 eq lk 3
132ret eq k 2
133end
134if eq lk 2
135ret eq k 3
136end
137ret false
138end
139
140fn ophdr a ulong b ulong to bool
141if gt add a 8 b
142ret false
143end
144for i ulong 8
145if ne get opdb add a i get ophd i
146ret false
147end
148end
149ret true
150end
151
152note --- subcommands ---
153fn opmode i ulong to ulong
154n = argread i opcm 0 16
155if ne n 1
156exit 2
157end
158m = ulong get opcm 0
159if not or eq m 85 eq m 71
160exit 2
161end
162ret m
163end
164
165fn opcinit to int
166if ne argcnt 9
167exit 2
168end
169opckdir 2
170opldat 3
171put opmeta 0 opdecu 4
172put opmeta 3 opdecu 5
173put opmeta 4 opdecu 6
174put opmeta 5 opdecu 7
175sh = opdecu 8
176if or eq sh 0 gt sh 30
177exit 2
178end
179put opmeta 6 shl sub 127 sh 23
180put opmeta 7 1
181put opmeta 1 0
182put opmeta 2 0
183for s ulong 2
184n = opslp s
185r = unlink opckp 0 n
186end
187opinit get opmeta 0
188opvpin
189opsave
190ret 0
191end
192
193fn opbind to void
194d = new uchar 32 0
195for i ulong 32
196put d i get optds i
197end
198ophdat
199for i ulong 32
200if ne get optds i get d i
201exit 54
202end
203end
204end
205
206fn opctrain to int
207if ne argcnt 6
208exit 2
209end
210opckdir 2
211opload
212opread 3
213opindex
214opbind
215until = opdecu 4
216every = opdecu 5
217if eq every 0
218exit 2
219end
220optrain until every
221ret 0
222end
223
224fn opcdev to int
225if ne argcnt 4
226exit 2
227end
228opckdir 2
229opload
230opldat 3
231for i ulong 16
232put opst i 0
233end
234n = get opne 0
235for e ulong n
236opepi e
237opdevep
238end
239w = write 1 opdl 0 2
240ocputn get opmeta 1
241ocputc 32
242ocputn n
243for i ulong 5
244ocputc 32
245ocputn get opst add i 1
246end
247ocputc 10
248ret 0
249end
250
251fn opcdec to int
252if ne argcnt 5
253exit 2
254end
255opckdir 2
256md = opmode 3
257opread 4
258r = opprefix 0 get opdn 0
259if ne r 0
260exit 40
261end
262opload
263n = get opsl 0
264r = opdecode n md
265if ne r 0
266exit int r
267end
268c = get opln 0
269for i ulong c
270put ocids i ulong get opseq add n i
271end
272b = ocdec c
273if lt b 0
274exit 50
275end
276w = write 1 ocout 0 ulong b
277ocputc 10
278ret 0
279end
280
281note Next prefix start after a: the next line `oe45 v1` at a line start, or b.
282fn opnextp a ulong b ulong to ulong
283if ge add a 1 b
284ret b
285end
286for q ulong sub b add a 1
287p = add add a 1 q
288if eq get opdb sub p 1 10
289if ophdr p b
290ret p
291end
292end
293end
294ret b
295end
296
297fn opcbat to int
298if ne argcnt 6
299exit 2
300end
301opckdir 2
302md = opmode 3
303opload
304opread 4
305b = get opdn 0
306a = ulong 0
307while lt a b bound 100000
308e = opnextp a b
309r = opprefix a e
310if ne r 0
311opon10 40
312opoc 10
313else
314opbline md
315end
316a = e
317end
318n = oppath 5
319fd = int fopen opfp 0 n 577 420
320if lt fd 0
321exit 70
322end
323p = ulong 0
324while lt p get opon 0 bound 5000
325w = write fd opob p sub get opon 0 p
326if le w 0
327exit 70
328end
329p = add p ulong w
330end
331if ne fsync fd 0
332exit 70
333end
334if ne fclose fd 0
335exit 70
336end
337ret 0
338end
339
340note One batch result line for the parsed prefix.
341fn opbline md ulong to void
342n = get opsl 0
343r = opdecode n md
344c = get opln 0
345if eq r 0
346opoc 111
347opoc 107
348opoc 32
349for i ulong c
350put ocids i ulong get opseq add n i
351end
352b = ocdec c
353for i ulong ulong b
354opoc get ocout i
355end
356else
357opoc 101
358opoc 114
359opoc 114
360opoc 32
361opon10 r
362if gt c 0
363opoc 32
364opowds n c
365end
366end
367opoc 10
368end
369
370fn opcinfo to int
371if ne argcnt 3
372exit 2
373end
374opckdir 2
375opload
376w = write 1 opil 0 2
377ocputc add 97 uchar get opslt 0
378for i ulong 8
379ocputc 32
380ocputn get opmeta i
381end
382ocputc 32
383for i ulong 32
384opphex get opck add 112 i
385end
386ocputc 32
387for i ulong 32
388opphex get opck add 8 i
389end
390ocputc 32
391for i ulong 32
392opphex get opck add 144 i
393end
394ocputc 10
395ret 0
396end
397
398fn opphex v uchar to void
399opnib shr v 4
400opnib and v 15
401end
402
403fn opnib v uchar to void
404if lt v 10
405ocputc add v 48
406else
407ocputc add v 87
408end
409end
410
411fn main to int
412if lt argcnt 2
413exit 2
414end
415n = argread 1 opcm 0 16
416if lt n 4
417exit 2
418end
419c0 = get opcm 0
420c1 = get opcm 1
421if eq c0 105
422if eq get opcm 2 105
423ret opcinit
424end
425ret opcinfo
426end
427if eq c0 116
428ret opctrain
429end
430if eq c0 101
431ret opcdev
432end
433if eq c0 100
434ret opcdec
435end
436if eq c0 98
437ret opcbat
438end
439exit 2
440end