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/evidence/ECOSYSTEM6/independent-review/mutant1-unit.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 / evidence / ECOSYSTEM6 / independent-review / mutant1-unit.om` 799 lines ยท 13441 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-only 2 note Native IEEE binary32 addition over bit patterns, RNE and gradual underflow. 3 note Canonical positive quiet NaN; no foreign floating runtime or compiler f32 type. 4 fn ajam x ulong n ulong to ulong 5 if eq n 0 6 ret x 7 end 8 if ge n 64 9 if ne x 0 10 ret 1 11 end 12 ret 0 13 end 14 q = shr x n 15 mask = sub shl 1 n 1 16 if ne and x mask 0 17 q = or q 1 18 end 19 ret q 20 end 21 fn add32 aa ulong bb ulong to ulong 22 a = and aa `4294967295` 23 b = and bb `4294967295` 24 if or gt and a `2147483647` `2139095040` gt and b `2147483647` `2139095040` 25 ret `2143289344` 26 end 27 if lt and a `2147483647` and b `2147483647` 28 t = a 29 a = b 30 b = t 31 end 32 if eq and a `2147483647` `2139095040` 33 if and eq and b `2147483647` `2139095040` ne and xor a b `2147483648` 0 34 ret `2143289344` 35 end 36 ret a 37 end 38 if eq and b `2147483647` 0 39 if eq and a `2147483647` 0 40 ret and and a b `2147483648` 41 end 42 ret a 43 end 44 sign = and a `2147483648` 45 ea = and shr a 23 255 46 eb = and shr b 23 255 47 ma = and a `8388607` 48 mb = and b `8388607` 49 if eq ea 0 50 ea = 1 51 else 52 ma = or ma `8388608` 53 end 54 if eq eb 0 55 eb = 1 56 else 57 mb = or mb `8388608` 58 end 59 ma = shl ma 3 60 mb = shl mb 3 61 mb = ajam mb sub ea eb 62 if eq and xor a b `2147483648` 0 63 ma = add ma mb 64 if ge ma `134217728` 65 ma = ajam ma 1 66 ea = add ea 1 67 end 68 else 69 ma = sub ma mb 70 if eq ma 0 71 ret 0 72 end 73 while and lt ma `67108864` gt ea 1 74 ma = shl ma 1 75 ea = sub ea 1 76 end 77 end 78 q = shr ma 3 79 r = and ma 7 80 if gt r 4 81 q = add q 1 82 else 83 if eq r 4 84 if ne and q 1 0 85 q = add q 1 86 end 87 end 88 end 89 if ge q `16777216` 90 q = shr q 1 91 ea = add ea 1 92 end 93 if ge ea 255 94 ret or sign `2139095040` 95 end 96 if lt q `8388608` 97 ea = 0 98 end 99 q = and q `8388607` 100 ea = shl ea 23 101 q = or q ea 102 ret or sign q 103 end 104 note SPDX-License-Identifier: AGPL-3.0-only 105 note Native IEEE binary32 multiplication represented as bits; no host floating runtime. 106 note Round-to-nearest ties-to-even, gradual underflow, signed zeros and infinities. 107 note Canonical positive quiet NaN for every NaN result. Inputs are low32 bits. 108 fn mround x ulong shift ulong to ulong 109 if eq shift 0 110 ret x 111 end 112 if gt shift 63 113 ret 0 114 end 115 q = shr x shift 116 mask = sub shl 1 shift 1 117 r = and x mask 118 half = shl 1 sub shift 1 119 if or gt r half and eq r half ne and q 1 0 120 q = add q 1 121 end 122 ret q 123 end 124 fn mul32 aa ulong bb ulong to ulong 125 a = and aa `4294967295` 126 b = and bb `4294967295` 127 sign = and xor a b `2147483648` 128 ea = long and shr a 23 255 129 eb = long and shr b 23 255 130 ma = and a `8388607` 131 mb = and b `8388607` 132 if or and eq ea 255 ne ma 0 and eq eb 255 ne mb 0 133 ret `2143289344` 134 end 135 if or eq ea 255 eq eb 255 136 if or eq and a `2147483647` 0 eq and b `2147483647` 0 137 ret `2143289344` 138 end 139 ret or sign `2139095040` 140 end 141 if or eq and a `2147483647` 0 eq and b `2147483647` 0 142 ret sign 143 end 144 if eq ea 0 145 ea = 1 146 while lt ma `8388608` 147 ma = shl ma 1 148 ea = sub ea 1 149 end 150 else 151 ma = or ma `8388608` 152 end 153 if eq eb 0 154 eb = 1 155 while lt mb `8388608` 156 mb = shl mb 1 157 eb = sub eb 1 158 end 159 else 160 mb = or mb `8388608` 161 end 162 product = mul ma mb 163 e = sub add ea eb 127 164 shift = long 23 165 if ge product `140737488355328` 166 shift = 24 167 e = add e 1 168 end 169 if lt e 1 170 shift = add shift sub 1 e 171 e = 0 172 end 173 q = mround product ulong shift 174 if eq e 0 175 if ge q `8388608` 176 e = 1 177 end 178 else 179 if ge q `16777216` 180 q = shr q 1 181 e = add e 1 182 end 183 end 184 if ge e 255 185 ret or sign `2139095040` 186 end 187 q = and q `8388607` 188 e = shl e 23 189 q = or q ulong e 190 ret or sign q 191 end 192 note M20 metadata-v1. Integer metadata only; no allocator or numeric execution. 193 note ED: schema,dtype,rank,elements,offset,slot,generation,reserved,shape8,stride8. 194 note ES: live,retired,slot,generation,dtype,elements,reserved,reserved. 195 note ES is the caller-owned allocator snapshot. It is not untrusted wire input. 196 global ED ulong 24 197 global ES ulong 8 198 199 fn emshape to int 200 rank = get ED 2 201 if gt rank 8 202 ret -2 203 end 204 n = ulong 1 205 for d ulong rank 206 size = get ED add 8 d 207 if eq size 0 208 ret -3 209 end 210 if gt size div `1073741824` n 211 ret -8 212 end 213 n = mul n size 214 end 215 if ne get ED 3 n 216 ret -3 217 end 218 ret 0 219 end 220 221 fn emlive slot ulong gen ulong to int 222 if gt slot `4294967295` 223 ret -5 224 end 225 if or ne get ES 0 1 ne get ES 1 0 226 ret -5 227 end 228 if or eq gen 0 ne slot get ES 2 229 ret -5 230 end 231 if ne gen get ES 3 232 ret -5 233 end 234 ret 0 235 end 236 237 fn embounds to int 238 size = get ES 5 239 offset = get ED 4 240 if or eq size 0 gt size `1073741824` 241 ret -8 242 end 243 if ge offset size 244 ret -6 245 end 246 note Compare against remaining extent before multiplication, never overflow. 247 room = sub sub size 1 offset 248 for d ulong get ED 2 249 count = sub get ED add 8 d 1 250 stride = get ED add 16 d 251 if ne stride 0 252 if gt count div room stride 253 ret -6 254 end 255 room = sub room mul count stride 256 end 257 end 258 ret 0 259 end 260 261 fn emcheck to int 262 if or ne get ED 0 1 ne get ED 7 0 263 ret -1 264 end 265 if or ne get ES 6 0 ne get ES 7 0 266 ret -1 267 end 268 dtype = get ED 1 269 if or lt dtype 1 gt dtype 3 270 ret -4 271 end 272 status = emshape 273 if ne status 0 274 ret status 275 end 276 status = emlive get ED 5 get ED 6 277 if ne status 0 278 ret status 279 end 280 if ne dtype get ES 4 281 ret -4 282 end 283 ret embounds 284 end 285 286 fn emrelease slot ulong gen ulong to int 287 status = emlive slot gen 288 if ne status 0 289 ret status 290 end 291 note A maximal generation is retired, never wrapped into a valid old handle. 292 if eq gen `18446744073709551615` 293 put ES 1 1 294 else 295 put ES 3 add gen 1 296 end 297 put ES 0 0 298 ret 0 299 end 300 note SPDX-License-Identifier: AGPL-3.0-only 301 note Bounded host FP32 consumer. Uses external pinned L720 add32/mul32 and M20 emcheck. 302 note Eight independent tensors X,W,b,T,Y,dX,dW,db in 16-cell slots. 303 note Values are IEEE binary32 bits in ulong carriers, not integer fixed-point values. 304 note AD/AS are trusted local descriptor and allocator snapshots, not wire records. 305 global AD ulong 192 306 global AS ulong 64 307 global AP ulong 128 308 global AQ ulong 128 309 global AL ulong 1 310 311 fn afcount t ulong to ulong 312 if or eq t 2 eq t 7 313 ret 2 314 end 315 if or eq t 3 eq t 4 316 ret 4 317 end 318 ret 6 319 end 320 321 fn afget t ulong i ulong to ulong 322 ret get AP add mul t 16 i 323 end 324 325 fn afq t ulong i ulong to ulong 326 ret get AQ add mul t 16 i 327 end 328 329 fn afput t ulong i ulong v ulong to void 330 put AQ add mul t 16 i v 331 end 332 333 fn affinite x ulong to bool 334 if gt x `4294967295` 335 ret false 336 end 337 ret lt and x `2147483647` `2139095040` 338 end 339 340 fn afvalidate to int 341 for t ulong 8 342 for i ulong 24 343 put ED i get AD add mul t 24 i 344 end 345 for i ulong 8 346 put ES i get AS add mul t 8 i 347 end 348 status = emcheck 349 if ne status 0 350 ret status 351 end 352 note Contiguous owned local carriers only. This does not claim strided numeric kernels. 353 if or ne get ED 1 1 ne get ED 4 0 354 ret -20 355 end 356 if or ne get ED 5 add t 1 ne get ES 5 afcount t 357 ret -20 358 end 359 rank = ulong 2 360 rows = ulong 2 361 cols = ulong 3 362 if or eq t 1 eq t 6 363 rows = 3 364 cols = 2 365 end 366 if or eq t 3 eq t 4 367 cols = 2 368 end 369 if or eq t 2 eq t 7 370 rank = 1 371 cols = 1 372 end 373 note MUTANT omits the dimension admission checks 374 end 375 ret 0 376 end 377 378 fn afstep lr ulong to int 379 status = afvalidate 380 if ne status 0 381 ret status 382 end 383 if not affinite lr 384 ret -22 385 end 386 if ne and lr `2147483648` 0 387 ret -22 388 end 389 for t ulong 4 390 for i ulong afcount t 391 if not affinite afget t i 392 ret -22 393 end 394 end 395 end 396 for i ulong 128 397 put AQ i 0 398 end 399 loss = ulong 0 400 for row ulong 2 401 for col ulong 2 402 v = afget 2 col 403 for k ulong 3 404 x = afget 0 add mul row 3 k 405 w = afget 1 add mul k 2 col 406 v = add32 v mul32 x w 407 end 408 pos = add mul row 2 col 409 afput 4 pos v 410 r = add32 v xor afget 3 pos `2147483648` 411 loss = add32 loss mul32 r r 412 g = mul32 `1073741824` r 413 afput 7 col add32 afq 7 col g 414 for k ulong 3 415 xp = add mul row 3 k 416 wp = add mul k 2 col 417 gx = mul32 g afget 1 wp 418 gw = mul32 g afget 0 xp 419 afput 5 xp add32 afq 5 xp gx 420 afput 6 wp add32 afq 6 wp gw 421 end 422 end 423 end 424 note Commit only after all finite-result checks; rejected steps preserve AP and AL. 425 for i ulong 6 426 delta = mul32 lr afq 6 i 427 afput 1 i add32 afget 1 i xor delta `2147483648` 428 end 429 for i ulong 2 430 delta = mul32 lr afq 7 i 431 afput 2 i add32 afget 2 i xor delta `2147483648` 432 end 433 if not affinite loss 434 ret -23 435 end 436 for t ulong 8 437 if and ne t 0 ne t 3 438 for i ulong afcount t 439 if not affinite afq t i 440 ret -23 441 end 442 end 443 end 444 end 445 for t ulong 8 446 if and ne t 0 ne t 3 447 for i ulong afcount t 448 put AP add mul t 16 i afq t i 449 end 450 end 451 end 452 put AL 0 loss 453 ret 0 454 end 455 note SPDX-License-Identifier: AGPL-3.0-only 456 note Independent exact rational oracle: X/8,W/16,b/128,T/128,learning rate1/32. 457 note Only the test oracle uses integer rationals. Production calls IEEE add32/mul32. 458 global C ulong 1 459 global D uchar 24 460 global RI long 18 461 global RR long 4 462 global SAV ulong 129 463 global RNG ulong 1 464 text PASS "NATIVE_AFFINE_FP32_PASS checks=" 465 text FAIL "NATIVE_AFFINE_FP32_FAIL check=" 466 text NL "\n" 467 468 fn number n ulong to void 469 if eq n 0 470 put D 0 48 471 w = write 1 D 0 1 472 if ne w 1 473 exit 90 474 end 475 ret 476 end 477 p = ulong 24 478 while gt n 0 bound 24 479 p = sub p 1 480 put D p uchar add 48 rem n 10 481 n = div n 10 482 end 483 w = write 1 D p sub 24 p 484 if ne w long sub 24 p 485 exit 90 486 end 487 end 488 489 fn check ok bool to void 490 put C 0 add get C 0 1 491 if not ok 492 w = write 1 FAIL 0 len FAIL 493 number get C 0 494 w = write 1 NL 0 1 495 exit 1 496 end 497 end 498 499 fn bits value long scale ulong to ulong 500 note Exact binary32 encoding of small dyadic test numbers; no production primitive. 501 if eq value 0 502 ret 0 503 end 504 sign = ulong 0 505 if lt value 0 506 sign = `2147483648` 507 value = neg value 508 end 509 n = ulong value 510 power = ulong 0 511 q = n 512 while gt q 1 bound 24 513 q = shr q 1 514 power = add power 1 515 end 516 check le power 23 517 mantissa = sub shl n sub 23 power `8388608` 518 exponent = sub add power 127 scale 519 ret or sign or shl exponent 23 mantissa 520 end 521 522 fn fixture to void 523 for i ulong 192 524 put AD i 0 525 end 526 for i ulong 64 527 put AS i 0 528 end 529 for i ulong 128 530 put AP i 0 531 end 532 put AL 0 0 533 for t ulong 8 534 rank = ulong 2 535 rows = ulong 2 536 cols = ulong 3 537 count = ulong 6 538 if or eq t 1 eq t 6 539 rows = 3 540 cols = 2 541 end 542 if or eq t 3 eq t 4 543 cols = 2 544 count = 4 545 end 546 if or eq t 2 eq t 7 547 rank = 1 548 cols = 1 549 count = 2 550 end 551 p = mul t 24 552 put AD p 1 553 put AD add p 1 1 554 put AD add p 2 rank 555 put AD add p 3 count 556 put AD add p 5 add t 1 557 put AD add p 6 17 558 put AD add p 8 rows 559 put AD add p 16 cols 560 if eq rank 2 561 put AD add p 9 cols 562 put AD add p 17 1 563 end 564 p = mul t 8 565 put AS p 1 566 put AS add p 2 add t 1 567 put AS add p 3 17 568 put AS add p 4 1 569 put AS add p 5 count 570 end 571 end 572 573 fn save to void 574 for i ulong 128 575 put SAV i get AP i 576 end 577 put SAV 128 get AL 0 578 end 579 580 fn unchanged to void 581 for i ulong 128 582 check eq get SAV i get AP i 583 end 584 check eq get SAV 128 get AL 0 585 end 586 587 fn loadinputs to void 588 for i ulong 6 589 put AP i bits get RI i 3 590 put AP add 16 i bits get RI add 6 i 4 591 end 592 for i ulong 2 593 put AP add 32 i bits get RI add 12 i 7 594 end 595 for i ulong 4 596 put AP add 48 i bits get RI add 14 i 7 597 end 598 end 599 600 fn oracle to void 601 loss = long 0 602 for row ulong 2 603 for col ulong 2 604 pos = add mul row 2 col 605 y = get RI add 12 col 606 for k ulong 3 607 x = get RI add mul row 3 k 608 w = get RI add 6 add mul k 2 col 609 y = add y mul x w 610 end 611 check eq afget 4 pos bits y 7 612 r = sub y get RI add 14 pos 613 put RR pos r 614 loss = add loss mul r r 615 end 616 end 617 check eq get AL 0 bits loss 14 618 for k ulong 3 619 for col ulong 2 620 g = long 0 621 for row ulong 2 622 r = get RR add mul row 2 col 623 x = get RI add mul row 3 k 624 g = add g mul r x 625 end 626 pos = add mul k 2 col 627 check eq afget 6 pos bits g 9 628 updated = sub mul get RI add 6 pos 1024 g 629 check eq afget 1 pos bits updated 14 630 end 631 end 632 for col ulong 2 633 g = add get RR col get RR add 2 col 634 check eq afget 7 col bits g 6 635 updated = sub mul get RI add 12 col 16 g 636 check eq afget 2 col bits updated 11 637 end 638 for row ulong 2 639 for k ulong 3 640 g = long 0 641 for col ulong 2 642 r = get RR add mul row 2 col 643 w = get RI add 6 add mul k 2 col 644 g = add g mul r w 645 end 646 pos = add mul row 3 k 647 check eq afget 5 pos bits g 10 648 end 649 end 650 note Inputs and targets remain byte-identical after a successful step. 651 for i ulong 6 652 check eq afget 0 i bits get RI i 3 653 end 654 for i ulong 4 655 check eq afget 3 i bits get RI add 14 i 7 656 end 657 end 658 659 fn direct to void 660 fixture 661 check eq afvalidate 0 662 note X rows(1,-2,3),(2,0,-1); W(.5,-.25),(1,.75),(-.5,2). 663 put RI 0 8 664 put RI 1 -16 665 put RI 2 24 666 put RI 3 16 667 put RI 4 0 668 put RI 5 -8 669 put RI 6 8 670 put RI 7 -4 671 put RI 8 16 672 put RI 9 12 673 put RI 10 -8 674 put RI 11 32 675 put RI 12 16 676 put RI 13 -64 677 put RI 14 32 678 put RI 15 128 679 put RI 16 -128 680 put RI 17 64 681 loadinputs 682 check eq afstep `1023410176` 0 683 oracle 684 note Independently hand-calculated loss36.46875, not merely decreasing loss. 685 check eq get AL 0 `1108467712` 686 end 687 688 fn refusals to void 689 fixture 690 put AD 32 2 691 put AD 33 3 692 put AD 40 3 693 save 694 check eq afstep `1023410176` -21 695 unchanged 696 fixture 697 put AS 11 18 698 save 699 check eq afstep `1023410176` -5 700 unchanged 701 fixture 702 put AD 29 1 703 put AS 10 1 704 save 705 check eq afstep `1023410176` -20 706 unchanged 707 fixture 708 put AP 0 `2139095040` 709 save 710 check eq afstep `1023410176` -22 711 unchanged 712 fixture 713 put AP 0 `2143289344` 714 save 715 check eq afstep `1023410176` -22 716 unchanged 717 fixture 718 put AP 0 `4294967296` 719 save 720 check eq afstep `1023410176` -22 721 unchanged 722 fixture 723 save 724 check eq afstep `3170893824` -22 725 unchanged 726 fixture 727 put AP 0 `2139095039` 728 put AP 16 `1073741824` 729 save 730 check eq afstep `1023410176` -23 731 unchanged 732 end 733 734 fn next to long 735 n = add mul get RNG 0 `1664525` `1013904223` 736 n = and n `4294967295` 737 put RNG 0 n 738 ret sub long rem shr n 12 17 8 739 end 740 741 fn rounding to void 742 note Smallest subnormal through actual forward and input derivative, loss underflows. 743 fixture 744 put AP 0 1 745 put AP 16 `1065353216` 746 check eq afstep 0 0 747 check eq afget 4 0 1 748 check eq afget 5 0 2 749 check eq afget 6 0 0 750 check eq afget 7 0 2 751 check eq get AL 0 0 752 note Half a subnormal rounds to even zero. 753 fixture 754 put AP 0 1 755 put AP 16 `1056964608` 756 check eq afstep 0 0 757 check eq afget 4 0 0 758 note 1 + 2^-24 rounds to even1; 1 + 3*2^-24 rounds upward two ulps. 759 fixture 760 put AP 0 `1065353216` 761 put AP 16 `1065353216` 762 put AP 32 `864026624` 763 check eq afstep 0 0 764 check eq afget 4 0 `1065353216` 765 check eq afget 1 0 `1065353216` 766 fixture 767 put AP 0 `1065353216` 768 put AP 16 `1065353216` 769 put AP 32 `876609536` 770 check eq afstep 0 0 771 check eq afget 4 0 `1065353218` 772 end 773 774 fn corpus to void 775 put RNG 0 303660 776 for trial ulong 4096 777 fixture 778 for i ulong 18 779 put RI i next 780 end 781 loadinputs 782 check eq afstep `1023410176` 0 783 oracle 784 end 785 end 786 787 fn main to int 788 direct 789 refusals 790 rounding 791 corpus 792 w = write 1 PASS 0 len PASS 793 number get C 0 794 w = write 1 NL 0 1 795 if ne w 1 796 ret 90 797 end 798 ret 0 799 end