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 / data / gen.om

384 lines · 6977 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note omegese45 episode generator (aien-train #45, pipeline lane). It implements the
3note reference policy of docs/omegese45/CONTRACT.md section 5 and the synthetic outcome
4note distribution declared in docs/omegese45/PIPELINE.md (grammar coverage, not runtime frequency). Build order:
5note cat native/omegese45/vocab.om native/omegese45/msg.om native/omegese45/data/gen.om
6note argv: SEED COUNT OUT.oe45 OUT.ids (SEED, COUNT decimal; COUNT 1..40000).
7note OUT.oe45: COUNT episodes, each the OE45 v1 text (line `oe45 v1`, one message per line).
8note OUT.ids: COUNT records, each one byte L (1..176) then the L episode ids, one byte each.
9note stdout: one line `oe45gen v1 seed=S count=N` followed by the coverage counters.
10note Deterministic: the only randomness is splitmix64 seeded with SEED. Exits: 0 ok, 2 usage,
11note 40 a generated message failed the contract validator (a generator defect), 70 file I/O.
12global oprs ulong 1
13global opep ulong 256
14global opel ulong 1
15global opgp uchar 4096
16global opgb uchar 256
17global opgst ulong 64
18global opgfd ulong 2
19
20note splitmix64 (Steele, Lea, Flood 2014): state += golden gamma, then the finaliser mix.
21fn opnext to ulong
22x = add get oprs 0 11400714819323198485
23put oprs 0 x
24z = xor x shr x 30
25z = mul z 13787848793156543929
26z = xor z shr z 27
27z = mul z 10723151780598845931
28ret xor z shr z 31
29end
30
31note A value in 0 .. n-1: the generator output reduced mod n (declared; bias below 2^-40).
32fn opbelow n ulong to ulong
33ret rem opnext n
34end
35
36fn oppush id ulong to void
37n = get opel 0
38put opep n id
39put opel 0 add n 1
40end
41
42note ushort 0x H H H for v in 0 .. 0xfff.
43fn oppd v ulong to void
44oppush 22
45oppush 24
46oppush add 25 and shr v 8 15
47oppush add 25 and shr v 4 15
48oppush add 25 and v 15
49end
50
51note ulong 0x H H H H for v in 0 .. 0xffff.
52fn opps v ulong to void
53oppush 23
54oppush 24
55oppush add 25 and shr v 12 15
56oppush add 25 and shr v 8 15
57oppush add 25 and shr v 4 15
58oppush add 25 and v 15
59end
60
61fn opcnt i ulong to void
62put opgst i add get opgst i 1
63end
64
65note One dimension: 8% an edge 0x000 0x001 0x100 0x101 (2% each), 4% uniform in
66note 0x101 .. 0xfff, 88% uniform in 0x001 .. 0x100.
67fn opdim to ulong
68u = opbelow 100
69if lt u 8
70e = opbelow 4
71opcnt add 40 e
72if eq e 0
73ret 0
74end
75if eq e 1
76ret 1
77end
78if eq e 2
79ret 256
80end
81ret 257
82end
83if lt u 12
84ret add 257 opbelow 3839
85end
86ret add 1 opbelow 256
87end
88
89note Synthetic outcome of one job attempt for grammar coverage, as class * 32 + code id:
90note 55% ok (class 1), 15% fail transport (class 3), 30% split evenly (2% each) over the
91note 15 other pairs: refused x {replay budget worker transport receipt recomp verdict io}
92note (class 2) and fail x {replay budget worker receipt recomp verdict io} (class 3).
93fn opout to ulong
94u = opbelow 100
95if lt u 55
96ret 32
97end
98if lt u 70
99ret add ulong 96 17
100end
101c = div sub u 70 2
102if lt c 8
103ret add 64 add 14 c
104end
105c = sub c 8
106if ge c 3
107c = add c 1
108end
109ret add 96 add 14 c
110end
111
112fn opadim d ulong to bool
113ret and ge d 1 le d 256
114end
115
116note The goal operands of the current episode: pair flag, m, k, n, seed1, seed2.
117global opgv ulong 6
118
119note A job attempt: act job mm D D D S end, with seed index j (0 seed1, 1 seed2).
120fn opact j ulong to void
121oppush 2
122oppush 8
123oppush 6
124oppd get opgv 1
125oppd get opgv 2
126oppd get opgv 3
127opps get opgv add 4 j
128oppush 5
129end
130
131note The operands as G and P ok carry them: kind word, D D D, S [S].
132fn opops to void
133if eq get opgv 0 1
134oppush 7
135else
136oppush 6
137end
138oppd get opgv 1
139oppd get opgv 2
140oppd get opgv 3
141opps get opgv 4
142if eq get opgv 0 1
143opps get opgv 5
144end
145end
146
147note Draw the goal (kind, dims, seeds, in this order) and append G. True when admitted.
148fn opgoal to bool
149pr = opbelow 2
150put opgv 0 pr
151put opgv 1 opdim
152put opgv 2 opdim
153put opgv 3 opdim
154put opgv 4 opbelow 65536
155put opgv 5 0
156if eq pr 1
157put opgv 5 opbelow 65536
158opcnt 1
159else
160opcnt 0
161end
162oppush 1
163opops
164oppush 5
165ret and and opadim get opgv 1 opadim get opgv 2 opadim get opgv 3
166end
167
168note Job j under the policy: A, then R; one retry after the first fail transport.
169note Returns the last outcome (class * 32 + code id; 32 = ok).
170fn opjob j ulong to ulong
171t = ulong 0
172o = ulong 0
173dn = false
174while not dn bound 3
175opact j
176o = opout
177cl = shr o 5
178cd = and o 31
179oppush 3
180if eq cl 1
181oppush 10
182dn = true
183else
184oppush add 9 cl
185oppush cd
186opcnt add 8 add mul sub cl 2 16 sub cd 13
187if and and eq cl 3 eq cd 17 eq t 0
188t = 1
189opcnt 3
190else
191dn = true
192end
193end
194oppush 5
195end
196ret o
197end
198
199note One episode by the reference policy into opep / opel.
200fn opgen to void
201put opel 0 0
202if not opgoal
203opcnt 2
204oppush 2
205oppush 9
206oppush 13
207oppush 5
208oppush 4
209oppush 11
210oppush 13
211oppush 5
212ret
213end
214for j ulong add get opgv 0 1
215o = opjob j
216if ne o 32
217opcnt 4
218oppush 4
219oppush add 9 shr o 5
220oppush and o 31
221oppush 5
222ret
223end
224end
225opcnt 5
226oppush 4
227oppush 10
228opops
229oppush 5
230end
231
232fn opatou n ulong to ulong
233v = ulong 0
234if or eq n 0 gt n 18
235exit 2
236end
237for i ulong n
238c = ulong get opgp i
239if or lt c 48 gt c 57
240exit 2
241end
242v = add mul v 10 sub c 48
243end
244ret v
245end
246
247fn oparg i ulong to ulong
248r = argread i opgp 0 4095
249if le r 0
250exit 2
251end
252ret ulong r
253end
254
255fn opopen i ulong to int
256n = oparg i
257fd = fopen opgp 0 n 577 420
258if lt fd 0
259exit 70
260end
261ret int fd
262end
263
264fn opwout fd int n ulong to void
265o = ulong 0
266while lt o n bound 4097
267w = write fd ocout o sub n o
268if le w 0
269exit 70
270end
271o = add o ulong w
272end
273end
274
275fn opwbuf fd int n ulong to void
276o = ulong 0
277while lt o n bound 257
278w = write fd opgb o sub n o
279if le w 0
280exit 70
281end
282o = add o ulong w
283end
284end
285
286note Write the episode: text (validated message by message) and its id record.
287fn opemit tf int bf int to void
288n = get opel 0
289put ocout 0 111
290put ocout 1 101
291put ocout 2 52
292put ocout 3 53
293put ocout 4 32
294put ocout 5 118
295put ocout 6 49
296put ocout 7 10
297opwout tf 8
298s = ulong 0
299for i ulong n
300if eq get opep i 5
301c = add sub i s 1
302for j ulong c
303put ocids j get opep add s j
304end
305if lt ocvids c 0 0
306exit 40
307end
308b = ocdec c
309if lt b 0
310exit 40
311end
312put ocout ulong b 10
313opwout tf add ulong b 1
314s = add i 1
315end
316end
317if ne s n
318exit 40
319end
320put opgb 0 uchar n
321for i ulong n
322put opgb add i 1 uchar get opep i
323end
324opwbuf bf add n 1
325end
326
327note Coverage line: `oe45gen v1 SEED COUNT` then 26 counters in this order: mm pair oob retry
328note stop okep e000 e001 e100 e101, refused replay budget worker transport receipt recomp
329note verdict io, fail replay budget worker transport receipt recomp verdict io.
330text opghd "oe45gen v1"
331
332fn opstat i ulong to void
333ocputc 32
334ocputn get opgst i
335end
336
337fn main to int
338if ne argcnt 5
339exit 2
340end
341seed = opatou oparg 1
342cnt = opatou oparg 2
343if or eq cnt 0 gt cnt 40000
344exit 2
345end
346tf = opopen 3
347bf = opopen 4
348put oprs 0 seed
349for e ulong cnt
350opgen
351opemit tf bf
352end
353if ne fsync tf 0
354exit 70
355end
356if ne fsync bf 0
357exit 70
358end
359if ne fclose tf 0
360exit 70
361end
362if ne fclose bf 0
363exit 70
364end
365w = write 1 opghd 0 len opghd
366ocputc 32
367ocputn seed
368ocputc 32
369ocputn cnt
370for i ulong 6
371opstat i
372end
373for i ulong 4
374opstat add 40 i
375end
376for i ulong 8
377opstat add 9 i
378end
379for i ulong 8
380opstat add 25 i
381end
382ocputc 10
383ret 0
384end