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/tools/omegallm/wpatch/wpbuild.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 / tools / omegallm / wpatch / wpbuild.om` 798 lines ยท 15079 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-only 2 note wpbuild: the Omega build driver for ollm, wpatch and its test driver wpcheck. CPU only. 3 note Usage: wpbuild REPO OUT OMC OMEGA_MV CORE (all five required; CORE is a taskset core number). 4 note Steps, in order (any failure prints one WPBUILD FAIL line and exits nonzero): 5 note 1. Compiler pin: the sha256 of OMC (read from sha256sum) must equal OMCPIN. 6 note 2. SHA-256: git show of om/sha256/sha256-om2.om at omega-mv pin `e5b32567` into OUT/sha256-source.om; 7 note its sha256 (read from sha256sum) must equal SHASRC. 8 note 3. Vendoring, done here in Omega: the layout block (from the line `layout shactx 104` through the 9 note next line `end`) goes to OUT/sha256-layout.om. Every other line except `om2` goes to 10 note OUT/sha256-functions.om, with a leading `export fn ` made `fn `, and on lines that do not start 11 note with `note` each whole word ([A-Za-z0-9_] run) in OLDW renamed to the word at the same position 12 note in NEWW. OUT/sha256-vendored.om is `om2`, layout, functions; OUT/sha256.diff is diff -u of the 13 note source against it (a review record, not an input). 14 note 4. wpcheck: OUT/wpcheck-all.om is `om2`, layout, functions, wpcheck.om; compiled to OUT/wpcheck. 15 note 5. Net pins: `OUT/wpcheck sum` (the vendored Omega SHA-256) of native/omegallm/net/http.om, 16 note json.om and jsonw.om must equal NPHTTP, NPJSON and NPJSONW (the pins of the aarch64 ollm build). 17 note 6. ollm: OUT/ollm.om is the line `om2`, then native/omegallm/ net/http.om net/json.om 18 note net/jsonw.om math.om data.om lpool.om model.om adam.om ckpt.om bpe.om cli.om lio.om serve.om 19 note nogpu.om, plain concatenation in that order (the aarch64 ollm source); compiled to OUT/ollm. 20 note 7. wpatch: OUT/wpatch-all.om is `om2`, layout, OUT/ollm.om without its `om2` line and with 21 note `fn main to int` (exactly one such line) renamed `fn wpollm to int`, functions, wpatch.om; 22 note compiled to OUT/wpatch. 23 note Each compile runs taskset -c CORE nice -n 19 OMC into a .new file, which is made executable and 24 note renamed over the target. A compile error removes the .new file and exits with omc's status. 25 note Finally sha256sum prints OMC, the SHA source, ollm.om, ollm, both compositions and both binaries. 26 note Exit codes: 2 usage, 3 a pinned digest differs (compiler, SHA source or net source), 4 main 27 note count, 5 I/O or capacity, 6 a tool failed (its status is printed), otherwise omc's own status. 28 om2 29 30 global sb uchar 65536 31 global sl ulong 128 32 global pb uchar 4096 33 global pn ulong 1 34 global av uchar 4096 35 global ap ulong 2 36 global stb uchar 4 37 global inb uchar `8388608` 38 global bn ulong 1 39 global ob uchar `8388608` 40 global obn ulong 1 41 global lay uchar 4096 42 global lan ulong 1 43 global fns uchar 65536 44 global fnn ulong 1 45 global cap uchar 4096 46 global capn ulong 1 47 global dig uchar 32 48 text PIN "`e5b32567a7aff3ce594e3254a622a846a6cd190b`:om/sha256/sha256-om2.om" 49 text SHASRC "`dbf002dd6aa36585632b9d01d98ac3f0bd2fa0f0475082940de53638847994bb`" 50 text OMCPIN "`2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`" 51 text NPHTTP "`aff258ecd3858454056811a5e6fe1f660f9d650a7207d6c41885105110e046a7`" 52 text NPJSON "`456254fc754ea35103ced480407b24fc1a3896d094b90ae0e9623e7b6594e2d2`" 53 text NPJSONW "`464f649e8207495f5d67fe8795d31e42ea3ccebd9ed547274dab802d4f7c5f21`" 54 text SHTTP "/native/omegallm/net/http.om" 55 text SJSON "/native/omegallm/net/json.om" 56 text SJSONW "/native/omegallm/net/jsonw.om" 57 text SMATH "/native/omegallm/math.om" 58 text SDATA "/native/omegallm/data.om" 59 text SLPOOL "/native/omegallm/lpool.om" 60 text SMODEL "/native/omegallm/model.om" 61 text SADAM "/native/omegallm/adam.om" 62 text SCKPT "/native/omegallm/ckpt.om" 63 text SBPE "/native/omegallm/bpe.om" 64 text SCLI "/native/omegallm/cli.om" 65 text SLIO "/native/omegallm/lio.om" 66 text SSERVE "/native/omegallm/serve.om" 67 text SNOGPU "/native/omegallm/nogpu.om" 68 text CSUM "sum" 69 text OLDW "kinit iv sched rounds compress run blocks finish tobuf absorb " 70 text NEWW "wskinit wsiv wssched wsround wscomp wsrun wsblks wsfin wstobuf wsabsb " 71 text GIT "/usr/bin/git" 72 text GC "-C" 73 text GSHOW "show" 74 text SUM "/usr/bin/sha256sum" 75 text DIFF "/usr/bin/diff" 76 text DU "-u" 77 text TSET "/usr/bin/taskset" 78 text TC "-c" 79 text NICE "/usr/bin/nice" 80 text NN "-n" 81 text N19 "19" 82 text OM2 "om2" 83 text LSTART "layout shactx 104" 84 text LEND "end" 85 text EXPFN "export fn " 86 text NOTE "note" 87 text MAINL "fn main to int" 88 text WPOLLM "fn wpollm to int\n" 89 text OM2NL "om2\n" 90 text FSRC "/sha256-source.om" 91 text FLAY "/sha256-layout.om" 92 text FFNS "/sha256-functions.om" 93 text FVEN "/sha256-vendored.om" 94 text FDIF "/sha256.diff" 95 text FOLLM "/ollm.om" 96 text FONEW "/ollm.new" 97 text FOL "/ollm" 98 text FWPS "/tools/omegallm/wpatch/wpatch.om" 99 text FCKS "/tools/omegallm/wpatch/wpcheck.om" 100 text FWALL "/wpatch-all.om" 101 text FCALL "/wpcheck-all.om" 102 text FWNEW "/wpatch.new" 103 text FCNEW "/wpcheck.new" 104 text FWP "/wpatch" 105 text FCK "/wpcheck" 106 text MUSAGE "WPBUILD FAIL usage: wpbuild REPO OUT OMC OMEGA_MV CORE\n" 107 text MIO "WPBUILD FAIL I/O or capacity: " 108 text MTOOL "WPBUILD FAIL tool exit " 109 text MSHA "WPBUILD FAIL SHA-256 source digest differs from the pin\n" 110 text MOMCP "WPBUILD FAIL omc digest differs from the pin\n" 111 text MNET "WPBUILD FAIL net source digest differs from the pin: " 112 text MMAIN "WPBUILD FAIL ollm.om must hold exactly one line `fn main to int`, found " 113 text MOMC "WPBUILD FAIL omc exit " 114 text MOK "WPBUILD PASS\n" 115 text NL "\n" 116 117 note ---- output, slots and argument packets -------------------------------------------------- 118 fn say s view uchar * to void 119 r = write 1 s 0 len s 120 end 121 fn saynum v ulong to void 122 x = v 123 n = ulong 0 124 while ge x 10 125 put dig n uchar add 48 rem x 10 126 x = div x 10 127 n = add n 1 128 end 129 put dig n uchar add 48 x 130 for i ulong add n 1 131 r = write 1 dig sub n i 1 132 end 133 end 134 fn saypb to void 135 r = write 1 pb 0 get pn 0 136 end 137 fn die c ulong m view uchar * to void 138 say m 139 exit int c 140 end 141 fn dieio to void 142 say MIO 143 saypb 144 say NL 145 exit 5 146 end 147 fn pclear to void 148 put pn 0 0 149 end 150 fn pbyte b uchar to void 151 n = get pn 0 152 if ge n 4095 153 dieio 154 end 155 put pb n b 156 put pn 0 add n 1 157 end 158 fn ptext s view uchar * to void 159 for i ulong len s 160 pbyte get s i 161 end 162 end 163 note Slot k is 512 bytes of sb at k * 512, its length in sl. 164 fn pslot k ulong to void 165 o = mul k 512 166 for i ulong get sl k 167 pbyte get sb add o i 168 end 169 end 170 fn keepat k ulong to void 171 n = get pn 0 172 if gt n 512 173 dieio 174 end 175 o = mul k 512 176 for i ulong n 177 put sb add o i get pb i 178 end 179 put sl k n 180 end 181 fn argslot i ulong k ulong to void 182 r = argread i pb 0 512 183 if le r 0 184 die 2 MUSAGE 185 end 186 put pn 0 ulong r 187 keepat k 188 end 189 note slot k = slot base followed by text s 190 fn under k ulong base ulong s view uchar * to void 191 pclear 192 pslot base 193 ptext s 194 keepat k 195 end 196 fn aclear to void 197 put ap 0 2 198 put ap 1 0 199 end 200 fn apb to void 201 p = get ap 0 202 n = get pn 0 203 if or gt add add p n 2 len av ge get ap 1 64 204 dieio 205 end 206 put av p uchar and n 255 207 put av add p 1 uchar shr n 8 208 for i ulong n 209 put av add add p 2 i get pb i 210 end 211 put ap 0 add add p 2 n 212 put ap 1 add get ap 1 1 213 end 214 fn atext s view uchar * to void 215 pclear 216 ptext s 217 apb 218 end 219 fn aslot k ulong to void 220 pclear 221 pslot k 222 apb 223 end 224 fn popen k ulong fl int to int 225 pclear 226 pslot k 227 r = fopen pb 0 get pn 0 fl 420 228 if lt r 0 229 dieio 230 end 231 ret int r 232 end 233 fn redir s int d int to void 234 if ne s d 235 if ne dupfd s d 0 long d 236 exit 127 237 end 238 end 239 end 240 note Run the packet in av with stdin fi and stdout fo (-1 inherits); return the exit status, or 241 note 256 + the signal number when the child was killed. 242 fn spawn fi int fo int to ulong 243 put av 0 uchar and get ap 1 255 244 put av 1 uchar shr get ap 1 8 245 pid = fork 246 if lt pid 0 247 dieio 248 end 249 if eq pid 0 250 if ge fi 0 251 redir fi 0 252 end 253 if ge fo 0 254 redir fo 1 255 end 256 r = execprog av 0 get ap 0 257 exit 127 258 end 259 if ge fi 0 260 r = fclose fi 261 end 262 if ge fo 0 263 r = fclose fo 264 end 265 w = waitpid int pid stb 0 4 0 266 if ne w long pid 267 dieio 268 end 269 if ne get stb 0 0 270 ret add 256 ulong and get stb 0 127 271 end 272 ret ulong get stb 1 273 end 274 fn tool fi int fo int to void 275 x = spawn fi fo 276 if ne x 0 277 say MTOOL 278 saynum x 279 say NL 280 exit 6 281 end 282 end 283 fn waitok pid long to void 284 w = waitpid int pid stb 0 4 0 285 bad = or ne get stb 0 0 ne get stb 1 0 286 if or ne w pid bad 287 say MTOOL 288 saynum ulong get stb 1 289 say NL 290 exit 6 291 end 292 end 293 note Run the packet with stdout read back through a pipe into cap (at most 4096 bytes). 294 fn capture to void 295 put av 0 uchar and get ap 1 255 296 put av 1 uchar shr get ap 1 8 297 pf = new uchar 8 0 298 if ne pipefds pf 0 8 0 0 299 dieio 300 end 301 rd = int or ulong get pf 0 shl ulong get pf 1 8 302 wr = int or ulong get pf 4 shl ulong get pf 5 8 303 pid = fork 304 if lt pid 0 305 dieio 306 end 307 if eq pid 0 308 r = fclose rd 309 redir wr 1 310 r = execprog av 0 get ap 0 311 exit 127 312 end 313 r = fclose wr 314 n = ulong 0 315 k = long 1 316 while gt k 0 317 k = read rd cap n sub len cap n 318 if gt k 0 319 n = add n ulong k 320 end 321 end 322 r = fclose rd 323 put capn 0 n 324 waitok pid 325 end 326 327 note ---- whole files --------------------------------------------------------------------------- 328 fn slurp k ulong to void 329 fd = popen k 0 330 n = ulong 0 331 k2 = long 1 332 while gt k2 0 333 if eq n len inb 334 dieio 335 end 336 k2 = read fd inb n sub len inb n 337 if lt k2 0 338 dieio 339 end 340 n = add n ulong k2 341 end 342 r = fclose fd 343 put bn 0 n 344 end 345 fn obyte b uchar to void 346 n = get obn 0 347 if ge n len ob 348 dieio 349 end 350 put ob n b 351 put obn 0 add n 1 352 end 353 fn otext s view uchar * to void 354 for i ulong len s 355 obyte get s i 356 end 357 end 358 fn obig o ulong n ulong to void 359 for i ulong n 360 obyte get inb add o i 361 end 362 end 363 fn olay to void 364 for i ulong get lan 0 365 obyte get lay i 366 end 367 end 368 fn ofns to void 369 for i ulong get fnn 0 370 obyte get fns i 371 end 372 end 373 note Write ob to slot k, created or truncated. 374 fn spill k ulong to void 375 fd = popen k 577 376 n = get obn 0 377 p = ulong 0 378 while lt p n 379 r = write fd ob p sub n p 380 if le r 0 381 dieio 382 end 383 p = add p ulong r 384 end 385 if ne fclose fd 0 386 dieio 387 end 388 put obn 0 0 389 end 390 391 note ---- line tests on inb ----------------------------------------------------------------------- 392 note end of the line starting at o (index of its LF, or bn) 393 fn eol o ulong to ulong 394 n = get bn 0 395 e = o 396 while lt e n 397 if eq get inb e 10 398 ret e 399 end 400 e = add e 1 401 end 402 ret n 403 end 404 fn lineis o ulong e ulong s view uchar * to bool 405 if ne sub e o len s 406 ret false 407 end 408 for i ulong len s 409 if ne get inb add o i get s i 410 ret false 411 end 412 end 413 ret true 414 end 415 fn starts o ulong e ulong s view uchar * to bool 416 if lt sub e o len s 417 ret false 418 end 419 for i ulong len s 420 if ne get inb add o i get s i 421 ret false 422 end 423 end 424 ret true 425 end 426 fn wordch c ulong to bool 427 a = and ge c 48 le c 57 428 b = and ge c 65 le c 90 429 d = and ge c 97 le c 122 430 ret or or a b or d eq c 95 431 end 432 note position (0..9) of inb[o..e) among the words of OLDW, or 10 433 fn oldword o ulong e ulong to ulong 434 w = ulong 0 435 s = ulong 0 436 for i ulong len OLDW 437 if eq get OLDW i 32 438 if eq sub i s sub e o 439 same = true 440 for j ulong sub i s 441 if ne get OLDW add s j get inb add o j 442 same = false 443 end 444 end 445 if same 446 ret w 447 end 448 end 449 w = add w 1 450 s = add i 1 451 end 452 end 453 ret 10 454 end 455 fn fbyte b uchar to void 456 n = get fnn 0 457 if ge n len fns 458 dieio 459 end 460 put fns n b 461 put fnn 0 add n 1 462 end 463 fn newword w ulong to void 464 k = ulong 0 465 for i ulong len NEWW 466 c = get NEWW i 467 if eq c 32 468 k = add k 1 469 else 470 if eq k w 471 fbyte c 472 end 473 end 474 end 475 end 476 note one functions line inb[o..e) plus its LF (when e < bn) 477 fn fnline o ulong e ulong to void 478 p = o 479 if starts o e EXPFN 480 p = add o 7 481 end 482 if starts o e NOTE 483 for i ulong sub e p 484 fbyte get inb add p i 485 end 486 else 487 while lt p e 488 if wordch ulong get inb p 489 q = p 490 while and lt q e wordch ulong get inb q 491 q = add q 1 492 end 493 w = oldword p q 494 if lt w 10 495 newword w 496 else 497 for i ulong sub q p 498 fbyte get inb add p i 499 end 500 end 501 p = q 502 else 503 fbyte get inb p 504 p = add p 1 505 end 506 end 507 end 508 if lt e get bn 0 509 fbyte 10 510 end 511 end 512 fn lbyte b uchar to void 513 n = get lan 0 514 if ge n len lay 515 dieio 516 end 517 put lay n b 518 put lan 0 add n 1 519 end 520 note Split the SHA source in inb into lay and fns (step 3). 521 fn split to void 522 n = get bn 0 523 put lan 0 0 524 put fnn 0 0 525 o = ulong 0 526 inl = false 527 while lt o n 528 e = eol o 529 if inl 530 for i ulong sub e o 531 lbyte get inb add o i 532 end 533 lbyte 10 534 if lineis o e LEND 535 inl = false 536 end 537 else 538 if lineis o e LSTART 539 inl = true 540 for i ulong sub e o 541 lbyte get inb add o i 542 end 543 lbyte 10 544 else 545 if not lineis o e OM2 546 fnline o e 547 end 548 end 549 end 550 o = add e 1 551 end 552 end 553 note Append ollm.om (in inb) to ob without `om2` and with main renamed; return the main count. 554 fn oollm to ulong 555 n = get bn 0 556 c = ulong 0 557 o = ulong 0 558 while lt o n 559 e = eol o 560 if lineis o e MAINL 561 otext WPOLLM 562 c = add c 1 563 else 564 if not lineis o e OM2 565 obig o sub e o 566 if lt e n 567 obyte 10 568 end 569 end 570 end 571 o = add e 1 572 end 573 ret c 574 end 575 576 note ---- steps ----------------------------------------------------------------------------------- 577 note slots: 0 REPO, 1 OUT, 2 OMC, 3 OMEGA_MV, 4 CORE, 5 scratch, 6 source, 7 vendored, 8 all, 9 new 578 note true when the captured output starts with the 64 hex digits s 579 fn capis s view uchar * to bool 580 if lt get capn 0 64 581 ret false 582 end 583 for i ulong 64 584 if ne get cap i get s i 585 ret false 586 end 587 end 588 ret true 589 end 590 fn stepomc to void 591 aclear 592 atext SUM 593 aslot 2 594 capture 595 if not capis OMCPIN 596 die 3 MOMCP 597 end 598 end 599 fn stepsrc to void 600 under 6 1 FSRC 601 aclear 602 atext GIT 603 atext GC 604 aslot 3 605 atext GSHOW 606 atext PIN 607 tool -1 popen 6 577 608 aclear 609 atext SUM 610 aslot 6 611 capture 612 if not capis SHASRC 613 die 3 MSHA 614 end 615 end 616 note `OUT/wpcheck sum REPO s` (vendored Omega SHA-256) must print the pin p. 617 fn netpin s view uchar * p view uchar * to void 618 under 5 1 FCK 619 aclear 620 aslot 5 621 atext CSUM 622 under 5 0 s 623 aslot 5 624 capture 625 if not capis p 626 say MNET 627 pclear 628 pslot 5 629 saypb 630 say NL 631 exit 3 632 end 633 end 634 note append the whole file REPO s to ob 635 fn ofile s view uchar * to void 636 under 5 0 s 637 slurp 5 638 obig 0 get bn 0 639 end 640 fn stepollm to void 641 netpin SHTTP NPHTTP 642 netpin SJSON NPJSON 643 netpin SJSONW NPJSONW 644 otext OM2NL 645 ofile SHTTP 646 ofile SJSON 647 ofile SJSONW 648 ofile SMATH 649 ofile SDATA 650 ofile SLPOOL 651 ofile SMODEL 652 ofile SADAM 653 ofile SCKPT 654 ofile SBPE 655 ofile SCLI 656 ofile SLIO 657 ofile SSERVE 658 ofile SNOGPU 659 under 8 1 FOLLM 660 spill 8 661 under 9 1 FONEW 662 compile FOL 663 end 664 fn stepvend to void 665 slurp 6 666 split 667 under 5 1 FLAY 668 olay 669 spill 5 670 under 5 1 FFNS 671 ofns 672 spill 5 673 under 7 1 FVEN 674 otext OM2NL 675 olay 676 ofns 677 spill 7 678 under 5 1 FDIF 679 aclear 680 atext DIFF 681 atext DU 682 aslot 6 683 aslot 7 684 x = spawn -1 popen 5 577 685 if ne x 1 686 say MTOOL 687 saynum x 688 say NL 689 exit 6 690 end 691 end 692 fn compose to void 693 under 5 1 FOLLM 694 slurp 5 695 otext OM2NL 696 olay 697 c = oollm 698 if ne c 1 699 say MMAIN 700 saynum c 701 say NL 702 exit 4 703 end 704 ofns 705 under 5 0 FWPS 706 slurp 5 707 obig 0 get bn 0 708 under 8 1 FWALL 709 spill 8 710 end 711 fn composeck to void 712 otext OM2NL 713 olay 714 ofns 715 under 5 0 FCKS 716 slurp 5 717 obig 0 get bn 0 718 under 8 1 FCALL 719 spill 8 720 end 721 note Compile slot 8 into slot 9 (the .new file), then rename it to dst (a text under OUT). 722 fn compile dst view uchar * to void 723 aclear 724 atext TSET 725 atext TC 726 aslot 4 727 atext NICE 728 atext NN 729 atext N19 730 aslot 2 731 x = spawn popen 8 0 popen 9 577 732 if ne x 0 733 pclear 734 pslot 9 735 r = unlink pb 0 get pn 0 736 say MOMC 737 saynum x 738 say NL 739 exit int x 740 end 741 pclear 742 pslot 9 743 if ne chmod pb 0 get pn 0 493 0 744 dieio 745 end 746 under 5 1 dst 747 aclear 748 aslot 9 749 aslot 5 750 put av 0 2 751 put av 1 0 752 if ne renames av 0 get ap 0 0 0 753 dieio 754 end 755 end 756 fn main to int 757 if ne argcnt 6 758 die 2 MUSAGE 759 end 760 for i ulong 5 761 argslot add i 1 i 762 end 763 pclear 764 pslot 1 765 r = makedir pb 0 get pn 0 493 766 if and lt r 0 ne r -17 767 dieio 768 end 769 stepomc 770 stepsrc 771 stepvend 772 composeck 773 under 9 1 FCNEW 774 compile FCK 775 stepollm 776 compose 777 under 9 1 FWNEW 778 compile FWP 779 aclear 780 atext SUM 781 aslot 2 782 aslot 6 783 under 5 1 FOLLM 784 aslot 5 785 under 5 1 FOL 786 aslot 5 787 under 5 1 FCALL 788 aslot 5 789 under 5 1 FCK 790 aslot 5 791 under 5 1 FWALL 792 aslot 5 793 under 5 1 FWP 794 aslot 5 795 tool -1 -1 796 say MOK 797 ret 0 798 end