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