Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-train/blob/main/tests/si19/world-test.om # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-train / tests / si19 / world-test.om` 572 lines ยท 9901 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-only 2 note aien-train#19 tests. The golden oracle is test-only exact integer arithmetic at 3 note scale 2^24; it never calls add32/mul32 and decodes binary32 bits independently. 4 global C ulong 1 5 global OW long 8 6 global OG long 8 7 global OY long 4 8 global OX long 6 9 global OT long 4 10 global OL long 1 11 global TV ulong 8 12 global TB ulong 64 13 text PASS "SI19_WORLD_TEST_PASS checks=" 14 text FAIL "SI19_WORLD_TEST_FAIL check=" 15 text NL "\n" 16 17 fn check ok bool to void 18 put C 0 add get C 0 1 19 if not ok 20 w = write 1 FAIL 0 len FAIL 21 wnum get C 0 22 w = write 1 NL 0 1 23 exit 1 24 end 25 end 26 27 note ---- independent binary32 decode/encode for the oracle ---- 28 29 fn odec x ulong to long 30 note Exact numerator at scale 2^24 of a normal binary32 value. 31 if eq and x `2147483647` 0 32 ret 0 33 end 34 e = long and shr x 23 255 35 check and gt e 0 lt e 255 36 m = long or and x `8388607` `8388608` 37 if ge e 126 38 check le sub e 126 30 39 m = shl m sub e 126 40 else 41 k = sub 126 e 42 check le k 23 43 check eq rem m shl long 1 k 0 44 m = shr m k 45 end 46 if ne and x `2147483648` 0 47 ret neg m 48 end 49 ret m 50 end 51 52 fn obits num long to ulong 53 note Exact binary32 bits of num/2^24; fails the test if not exactly representable. 54 if eq num 0 55 ret 0 56 end 57 sign = ulong 0 58 if lt num 0 59 sign = `2147483648` 60 num = neg num 61 end 62 m = ulong num 63 sc = long 24 64 while eq and m 1 0 bound 64 65 m = shr m 1 66 sc = sub sc 1 67 end 68 check lt m `16777216` 69 pw = long 0 70 q = m 71 while gt q 1 bound 64 72 q = shr q 1 73 pw = add pw 1 74 end 75 ex = sub add pw 127 sc 76 check and gt ex 0 lt ex 255 77 ret or sign or shl ulong ex 23 sub shl m ulong sub 23 pw `8388608` 78 end 79 80 fn ochk num long to void 81 x = obits num 82 end 83 84 fn oload row ulong id ulong to void 85 r = mul id 8 86 c = mul row 3 87 put OX c get TL add r 1 88 put OX add c 1 get TL add r 2 89 put OX add c 2 get TL add r 3 90 c = mul row 2 91 put OT c get TL add r 4 92 put OT add c 1 get TL add r 5 93 end 94 95 fn oforward row ulong col ulong to long 96 y = get OW add 6 col 97 for k ulong 3 98 t = mul get OX add mul row 3 k get OW add mul k 2 col 99 ochk t 100 y = add y t 101 ochk y 102 end 103 put OY add mul row 2 col y 104 ret y 105 end 106 107 fn ograd row ulong col ulong g long to void 108 put OG add 6 col add get OG add 6 col g 109 ochk get OG add 6 col 110 for k ulong 3 111 i = add mul k 2 col 112 gw = mul g get OX add mul row 3 k 113 ochk gw 114 put OG i add get OG i gw 115 ochk get OG i 116 end 117 end 118 119 fn ocell row ulong col ulong to void 120 note One output element: forward, residual, loss term and gradient contributions. 121 r = sub oforward row col shl get OT add mul row 2 col 24 122 ochk r 123 check eq rem r 4096 0 124 h = div r 4096 125 sq = mul h h 126 ochk sq 127 put OL 0 add get OL 0 sq 128 ochk get OL 0 129 g = mul r 2 130 ochk g 131 ograd row col g 132 end 133 134 fn ostep to void 135 put OL 0 0 136 for i ulong 8 137 put OG i 0 138 end 139 for row ulong 2 140 for col ulong 2 141 ocell row col 142 end 143 end 144 for i ulong 8 145 d = get OG i 146 check eq rem d 512 0 147 d = div d 512 148 ochk d 149 put OW i sub get OW i d 150 ochk get OW i 151 end 152 end 153 154 fn ocompare to void 155 note Real afstep slots and committed WS parameters against the exact oracle. 156 for i ulong 8 157 check eq get WS add 8 i obits get OW i 158 end 159 check eq get WS 5 obits get OL 0 160 check eq get AL 0 obits get OL 0 161 for i ulong 4 162 check eq get AP add 64 i obits get OY i 163 end 164 for i ulong 6 165 check eq get AP add 96 i obits get OG i 166 end 167 check eq get AP 112 obits get OG 6 168 check eq get AP 113 obits get OG 7 169 end 170 171 fn tforward pb ulong to void 172 note Forward-only predictor reproduces afstep's pre-update Y bit for bit. 173 for row ulong 2 174 id = get WS add 112 row 175 r = mul id 8 176 wmpred pb get TL add r 1 get TL add r 2 get TL add r 3 177 check eq get PR 0 get AP add 64 mul row 2 178 check eq get PR 1 get AP add 65 mul row 2 179 end 180 end 181 182 fn tgolden to void 183 note Two actual trainer updates (wstrain, arm M) on admitted experience vs exact oracle. 184 wsinit 185 check eq wsuses 0 0 186 for i ulong 8 187 check eq get WS add 8 i get WS add 40 i 188 put OW i odec get WS add 40 i 189 end 190 wscollect 0 191 put WS 0 1 192 wscollect 0 193 put WS 0 2 194 wstrain 0 0 0 195 tforward 40 196 oload 0 get WS 112 197 oload 1 get WS 113 198 ostep 199 ocompare 200 check eq get WS 1 1 201 put TB 0 get WS 112 202 put TB 1 get WS 113 203 for i ulong 8 204 put TV i get WS add 8 i 205 end 206 wscopy 120 8 8 207 wstrain 0 0 0 208 tforward 120 209 oload 0 get WS 112 210 oload 1 get WS 113 211 ostep 212 ocompare 213 check eq get WS 1 2 214 check eq wsuses 0 4 215 put TB 2 get WS 112 216 put TB 3 get WS 113 217 tbatch 0 4 218 tbatch 1 4 219 changed = ulong 0 220 for i ulong 8 221 if ne get TV i get WS add 8 i 222 changed = add changed 1 223 end 224 end 225 check gt changed 0 226 end 227 228 fn tbatch id ulong n ulong to void 229 note Lineage counts equal the exact number of times id was in an applied batch. 230 occ = ulong 0 231 for i ulong n 232 if eq get TB i id 233 occ = add occ 1 234 end 235 end 236 check eq get WS add 128 id occ 237 end 238 239 fn tlinexact to void 240 note 32 real arm-M updates over 8 admitted experiences; every id's count is exact. 241 wsinit 242 for e ulong 8 243 put WS 0 e 244 wscollect 0 245 end 246 put WS 0 8 247 for k ulong 32 248 wstrain 0 0 0 249 put TB mul k 2 get WS 112 250 put TB add mul k 2 1 get WS 113 251 end 252 for id ulong 8 253 tbatch id 64 254 end 255 check eq wsuses 0 64 256 end 257 258 fn tshuffle to void 259 note Shuffled control: row inputs and row outcome come from the recorded, distinct ids. 260 wsinit 261 wscollect 0 262 put WS 0 1 263 wscollect 0 264 put WS 0 2 265 seen = ulong 0 266 for k ulong 64 267 wsshuf 268 a = get WS 116 269 t = get WS 117 270 if ne a t 271 seen = add seen 1 272 check eq get AP 0 wmbits get TL add mul a 8 1 0 273 check eq get AP 1 wmbits get TL add mul a 8 2 0 274 check eq get AP 48 wmbits get TL add mul t 8 4 0 275 check eq get AP 49 wmbits get TL add mul t 8 5 0 276 end 277 end 278 check gt seen 0 279 check eq wsuses 2 256 280 end 281 282 note ---- fixture: seeded, resettable, transition boundaries ---- 283 284 fn tsame to void 285 fxinit 2 1 4242 0 286 for i ulong 300 287 u = fxact 2 288 fxstep 2 u 289 for k ulong 7 290 put OG k get FT k 291 end 292 fxinit 3 1 4242 0 293 for j ulong i 294 uu = fxact 3 295 fxstep 3 uu 296 end 297 u = fxact 3 298 fxstep 3 u 299 for k ulong 7 300 check eq get OG k get FT k 301 end 302 end 303 end 304 305 fn tdiffer to void 306 fxinit 2 1 4242 0 307 fxinit 3 1 4243 0 308 same = ulong 0 309 for i ulong 64 310 u = fxact 2 311 fxstep 2 u 312 for k ulong 5 313 put OG k get FT k 314 end 315 u = fxact 3 316 fxstep 3 u 317 eqp = eq get OG 0 get FT 0 318 if and eqp eq get OG 1 get FT 1 319 same = add same 1 320 end 321 end 322 check lt same 64 323 end 324 325 fn tin x long lo long hi long to void 326 check and ge x lo le x hi 327 end 328 329 fn tdone r ulong to void 330 step = rem get TL add r 7 16 331 dn = fxdone get TL add r 4 get TL add r 5 step 332 check eq get TL add r 6 dn 333 end 334 335 fn trec id ulong gain long to void 336 note Each logged transition obeys the dynamics; terminal flag matches bounds and horizon. 337 r = mul id 8 338 check eq get TL r long id 339 v = get TL add r 2 340 tin get TL add r 1 -12 12 341 tin v -3 3 342 tin get TL add r 3 -1 1 343 check eq get TL add r 4 add get TL add r 1 v 344 g = sub get TL add r 5 v 345 tin sub g mul gain get TL add r 3 -1 1 346 tdone r 347 end 348 349 fn tlink id ulong to void 350 note Consecutive records: a terminal record is followed by a fresh reset, never its successor. 351 r = mul id 8 352 n = add r 8 353 a = get TL add r 7 354 b = get TL add n 7 355 if eq get TL add r 6 1 356 check eq rem b 16 0 357 a = add div a 16 1 358 check eq div b 16 a 359 tin get TL add n 1 -12 -4 360 tin get TL add n 2 -2 2 361 else 362 check eq b add a 1 363 a = get TL add r 4 364 check eq get TL add n 1 a 365 a = get TL add r 5 366 check eq get TL add n 2 a 367 end 368 end 369 370 fn tboundary to void 371 for i ulong 256 372 trec i 1 373 trec add 256 i -1 374 end 375 for i ulong 255 376 tlink i 377 tlink add 256 i 378 end 379 end 380 381 note ---- lineage and held-out separation ---- 382 383 fn tlineage to void 384 check eq wsuses 0 4096 385 check eq wsuses 1 4096 386 check eq wsuses 2 4096 387 check eq wsuses 3 2048 388 for i ulong 512 389 check ge get WS add 640 i get WS add 1664 i 390 check ge get WS add 128 i get WS add 1664 i 391 end 392 for i ulong 256 393 check not wsaffect 3 add 256 i 394 check not wsaffect 2 add 256 i 395 end 396 nb = ulong 0 397 for i ulong 256 398 if wsaffect 1 add 256 i 399 nb = add nb 1 400 end 401 end 402 check gt nb 0 403 end 404 405 fn tkey r ulong t ulong to bool 406 a = get HO add r 1 407 if ne a get TL add t 1 408 ret false 409 end 410 a = get HO add r 2 411 if ne a get TL add t 2 412 ret false 413 end 414 a = get HO add r 3 415 ret eq a get TL add t 3 416 end 417 418 fn theld env ulong to void 419 note Held-out ids are outside the training range and keys never occur in training. 420 wsfreq env 421 wsheld env 422 for n ulong 128 423 r = mul n 8 424 check eq get HO r long add `1048576` n 425 for j ulong 256 426 t = mul add mul env 256 j 8 427 check not tkey r t 428 end 429 end 430 end 431 432 note ---- checkpoint restart and refusal ---- 433 434 fn tdig to ulong 435 h = ulong `1469598103934665603` 436 for i ulong 2304 437 h = mul xor h get WS i `1099511628211` 438 end 439 for i ulong 4096 440 h = mul xor h wsenc get TL i `1099511628211` 441 end 442 for i ulong 64 443 h = mul xor h wsenc get FS i `1099511628211` 444 end 445 ret h 446 end 447 448 fn twipe to void 449 for i ulong 2304 450 put WS i 0 451 end 452 for i ulong 4096 453 put TL i 0 454 end 455 for i ulong 64 456 put FS i 0 457 end 458 for i ulong 192 459 put AD i 0 460 end 461 end 462 463 fn trestart cut ulong to void 464 wsinit 465 wsrun cut 466 cksave 0 467 twipe 468 check eq ckload 0 51752 0 469 check eq get WS 0 cut 470 wsrun 512 471 cksave 0 472 for i ulong 51752 473 check eq get CB i get CB add 51752 i 474 end 475 end 476 477 fn trefuse code int to void 478 d = tdig 479 check eq ckload 0 51752 code 480 check eq tdig d 481 end 482 483 fn treseal to void 484 ckput 51744 ckfnv 0 51744 485 end 486 487 fn tcorrupt to void 488 wsinit 489 wsrun 100 490 cksave 0 491 wsrun 140 492 d = tdig 493 check eq ckload 0 51751 -1 494 check eq tdig d 495 for k ulong 6 496 pos = add 100 mul k 9000 497 put CB pos uchar xor get CB pos 1 498 trefuse -5 499 put CB pos uchar xor get CB pos 1 500 end 501 put CB 0 uchar xor get CB 0 1 502 trefuse -2 503 put CB 0 uchar xor get CB 0 1 504 ckput 8 2 505 trefuse -3 506 ckput 8 1 507 ckput 32 600 508 ckput 24 600 509 treseal 510 trefuse -6 511 ckput 32 100 512 ckput 24 100 513 ckput 56 99 514 treseal 515 trefuse -7 516 ckput 56 100 517 keep = ckget 96 518 ckput 96 `2143289344` 519 treseal 520 trefuse -8 521 ckput 96 keep 522 keep = ckget 17440 523 ckput 17440 9999 524 treseal 525 trefuse -10 526 ckput 17440 keep 527 keep = ckget 18464 528 ckput 18464 `2199023255552` 529 treseal 530 trefuse -9 531 ckput 18464 keep 532 treseal 533 note Every edit undone: the original event-100 image must load again. 534 check eq ckload 0 51752 0 535 check eq get WS 0 100 536 cksave 51752 537 for i ulong 51752 538 check eq get CB i get CB add 51752 i 539 end 540 end 541 542 fn main to int 543 tgolden 544 tsame 545 tdiffer 546 tshuffle 547 tlinexact 548 wsinit 549 wsrun 512 550 tboundary 551 tlineage 552 theld 0 553 theld 1 554 wsinit 555 wsrun 512 556 cksave 51752 557 trestart 0 558 trestart 1 559 trestart 37 560 trestart 100 561 trestart 255 562 trestart 256 563 trestart 257 564 trestart 300 565 trestart 511 566 trestart 512 567 tcorrupt 568 w = write 1 PASS 0 len PASS 569 wnum get C 0 570 w = write 1 NL 0 1 571 ret 0 572 end