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 / tools / omegallm / wdrive / wrun.om

440 lines · 8611 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note wrun.om (DRA-187, lane wsp): arm runner. Composed after wbuild.om (its main renamed wbmain):
3note OMC=omc wbuild OUT/wrun tools/omegallm/wdrive/wbuild.om@wbmain tools/omegallm/wdrive/wrun.om
4note Usage: wrun ARMS OUTDIR
5note ARMS is plain text, one arm per line: NAME SPLIT MODE [ck=PATH] K L I A ... (blank lines and
6note lines starting with # are skipped). MODE is gen or probe; hooks are groups of four decimals, at
7note most 64 groups, passed through to wprobe, which judges them. Every line is checked before any arm runs.
8note For each arm whose OUTDIR/NAME.out does not exist it takes the pool lock LOCK (flock(2) exclusive,
9note polled every 10 ms for at most 7200 s, as `flock -w 7200 -o` did; a timeout counts as exit status
10note 1 and prints LOCK_TIMEOUT LOCK on stderr) and runs, with an empty environment and without the
11note lock descriptor,
12note /usr/bin/taskset -c POOL /usr/bin/nice -n 10 WPROBE gen CK MERGES 64 REC hooks
13note (probe: WPROBE probe CK MERGES REC hooks)
14note An arm with more than 48 hook words (execprog's 64 records less the 13 above) has them written to
15note OUTDIR/NAME.hooks, one line, and passed as the single last argument @OUTDIR/NAME.hooks (wprobe
16note with @PATH hooks, wprobe.om after 72d3377).
17note with stdout to OUTDIR/NAME.out.tmp, renamed to NAME.out on exit status 0 and to NAME.out.failed
18note otherwise, then appends to OUTDIR/runs.log and prints
19note RUN NAME SPLIT MODE RC WALL_MS START_UNIX_MS CK_SHA256 WPROBE_SHA256 OUT_SHA256 hooks...
20note (OUT_SHA256 is of NAME.out or NAME.out.failed). An existing NAME.out prints SKIP NAME.
21note Environment: HOME (required), POOL (default 19), LOCK (default HOME/handoffs/hive/queen/pool-POOL.lock),
22note WPROBE (default HOME/work/wsp/build/wprobe), CK (default HOME/.local/share/omega-tool-model/round40/
23note model.ck), MERGES (default beside it, merges.bin), SPLITS (default HOME/work/wsp/aien-train/evidence/
24note OMEGALLM/wsp-dra187-20261107/splits); REC is SPLITS/SPLIT.rec.
25note Exits: 0 every run arm exited 0, 1 some arm failed, 2 usage or a bad ARMS line (stderr names the
26note line), 70 I/O. Scoring is not part of wrun.
27
28note string slots (wdz, see wbuild.om): 0 HOME, 1 POOL, 2 LOCK, 3 WPROBE, 4 SPLITS, 5 CK, 6 MERGES,
29note 7 OUTDIR
30note wrtk: last token start, end. wrar: the parsed arm: 0 1 name, 2 3 split, 4 mode (1 gen, 2 probe),
31note 5 6 ck=PATH value (6 is 0 when absent), 7 position of the first hook, 8 hook count, 9 content end
32global wrtk ulong 2
33global wrar ulong 10
34global wrfail ulong 1
35text wrtwp "WPROBE"
36text wrtck "CK"
37text wrtmrg "MERGES"
38text wrtspl "SPLITS"
39text wrdwp "/work/wsp/build/wprobe"
40text wrdck "/.local/share/omega-tool-model/round40/model.ck"
41text wrdmrg "/.local/share/omega-tool-model/round40/merges.bin"
42text wrdspl "/work/wsp/aien-train/evidence/OMEGALLM/wsp-dra187-20261107/splits"
43text wrtgen "gen"
44text wrtprb "probe"
45text wrtcke "ck="
46text wrtout ".out"
47text wrttmp ".out.tmp"
48text wrtfld ".out.failed"
49text wrthk ".hooks"
50text wrtrec ".rec"
51text wrtlog "/runs.log"
52text wrt64 "64"
53text wrtrun "RUN "
54text wrtskip "SKIP "
55text wrtbad "BAD_ARM line "
56text wrtnl "\n"
57text wrtuse "usage: wrun ARMS OUTDIR (ARMS lines: NAME SPLIT gen|probe [ck=PATH] K L I A ...)\n"
58
59fn wrusage to void
60wdoclr
61wdot wrtuse
62wdoflush 2
63exit 2
64end
65
66fn wrsetup to void
67wdzpool
68wdzenv wrtwp 3 wrdwp
69wdzenv wrtspl 4 wrdspl
70wdzenv wrtck 5 wrdck
71wdzenv wrtmrg 6 wrdmrg
72wdpclr
73wdpa 2
74wdzsave 7
75end
76
77fn wrspace c ulong to bool
78ret or or eq c 32 eq c 9 eq c 13
79end
80
81note next token of wdsrc[p, e) into wrtk; false when none
82fn wrnext p ulong e ulong to bool
83i = p
84while lt i e bound 999999
85if not wrspace ulong get wdsrc i
86break
87end
88i = add i 1
89end
90if ge i e
91ret false
92end
93j = i
94while lt j e bound 999999
95if wrspace ulong get wdsrc j
96break
97end
98j = add j 1
99end
100put wrtk 0 i
101put wrtk 1 j
102ret true
103end
104
105note a name: 1..200 bytes of A-Z a-z 0-9 . _ - +, not starting with .
106fn wrisname s ulong e ulong to bool
107if or eq s e gt sub e s 200
108ret false
109end
110if eq get wdsrc s 46
111ret false
112end
113for i ulong sub e s
114c = ulong get wdsrc add s i
115a = or and ge c 65 le c 90 and ge c 97 le c 122
116d = and ge c 48 le c 57
117p = or or eq c 46 eq c 95 or eq c 45 eq c 43
118if not or or a d p
119ret false
120end
121end
122ret true
123end
124
125fn wrisnum s ulong e ulong to bool
126if or eq s e gt sub e s 20
127ret false
128end
129for i ulong sub e s
130c = ulong get wdsrc add s i
131if or lt c 48 gt c 57
132ret false
133end
134end
135ret true
136end
137
138note parse the line content wdsrc[s, e) into wrar: 0 blank or comment, 1 arm, 2 bad
139fn wrparse s ulong e ulong to ulong
140put wrar 9 e
141if not wrnext s e
142ret 0
143end
144if eq get wdsrc get wrtk 0 35
145ret 0
146end
147put wrar 0 get wrtk 0
148put wrar 1 get wrtk 1
149if not wrisname get wrtk 0 get wrtk 1
150ret 2
151end
152if not wrnext get wrtk 1 e
153ret 2
154end
155put wrar 2 get wrtk 0
156put wrar 3 get wrtk 1
157if not wrisname get wrtk 0 get wrtk 1
158ret 2
159end
160if not wrnext get wrtk 1 e
161ret 2
162end
163m = sub get wrtk 1 get wrtk 0
164put wrar 4 0
165if wbeq get wrtk 0 m wrtgen false
166put wrar 4 1
167end
168if wbeq get wrtk 0 m wrtprb false
169put wrar 4 2
170end
171if eq get wrar 4 0
172ret 2
173end
174ret wrhooks e
175end
176
177note the optional ck=PATH and the hooks after the mode token
178fn wrhooks e ulong to ulong
179p = get wrtk 1
180put wrar 6 0
181if wrnext p e
182m = sub get wrtk 1 get wrtk 0
183if and wbeq get wrtk 0 m wrtcke true gt m 3
184put wrar 5 add get wrtk 0 3
185put wrar 6 get wrtk 1
186p = get wrtk 1
187end
188end
189put wrar 7 p
190k = ulong 0
191while wrnext p e bound 999999
192if not wrisnum get wrtk 0 get wrtk 1
193ret 2
194end
195k = add k 1
196p = get wrtk 1
197end
198note at most 64 groups (wprobe's cap). execprog takes 64 records and gen uses 13 before the hooks,
199note so more than 48 words go through OUTDIR/NAME.hooks and wprobe's last argument @PATH
200if or ne rem k 4 0 gt k 256
201ret 2
202end
203put wrar 8 k
204ret 1
205end
206
207note OUTDIR/NAME followed by t
208fn wrpout t view uchar * to void
209wdpclr
210wdzp 7
211wdpc 47
212wdpb get wrar 0 sub get wrar 1 get wrar 0
213wdpt t
214end
215
216fn wrpck to void
217wdpclr
218if gt get wrar 6 0
219wdpb get wrar 5 sub get wrar 6 get wrar 5
220else
221wdzp 5
222end
223end
224
225fn wrcmd to void
226wdkpre
227wdpclr
228wdzp 3
229wdkp
230if eq get wrar 4 1
231wdkt wrtgen
232else
233wdkt wrtprb
234end
235wrpck
236wdkp
237wdpclr
238wdzp 6
239wdkp
240if eq get wrar 4 1
241wdkt wrt64
242end
243wdpclr
244wdzp 4
245wdpc 47
246wdpb get wrar 2 sub get wrar 3 get wrar 2
247wdpt wrtrec
248wdkp
249if gt get wrar 8 48
250wdpclr
251wdpc 64
252wdzp 7
253wdpc 47
254wdpb get wrar 0 sub get wrar 1 get wrar 0
255wdpt wrthk
256wdkp
257ret
258end
259p = get wrar 7
260e = get wrar 9
261while wrnext p e bound 999999
262wdpclr
263wdpb get wrtk 0 sub get wrtk 1 get wrtk 0
264wdkp
265p = get wrtk 1
266end
267end
268
269note OUTDIR/NAME.hooks: the arm's hook words, one line
270fn wrhookfile to void
271wrpout wrthk
272fd = wdopen 577 438
273if lt fd 0
274exit 70
275end
276wdoclr
277wrhookout
278wdot wrtnl
279wdowr fd
280c = fclose fd
281if ne c 0
282exit 70
283end
284wdoclr
285end
286
287note append wdsrc[s, e) to the output line
288fn wrob s ulong e ulong to void
289for j ulong sub e s
290wdoc ulong get wdsrc add s j
291end
292end
293
294fn wrshaline to void
295if not wdfsha
296exit 70
297end
298wdohex
299wdoc 32
300end
301
302note run the parsed arm
303fn wrarm to void
304wrpout wrtout
305if wdexists
306wdoclr
307wdot wrtskip
308wrob get wrar 0 get wrar 1
309wdot wrtnl
310wdoflush 1
311ret
312end
313if gt get wrar 8 48
314wrhookfile
315end
316wrpout wrttmp
317fo = wdopen 577 438
318if lt fo 0
319exit 70
320end
321wrcmd
322s0 = realns
323m0 = monons
324rc = wdpoolrun -1 fo -1
325c = fclose fo
326m1 = monons
327wdkclr
328wrpout wrttmp
329wdkp
330if eq rc 0
331wrpout wrtout
332else
333wrpout wrtfld
334put wrfail 0 1
335end
336wdkp
337wdrename
338wrline rc div ulong sub m1 m0 1000000 div ulong s0 1000000
339end
340
341note the RUN line, to stdout and to OUTDIR/runs.log
342fn wrline rc long wall ulong st ulong to void
343wdoclr
344wdot wrtrun
345wrob get wrar 0 get wrar 1
346wdoc 32
347wrob get wrar 2 get wrar 3
348wdoc 32
349if eq get wrar 4 1
350wdot wrtgen
351else
352wdot wrtprb
353end
354wdoc 32
355wdod ulong rc
356wdoc 32
357wdod wall
358wdoc 32
359wdod st
360wdoc 32
361wrpck
362wrshaline
363wdpclr
364wdzp 3
365wrshaline
366if eq rc 0
367wrpout wrtout
368else
369wrpout wrtfld
370end
371if not wdfsha
372exit 70
373end
374wdohex
375wrhookout
376wdot wrtnl
377wdpclr
378wdzp 7
379wdpt wrtlog
380fd = wdopen 1089 438
381if lt fd 0
382exit 70
383end
384wdowr fd
385c = fclose fd
386wdoflush 1
387end
388
389fn wrhookout to void
390p = get wrar 7
391e = get wrar 9
392while wrnext p e bound 999999
393wdoc 32
394wrob get wrtk 0 get wrtk 1
395p = get wrtk 1
396end
397end
398
399note pass 0 checks every line, pass 1 runs the arms
400fn wrpass pass ulong to void
401n = get wdsn 0
402s = ulong 0
403ln = ulong 1
404while lt s n bound 999999
405e = wbeol s n
406r = wrparse s add s wbcl s e
407if eq r 2
408wdoclr
409wdot wrtbad
410wdod ln
411wdot wrtnl
412wdoflush 2
413exit 2
414end
415if and eq r 1 eq pass 1
416wrarm
417end
418s = e
419ln = add ln 1
420end
421end
422
423fn main to int
424if ne argcnt 3
425wrusage
426end
427wrsetup
428wdpclr
429wdpa 1
430r = wdload
431if lt r 0
432exit 70
433end
434wdpclr
435wdzp 7
436m = makedir wdp 0 get wdpn 0 509
437wrpass 0
438wrpass 1
439ret int get wrfail 0
440end