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 / si19 / omexpmain.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note aien-train#24 ORIG-1 driver. stdin: one mode byte, then the allow-list (4096 bytes), |
| 3 | note then omexp-v1 records to end of input. Mode I: admit the file and print the |
| 4 | note dataset identity, family counts and the deterministic baselines per partition and |
| 5 | note core class (contract s.7). Mode G: generate the SYNTHETIC fixture (seed, count from |
| 6 | note the next 16 bytes) to fd 3 and print its identity. No training, no model here. |
| 7 | note Mode V (ORIG1-CONTRACT-v2.md): allow-list, records; v2 admission (oxadm2), refusal |
| 8 | note counts by reason, admitted records and workload families per split and core class. |
| 9 | note Mode A (leakage audit, no admission, local analysis only): 8 bytes na, then file A |
| 10 | note (na records) and file B to end of input; prints the oxaudit counters. |
| 11 | note Mode S: the frozen v2 split of every workload family (fm, fn), 0 <= fm, fn <= 13 and |
| 12 | note fm + fn <= 19 (M, N <= 8192, M N <= 2^19): one line "fm fn split" each. |
| 13 | note Exit: 64 bad mode, 66 dataset refused, 67 unauthorized or revoked, 74 I/O. |
| 14 | global OM uchar 1 |
| 15 | global OB uchar 16 |
| 16 | global OE ulong 16 |
| 17 | text OKV "status=" |
| 18 | text OREC "records=" |
| 19 | text OFNV "data_fnv=" |
| 20 | text OALW "allow=" |
| 21 | text OFAM "family_" |
| 22 | text OSTA "static_core" |
| 23 | text OPT "part=" |
| 24 | text OCO " core=" |
| 25 | text OSEP " " |
| 26 | text OEQ "=" |
| 27 | text ONL2 "\n" |
| 28 | text ONM0 "n" |
| 29 | text ONM1 "oracle" |
| 30 | text ONM2 "rule" |
| 31 | text ONM3 "reference" |
| 32 | text ONM4 "static" |
| 33 | text ONM5 "retrieval" |
| 34 | text ONM6 "rule_top1" |
| 35 | text ONM7 "retrieval_top1" |
| 36 | text OREF "SELECT dataset refused status=-" |
| 37 | text OUNA "SELECT dataset not authorized status=-" |
| 38 | text OGEN "fixture_bytes=" |
| 39 | text OV2 "v2_" |
| 40 | text OADM "admitted=" |
| 41 | text ORQ "refused_reason_" |
| 42 | text OSPL "split_" |
| 43 | text OFAMS "_families=" |
| 44 | text OAU "audit_" |
| 45 | text OAN "a_records=" |
| 46 | text OBN "b_records=" |
| 47 | text OAF "a_fnv=" |
| 48 | text OBF "b_fnv=" |
| 49 | text OCU "_core_" |
| 50 | |
| 51 | fn onl to void |
| 52 | w = write 1 ONL2 0 1 |
| 53 | end |
| 54 | |
| 55 | fn oread n ulong to ulong |
| 56 | note Read exactly up to n bytes of records into RB; returns the count (stops at EOF). |
| 57 | o = ulong 0 |
| 58 | while lt o n bound 999999 |
| 59 | r = read 0 RB o sub n o |
| 60 | if lt r 0 |
| 61 | exit 74 |
| 62 | end |
| 63 | if eq r 0 |
| 64 | ret o |
| 65 | end |
| 66 | o = add o ulong r |
| 67 | end |
| 68 | ret o |
| 69 | end |
| 70 | |
| 71 | fn olist to ulong |
| 72 | note The allow-list block: 4096 bytes, zero padded; returns the used length. |
| 73 | o = ulong 0 |
| 74 | while lt o 4096 bound 4096 |
| 75 | r = read 0 LB o sub 4096 o |
| 76 | if lt r 0 |
| 77 | exit 74 |
| 78 | end |
| 79 | if eq r 0 |
| 80 | ret o |
| 81 | end |
| 82 | o = add o ulong r |
| 83 | end |
| 84 | n = ulong 0 |
| 85 | for i ulong 4096 |
| 86 | if ne get LB i 0 |
| 87 | n = add i 1 |
| 88 | end |
| 89 | end |
| 90 | ret n |
| 91 | end |
| 92 | |
| 93 | fn okey k ulong to void |
| 94 | if eq k 0 |
| 95 | w = write 1 ONM0 0 len ONM0 |
| 96 | end |
| 97 | if eq k 1 |
| 98 | w = write 1 ONM1 0 len ONM1 |
| 99 | end |
| 100 | if eq k 2 |
| 101 | w = write 1 ONM2 0 len ONM2 |
| 102 | end |
| 103 | if eq k 3 |
| 104 | w = write 1 ONM3 0 len ONM3 |
| 105 | end |
| 106 | if eq k 4 |
| 107 | w = write 1 ONM4 0 len ONM4 |
| 108 | end |
| 109 | if eq k 5 |
| 110 | w = write 1 ONM5 0 len ONM5 |
| 111 | end |
| 112 | if eq k 6 |
| 113 | w = write 1 ONM6 0 len ONM6 |
| 114 | end |
| 115 | if eq k 7 |
| 116 | w = write 1 ONM7 0 len ONM7 |
| 117 | end |
| 118 | end |
| 119 | |
| 120 | fn oacc k ulong v ulong to void |
| 121 | put OE k add get OE k v |
| 122 | end |
| 123 | |
| 124 | fn onearm r ulong to ulong |
| 125 | a = oxbest oxnear r |
| 126 | if oxcand r a |
| 127 | ret a |
| 128 | end |
| 129 | ret 0 |
| 130 | end |
| 131 | |
| 132 | fn obaseone r ulong s ulong to void |
| 133 | oacc 0 1 |
| 134 | b = oxbest r |
| 135 | oacc 1 oxcost r b |
| 136 | a = oxrule r |
| 137 | oacc 2 oxcost r a |
| 138 | if eq a b |
| 139 | oacc 6 1 |
| 140 | end |
| 141 | oacc 3 oxcost r 0 |
| 142 | oacc 4 oxcost r s |
| 143 | a = onearm r |
| 144 | oacc 5 oxcost r a |
| 145 | if eq a b |
| 146 | oacc 7 1 |
| 147 | end |
| 148 | end |
| 149 | |
| 150 | fn obase part ulong core ulong to void |
| 151 | note Baseline totals over one partition and core class into OE: 0 n, 1 oracle, 2 rule, |
| 152 | note 3 reference, 4 best static, 5 retrieval, 6 rule top-1 hits, 7 retrieval top-1 hits. |
| 153 | for i ulong 8 |
| 154 | put OE i 0 |
| 155 | end |
| 156 | s = oxstatic core |
| 157 | for r ulong get RC 0 |
| 158 | if and eq oxpart r part eq oxcore r core |
| 159 | obaseone r s |
| 160 | end |
| 161 | end |
| 162 | end |
| 163 | |
| 164 | fn oshow part ulong core ulong to void |
| 165 | obase part core |
| 166 | w = write 1 OPT 0 len OPT |
| 167 | wnum part |
| 168 | w = write 1 OCO 0 len OCO |
| 169 | wnum core |
| 170 | for k ulong 8 |
| 171 | w = write 1 OSEP 0 1 |
| 172 | okey k |
| 173 | w = write 1 OEQ 0 1 |
| 174 | wnum get OE k |
| 175 | end |
| 176 | onl |
| 177 | end |
| 178 | |
| 179 | fn oinspect to void |
| 180 | n = olist |
| 181 | c = oread 524288 |
| 182 | s = oxload c |
| 183 | if lt s 0 |
| 184 | w = write 1 OREF 0 len OREF |
| 185 | wnum ulong neg long s |
| 186 | onl |
| 187 | exit 66 |
| 188 | end |
| 189 | a = oxallow n get RC 2 |
| 190 | if lt a 0 |
| 191 | w = write 1 OUNA 0 len OUNA |
| 192 | wnum ulong neg long a |
| 193 | onl |
| 194 | exit 67 |
| 195 | end |
| 196 | w = write 1 OKV 0 len OKV |
| 197 | wnum 0 |
| 198 | onl |
| 199 | w = write 1 OALW 0 len OALW |
| 200 | wnum ulong a |
| 201 | onl |
| 202 | w = write 1 OREC 0 len OREC |
| 203 | wnum get RC 0 |
| 204 | onl |
| 205 | w = write 1 OFNV 0 len OFNV |
| 206 | wnum get RC 2 |
| 207 | onl |
| 208 | for f ulong 5 |
| 209 | w = write 1 OFAM 0 len OFAM |
| 210 | wnum f |
| 211 | w = write 1 OEQ 0 1 |
| 212 | wnum get RC add 4 f |
| 213 | onl |
| 214 | end |
| 215 | for k ulong 2 |
| 216 | w = write 1 OSTA 0 len OSTA |
| 217 | wnum k |
| 218 | w = write 1 OEQ 0 1 |
| 219 | wnum oxstatic k |
| 220 | onl |
| 221 | end |
| 222 | for p ulong 3 |
| 223 | for k ulong 2 |
| 224 | oshow p k |
| 225 | end |
| 226 | end |
| 227 | end |
| 228 | |
| 229 | fn ogen to void |
| 230 | o = ulong 0 |
| 231 | while lt o 16 bound 64 |
| 232 | r = read 0 OB o sub 16 o |
| 233 | if le r 0 |
| 234 | exit 74 |
| 235 | end |
| 236 | o = add o ulong r |
| 237 | end |
| 238 | seed = ulong 0 |
| 239 | cnt = ulong 0 |
| 240 | for i ulong 8 |
| 241 | seed = or seed shl ulong get OB i mul i 8 |
| 242 | cnt = or cnt shl ulong get OB add 8 i mul i 8 |
| 243 | end |
| 244 | n = sxgen seed cnt |
| 245 | o = ulong 0 |
| 246 | while lt o n bound 999999 |
| 247 | w = write 3 RB o sub n o |
| 248 | if le w 0 |
| 249 | exit 74 |
| 250 | end |
| 251 | o = add o ulong w |
| 252 | end |
| 253 | w = write 1 OGEN 0 len OGEN |
| 254 | wnum n |
| 255 | onl |
| 256 | w = write 1 OFNV 0 len OFNV |
| 257 | wnum oxfnv n |
| 258 | onl |
| 259 | end |
| 260 | |
| 261 | fn ofnvr a ulong n ulong to ulong |
| 262 | note FNV-1a 64 over RB[a..a+n). |
| 263 | h = ulong 14695981039346656037 |
| 264 | for i ulong n |
| 265 | h = mul xor h ulong get RB add a i 1099511628211 |
| 266 | end |
| 267 | ret h |
| 268 | end |
| 269 | |
| 270 | fn ofams p ulong to ulong |
| 271 | note Distinct workload families among the admitted records of split p. |
| 272 | k = ulong 0 |
| 273 | for r ulong get RC 0 |
| 274 | if eq oxpart r p |
| 275 | u = true |
| 276 | for q ulong r |
| 277 | if and eq oxpart q p eq oxcell q oxcell r |
| 278 | u = false |
| 279 | end |
| 280 | end |
| 281 | if u |
| 282 | k = add k 1 |
| 283 | end |
| 284 | end |
| 285 | end |
| 286 | ret k |
| 287 | end |
| 288 | |
| 289 | fn ospcore p ulong c ulong to ulong |
| 290 | k = ulong 0 |
| 291 | for r ulong get RC 0 |
| 292 | if and eq oxpart r p eq oxcore r c |
| 293 | k = add k 1 |
| 294 | end |
| 295 | end |
| 296 | ret k |
| 297 | end |
| 298 | |
| 299 | fn ov2show to void |
| 300 | w = write 1 OADM 0 len OADM |
| 301 | wnum get RQ 0 |
| 302 | onl |
| 303 | for k ulong 16 |
| 304 | if gt k 0 |
| 305 | w = write 1 ORQ 0 len ORQ |
| 306 | wnum k |
| 307 | w = write 1 OEQ 0 1 |
| 308 | wnum get RQ k |
| 309 | onl |
| 310 | end |
| 311 | end |
| 312 | for p ulong 3 |
| 313 | w = write 1 OSPL 0 len OSPL |
| 314 | wnum p |
| 315 | w = write 1 OFAMS 0 len OFAMS |
| 316 | wnum ofams p |
| 317 | onl |
| 318 | for c ulong 2 |
| 319 | w = write 1 OSPL 0 len OSPL |
| 320 | wnum p |
| 321 | w = write 1 OCU 0 len OCU |
| 322 | wnum c |
| 323 | w = write 1 OEQ 0 1 |
| 324 | wnum ospcore p c |
| 325 | onl |
| 326 | end |
| 327 | end |
| 328 | end |
| 329 | |
| 330 | fn ov2 to void |
| 331 | n = olist |
| 332 | c = oread 524288 |
| 333 | s = oxadm2 c |
| 334 | if lt s 0 |
| 335 | w = write 1 OREF 0 len OREF |
| 336 | wnum ulong neg long s |
| 337 | onl |
| 338 | exit 66 |
| 339 | end |
| 340 | a = oxallow n get RC 2 |
| 341 | if lt a 0 |
| 342 | w = write 1 OUNA 0 len OUNA |
| 343 | wnum ulong neg long a |
| 344 | onl |
| 345 | exit 67 |
| 346 | end |
| 347 | w = write 1 OV2 0 len OV2 |
| 348 | w = write 1 OKV 0 len OKV |
| 349 | wnum 0 |
| 350 | onl |
| 351 | w = write 1 OALW 0 len OALW |
| 352 | wnum ulong a |
| 353 | onl |
| 354 | w = write 1 OREC 0 len OREC |
| 355 | wnum get RC 0 |
| 356 | onl |
| 357 | w = write 1 OFNV 0 len OFNV |
| 358 | wnum get RC 2 |
| 359 | onl |
| 360 | ov2show |
| 361 | end |
| 362 | |
| 363 | fn oaudit to void |
| 364 | o = ulong 0 |
| 365 | while lt o 8 bound 64 |
| 366 | r = read 0 OB o sub 8 o |
| 367 | if le r 0 |
| 368 | exit 74 |
| 369 | end |
| 370 | o = add o ulong r |
| 371 | end |
| 372 | na = ulong 0 |
| 373 | for i ulong 8 |
| 374 | na = or na shl ulong get OB i mul i 8 |
| 375 | end |
| 376 | c = oread 524288 |
| 377 | t = div c 256 |
| 378 | if or ne rem c 256 0 gt na t |
| 379 | exit 66 |
| 380 | end |
| 381 | nb = sub t na |
| 382 | t = oxdec c |
| 383 | oxaudit na nb |
| 384 | w = write 1 OAN 0 len OAN |
| 385 | wnum na |
| 386 | onl |
| 387 | w = write 1 OBN 0 len OBN |
| 388 | wnum nb |
| 389 | onl |
| 390 | w = write 1 OAF 0 len OAF |
| 391 | wnum ofnvr 0 mul na 256 |
| 392 | onl |
| 393 | w = write 1 OBF 0 len OBF |
| 394 | wnum ofnvr mul na 256 mul nb 256 |
| 395 | onl |
| 396 | for k ulong 13 |
| 397 | w = write 1 OAU 0 len OAU |
| 398 | wnum k |
| 399 | w = write 1 OEQ 0 1 |
| 400 | wnum get AU k |
| 401 | onl |
| 402 | end |
| 403 | end |
| 404 | |
| 405 | fn osplits to void |
| 406 | for a ulong 14 |
| 407 | for b ulong 14 |
| 408 | if le add a b 19 |
| 409 | wnum a |
| 410 | w = write 1 OSEP 0 1 |
| 411 | wnum b |
| 412 | w = write 1 OSEP 0 1 |
| 413 | wnum oxhspl a b |
| 414 | onl |
| 415 | end |
| 416 | end |
| 417 | end |
| 418 | end |
| 419 | |
| 420 | fn main to int |
| 421 | r = read 0 OM 0 1 |
| 422 | if ne r 1 |
| 423 | exit 64 |
| 424 | end |
| 425 | m = get OM 0 |
| 426 | if eq m 73 |
| 427 | oinspect |
| 428 | ret 0 |
| 429 | end |
| 430 | if eq m 71 |
| 431 | ogen |
| 432 | ret 0 |
| 433 | end |
| 434 | if eq m 86 |
| 435 | ov2 |
| 436 | ret 0 |
| 437 | end |
| 438 | if eq m 65 |
| 439 | oaudit |
| 440 | ret 0 |
| 441 | end |
| 442 | if eq m 83 |
| 443 | osplits |
| 444 | ret 0 |
| 445 | end |
| 446 | exit 64 |
| 447 | end |