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 / vocab.om

318 lines · 8401 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note R45 vocabulary and lossless codec (aien-train #45, contract lane).
3note The text ocvtsv is byte-identical to docs/omegese45/vocab.tsv; its sha256 is the
4note vocabulary pin (docs/omegese45/CONTRACT.md). Word offsets are parsed from that text,
5note so the codec and the T table can never disagree.
6note Build order: cat vocab.om msg.om [mjr1.om] <unit with fn main>. All names use the oc prefix.
7note Public API (stable, documented in CONTRACT.md):
8note ocin uchar 4096 input line bytes, filled by the caller
9note ocids ulong 256 ids (encode output / decode and validator input)
10note ocipos ulong 256 byte offset in ocin of each id (encode output)
11note ocout uchar 4096 decode output text
12note ocerr ulong 2 [0] position, [1] reason code of the last error
13note fn ocenc n ulong to long ocin[0,n) -> ocids; returns id count or -reason
14note fn ocdec n ulong to long ocids[0,n) -> ocout; returns byte count or -reason
15note Reason codes: see the const block; ocputrs prints the reason word.
16const ocv ulong 41
17const ocmaxi ulong 176
18const ocmaxb ulong 1024
19const ocrempty long 1
20const ocrspace long 2
21const ocrtab long 3
22const ocrcr long 4
23const ocrnasc long 5
24const ocrupper long 6
25const ocrhexc long 7
26const ocrctrl long 8
27const ocrunk long 9
28const ocrlong long 10
29const ocrbadid long 11
30const ocrdigit long 12
31const ocrgram long 13
32const ocrnoend long 14
33const ocrtrail long 15
34const ocrkind long 16
35const ocrnjob long 17
36const ocrjobix long 18
37const ocrdims long 19
38const ocrseed long 20
39text ocvtsv "0\t<pad>\treserved\tcontext padding only; never emitted, never in a message\n1\tgoal\tframe\tprofile word\n2\tact\tframe\tprofile word\n3\tres\tframe\tprofile word, runtime-only (the model never emits it)\n4\trep\tframe\tprofile word\n5\tend\tframe\tOmega keyword `end` (block terminator)\n6\tmm\tkind\tprofile word: one `matmul_u32` job\n7\tpair\tkind\tprofile word: two `matmul_u32` jobs, same dims, seeds in order\n8\tjob\taction\tprofile word: submit one admitted microjob\n9\trefuse\taction\tprofile word: refuse before submission\n10\tok\toutcome\tprofile word\n11\trefused\toutcome\tprofile word\n12\tfail\toutcome\tprofile word\n13\tbound\tcode\tgoal outside the admitted bounds (a dim not in 1..256); decided by the model\n14\treplay\tcode\tworker refusal AN0_REPLAY\n15\tbudget\tcode\tworker refusal: budget/fuel\n16\tworker\tcode\tany other worker refusal (aienet0-run exit 11)\n17\ttransport\tcode\taienet0-run exit 10\n18\treceipt\tcode\taienet0-run exit 12\n19\trecomp\tcode\taienet0-run exit 13\n20\tverdict\tcode\taienet0-run exit 14\n21\tio\tcode\taienet0-run exit 15\n22\tushort\ttype\tOmega type keyword (u16), OMEGESE.md:114\n23\tulong\ttype\tOmega type keyword (u64), OMEGESE.md:114\n24\t0x\tliteral\tOmega hex-literal prefix, OMEGESE.md:691\n25\t0\tliteral digit\tOmega hex digits (lowercase), OMEGESE.md:691\n26\t1\tliteral digit\tOmega hex digits (lowercase), OMEGESE.md:691\n27\t2\tliteral digit\tOmega hex digits (lowercase), OMEGESE.md:691\n28\t3\tliteral digit\tOmega hex digits (lowercase), OMEGESE.md:691\n29\t4\tliteral digit\tOmega hex digits (lowercase), OMEGESE.md:691\n30\t5\tliteral digit\tOmega hex digits (lowercase), OMEGESE.md:691\n31\t6\tliteral digit\tOmega hex digits (lowercase), OMEGESE.md:691\n32\t7\tliteral digit\tOmega hex digits (lowercase), OMEGESE.md:691\n33\t8\tliteral digit\tOmega hex digits (lowercase), OMEGESE.md:691\n34\t9\tliteral digit\tOmega hex digits (lowercase), OMEGESE.md:691\n35\ta\tliteral digit\tOmega hex digits (lowercase), OMEGESE.md:691\n36\tb\tliteral digit\tOmega hex digits (lowercase), OMEGESE.md:691\n37\tc\tliteral digit\tOmega hex digits (lowercase), OMEGESE.md:691\n38\td\tliteral digit\tOmega hex digits (lowercase), OMEGESE.md:691\n39\te\tliteral digit\tOmega hex digits (lowercase), OMEGESE.md:691\n40\tf\tliteral digit\tOmega hex digits (lowercase), OMEGESE.md:691\n"
40text ocrtx "empty space tab cr nonasciiupper hexcase ctrl unknown long badid digit grammar noend trailingkind notjob jobindexdims seed "
41global ocwo ulong 41
42global ocwl ulong 41
43global ocvok ulong 1
44global ocin uchar 4096
45global ocids ulong 256
46global ocipos ulong 256
47global ocout uchar 4096
48global ocerr ulong 2
49global ocb1 uchar 1
50global ocnb uchar 24
51
52note Parse ocvtsv once: row i is "<id>\t<word>\t<class>\t<provenance>\n".
53fn ocvinit to void
54if eq get ocvok 0 1
55ret
56end
57p = ulong 0
58for i ulong ocv
59while ne get ocvtsv p 9 bound 8
60p = add p 1
61end
62p = add p 1
63put ocwo i p
64while ne get ocvtsv p 9 bound 16
65p = add p 1
66end
67put ocwl i sub p get ocwo i
68while ne get ocvtsv p 10 bound 200
69p = add p 1
70end
71p = add p 1
72end
73put ocvok 0 1
74end
75
76note Record an error and return -r.
77fn ocerrset pos ulong r long to long
78put ocerr 0 pos
79put ocerr 1 ulong r
80ret sub 0 r
81end
82
83fn ocisdig id ulong to bool
84ret and ge id 25 le id 40
85end
86
87note Hex digit value of a lowercase ASCII byte, 16 when it is not one.
88fn ochexd b uchar to ulong
89if and ge b 48 le b 57
90ret ulong sub b 48
91end
92if and ge b 97 le b 102
93ret ulong sub b 87
94end
95ret 16
96end
97
98note ocin[s,s+n) equals the word of id?
99fn ocwmatch id ulong s ulong n ulong to bool
100if ne n get ocwl id
101ret false
102end
103o = get ocwo id
104for j ulong n
105if ne get ocin add s j get ocvtsv add o j
106ret false
107end
108end
109ret true
110end
111
112note Id of the plain word ocin[s,s+n) among ids 0..23, or 99.
113fn oclook s ulong n ulong to ulong
114for i ulong 24
115if ocwmatch i s n
116ret i
117end
118end
119ret 99
120end
121
122note Encode one word ocin[s,e) at id index k; return the new count or -reason.
123fn ocencw s ulong e ulong k ulong to long
124wn = sub e s
125hx = false
126if ge wn 2
127if and eq get ocin s 48 eq get ocin add s 1 120
128hx = true
129end
130end
131if hx
132if ge k ocmaxi
133ret ocerrset s ocrlong
134end
135put ocids k 24
136put ocipos k s
137k = add k 1
138for j ulong sub wn 2
139q = add add s 2 j
140v = ochexd get ocin q
141if eq v 16
142ret ocerrset q ocrunk
143end
144if ge k ocmaxi
145ret ocerrset q ocrlong
146end
147put ocids k add 25 v
148put ocipos k q
149k = add k 1
150end
151ret long k
152end
153id = oclook s wn
154if eq id 99
155ret ocerrset s ocrunk
156end
157if ge k ocmaxi
158ret ocerrset s ocrlong
159end
160put ocids k id
161put ocipos k s
162ret long add k 1
163end
164
165note Text -> ids. Byte classes are checked first (first offending byte wins),
166note then single-space word structure, then words left to right.
167fn ocenc n ulong to long
168ocvinit
169if eq n 0
170ret ocerrset 0 ocrempty
171end
172if gt n ocmaxb
173ret ocerrset ocmaxb ocrlong
174end
175for i ulong n
176b = get ocin i
177if eq b 13
178ret ocerrset i ocrcr
179end
180if eq b 9
181ret ocerrset i ocrtab
182end
183if gt b 127
184ret ocerrset i ocrnasc
185end
186if or lt b 32 eq b 127
187ret ocerrset i ocrctrl
188end
189if and ge b 65 le b 90
190hc = false
191if and eq b 88 gt i 0
192if eq get ocin sub i 1 48
193hc = true
194end
195end
196if hc
197ret ocerrset i ocrhexc
198end
199ret ocerrset i ocrupper
200end
201end
202if eq get ocin 0 32
203ret ocerrset 0 ocrspace
204end
205if eq get ocin sub n 1 32
206ret ocerrset sub n 1 ocrspace
207end
208for i ulong sub n 1
209if and eq get ocin i 32 eq get ocin add i 1 32
210ret ocerrset add i 1 ocrspace
211end
212end
213k = ulong 0
214s = ulong 0
215for i ulong add n 1
216br = false
217if eq i n
218br = true
219else
220if eq get ocin i 32
221br = true
222end
223end
224if br
225r = ocencw s i k
226if lt r 0
227ret r
228end
229k = ulong r
230s = add i 1
231end
232end
233ret long k
234end
235
236note Ids -> text in ocout. Errors carry the id index as position.
237fn ocdec n ulong to long
238ocvinit
239if eq n 0
240ret ocerrset 0 ocrempty
241end
242if gt n ocmaxi
243ret ocerrset ocmaxi ocrlong
244end
245p = ulong 0
246for i ulong n
247id = get ocids i
248if ge id ocv
249ret ocerrset i ocrbadid
250end
251if ocisdig id
252if eq i 0
253ret ocerrset 0 ocrdigit
254end
255if lt get ocids sub i 1 24
256ret ocerrset i ocrdigit
257end
258put ocout p get ocvtsv get ocwo id
259p = add p 1
260else
261if gt i 0
262put ocout p 32
263p = add p 1
264end
265o = get ocwo id
266for j ulong get ocwl id
267put ocout p get ocvtsv add o j
268p = add p 1
269end
270end
271end
272ret long p
273end
274
275fn ocputc c uchar to void
276put ocb1 0 c
277w = write 1 ocb1 0 1
278if ne w 1
279exit 2
280end
281end
282
283fn ocputn n ulong to void
284if eq n 0
285ocputc 48
286ret
287end
288p = ulong 24
289while gt n 0 bound 24
290p = sub p 1
291put ocnb p uchar add 48 rem n 10
292n = div n 10
293end
294w = write 1 ocnb p sub 24 p
295if ne w long sub 24 p
296exit 2
297end
298end
299
300note Print the reason word of code r (1..20).
301fn ocputrs r ulong to void
302o = mul sub r 1 8
303for j ulong 8
304c = get ocrtx add o j
305if ne c 32
306ocputc c
307end
308end
309end
310
311note Print the surface word of id (digits print as one character).
312fn ocputw id ulong to void
313ocvinit
314o = get ocwo id
315for j ulong get ocwl id
316ocputc get ocvtsv add o j
317end
318end