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 / collective / admit_p0.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note aien-train#26 P0 refusal contract (DRA-15, Spark hive card t_8cf72aaf). |
| 3 | note Admits ONE synthetic bank descriptor and ONE microjob request before any |
| 4 | note adapter arithmetic. Contract, codes, check order and the 46 cases: |
| 5 | note native/collective/fixtures/admission_v0.json (committed before this file). |
| 6 | note The merged pilot shared_bank_p0.om is not changed; this unit reuses its |
| 7 | note numbers (B, x, U_i, V_i, scores) as the baseline descriptor. |
| 8 | note Refusal = nonzero status, no response written, counters unchanged. |
| 9 | note Score and permission are distinct abstract types: passing one where the |
| 10 | note other is needed is a compile refusal (omc error 7); a permission entry |
| 11 | note that is not 0 or 1 (scores stored as permissions) is a runtime refusal. |
| 12 | note Synthetic P0 admission only: not AEGIS authority, not a router, no model, |
| 13 | note no checkpoint, no GPU. Names are at most 8 characters (omc error 13). |
| 14 | om2 |
| 15 | abstract perm ulong |
| 16 | abstract score ulong |
| 17 | |
| 18 | const NCAND ulong 8 |
| 19 | const KMAX ulong 3 |
| 20 | const VMAX long 65536 |
| 21 | const NCASE ulong 46 |
| 22 | note FNV-1a 64 identities computed by Wolfram (evidence/COLLECTIVE-P0-ADMIT): |
| 23 | note BASEID of B, ALTID of B with B[4]=1, OVRID of B with B[0]=65537. |
| 24 | const BASEID ulong 10035045484153181716 |
| 25 | const ALTID ulong 9153321889483684885 |
| 26 | const OVRID ulong 9990611769663005102 |
| 27 | |
| 28 | note Descriptor Dsc: 0 rank, 1 rows, 2 cols, 3 base identity, 4 generation. |
| 29 | note Request Req: 0 rank, 1 rows, 2 cols, 3 base identity, 4 generation, |
| 30 | note 5 active count, 6 mode (0 explicit indices, 1 select top-k by score). |
| 31 | global Dsc ulong 8 |
| 32 | global Req ulong 8 |
| 33 | global Ract ulong 4 |
| 34 | global Rph long 4 |
| 35 | global B long 6 |
| 36 | global U long 16 |
| 37 | global V long 24 |
| 38 | global X long 3 |
| 39 | global PermA ulong 8 |
| 40 | global ScoreA ulong 8 |
| 41 | global Cgen ulong 8 |
| 42 | global PlanA ulong 4 |
| 43 | global PlanP long 4 |
| 44 | global Yv long 2 |
| 45 | global Counts ulong 2 |
| 46 | global Exp long 64 |
| 47 | |
| 48 | fn permmk x ulong to perm |
| 49 | ret seal perm x |
| 50 | end |
| 51 | |
| 52 | fn scoremk x ulong to score |
| 53 | ret seal score x |
| 54 | end |
| 55 | |
| 56 | fn permat id ulong to perm |
| 57 | ret permmk get PermA id |
| 58 | end |
| 59 | |
| 60 | fn scoreat id ulong to score |
| 61 | ret scoremk get ScoreA id |
| 62 | end |
| 63 | |
| 64 | note A permission is valid only as 0 (denied) or 1 (granted). |
| 65 | fn permbad p perm to bool |
| 66 | ret gt open p 1 |
| 67 | end |
| 68 | |
| 69 | fn denied p perm to bool |
| 70 | ret ne open p 1 |
| 71 | end |
| 72 | |
| 73 | fn above a score b score to bool |
| 74 | ret gt open a open b |
| 75 | end |
| 76 | |
| 77 | note Baseline descriptor and request. Response Yv and Counts are not touched. |
| 78 | fn reset to void |
| 79 | put B 0 2 |
| 80 | put B 1 -1 |
| 81 | put B 2 3 |
| 82 | put B 3 1 |
| 83 | put B 4 0 |
| 84 | put B 5 -2 |
| 85 | for id ulong 8 |
| 86 | sid = long id |
| 87 | ui = mul id 2 |
| 88 | vi = mul id 3 |
| 89 | put U ui sub sid 3 |
| 90 | put U add ui 1 add sid 1 |
| 91 | put V vi 1 |
| 92 | put V add vi 1 sub 3 sid |
| 93 | put V add vi 2 -1 |
| 94 | put PermA id 1 |
| 95 | put Cgen id 7 |
| 96 | end |
| 97 | put ScoreA 0 4 |
| 98 | put ScoreA 1 11 |
| 99 | put ScoreA 2 7 |
| 100 | put ScoreA 3 9 |
| 101 | put ScoreA 4 8 |
| 102 | put ScoreA 5 0 |
| 103 | put ScoreA 6 3 |
| 104 | put ScoreA 7 2 |
| 105 | put X 0 2 |
| 106 | put X 1 3 |
| 107 | put X 2 5 |
| 108 | put Dsc 0 1 |
| 109 | put Dsc 1 2 |
| 110 | put Dsc 2 3 |
| 111 | put Dsc 3 BASEID |
| 112 | put Dsc 4 7 |
| 113 | put Req 0 1 |
| 114 | put Req 1 2 |
| 115 | put Req 2 3 |
| 116 | put Req 3 BASEID |
| 117 | put Req 4 7 |
| 118 | put Req 5 2 |
| 119 | put Req 6 0 |
| 120 | put Ract 0 1 |
| 121 | put Ract 1 3 |
| 122 | put Ract 2 0 |
| 123 | put Ract 3 0 |
| 124 | put Rph 0 1 |
| 125 | put Rph 1 -1 |
| 126 | put Rph 2 1 |
| 127 | put Rph 3 1 |
| 128 | end |
| 129 | |
| 130 | note Base identity: FNV-1a 64 over B row-major, 8 little-endian bytes each. |
| 131 | fn bdigest to ulong |
| 132 | h = ulong 14695981039346656037 |
| 133 | for i ulong 6 |
| 134 | w = bitcast ulong get B i |
| 135 | for b ulong 8 |
| 136 | byt = and shr w mul b 8 255 |
| 137 | h = mul xor h byt 1099511628211 |
| 138 | end |
| 139 | end |
| 140 | ret h |
| 141 | end |
| 142 | |
| 143 | fn badval v long to bool |
| 144 | ret or lt v neg VMAX gt v VMAX |
| 145 | end |
| 146 | |
| 147 | note Range of x, B and the U/V of every planned candidate (first k slots). |
| 148 | fn rangebad k ulong to bool |
| 149 | for i ulong 3 |
| 150 | if badval get X i |
| 151 | ret true |
| 152 | end |
| 153 | end |
| 154 | for i ulong 6 |
| 155 | if badval get B i |
| 156 | ret true |
| 157 | end |
| 158 | end |
| 159 | for j ulong k |
| 160 | id = get PlanA j |
| 161 | ui = mul id 2 |
| 162 | vi = mul id 3 |
| 163 | for r ulong 2 |
| 164 | if badval get U add ui r |
| 165 | ret true |
| 166 | end |
| 167 | end |
| 168 | for c ulong 3 |
| 169 | if badval get V add vi c |
| 170 | ret true |
| 171 | end |
| 172 | end |
| 173 | end |
| 174 | ret false |
| 175 | end |
| 176 | |
| 177 | note Highest-score permitted candidate not in the used mask; 8 when none. |
| 178 | fn pick used ulong to ulong |
| 179 | best = ulong 8 |
| 180 | bsc = scoremk 0 |
| 181 | for id ulong 8 |
| 182 | if denied permat id |
| 183 | continue |
| 184 | end |
| 185 | if ne and used shl ulong 1 id 0 |
| 186 | continue |
| 187 | end |
| 188 | s = scoreat id |
| 189 | if eq best 8 |
| 190 | best = id |
| 191 | bsc = s |
| 192 | continue |
| 193 | end |
| 194 | if above s bsc |
| 195 | best = id |
| 196 | bsc = s |
| 197 | end |
| 198 | end |
| 199 | ret best |
| 200 | end |
| 201 | |
| 202 | note Shape: descriptor 2x3, request equal to the descriptor. |
| 203 | fn shapebad to bool |
| 204 | d = or ne get Dsc 1 2 ne get Dsc 2 3 |
| 205 | r = or ne get Req 1 get Dsc 1 ne get Req 2 get Dsc 2 |
| 206 | ret or d r |
| 207 | end |
| 208 | |
| 209 | fn dupat j ulong id ulong to bool |
| 210 | for i ulong j |
| 211 | if eq get PlanA i id |
| 212 | ret true |
| 213 | end |
| 214 | end |
| 215 | ret false |
| 216 | end |
| 217 | |
| 218 | note Admission. Writes only the internal plan; never Yv or Counts. |
| 219 | note Codes and order: fixtures/admission_v0.json "codes" and "check_order". |
| 220 | fn admit to long |
| 221 | if or ne get Dsc 0 1 ne get Req 0 get Dsc 0 |
| 222 | ret -4 |
| 223 | end |
| 224 | if shapebad |
| 225 | ret -5 |
| 226 | end |
| 227 | if or eq get Dsc 3 0 eq get Req 3 0 |
| 228 | ret -6 |
| 229 | end |
| 230 | if ne get Req 3 get Dsc 3 |
| 231 | ret -7 |
| 232 | end |
| 233 | if ne bdigest get Dsc 3 |
| 234 | ret -7 |
| 235 | end |
| 236 | if ne get Req 4 get Dsc 4 |
| 237 | ret -8 |
| 238 | end |
| 239 | for i ulong 8 |
| 240 | if permbad permat i |
| 241 | ret -13 |
| 242 | end |
| 243 | end |
| 244 | md = get Req 6 |
| 245 | if gt md 1 |
| 246 | ret -16 |
| 247 | end |
| 248 | k = get Req 5 |
| 249 | if eq k 0 |
| 250 | ret -10 |
| 251 | end |
| 252 | if gt k KMAX |
| 253 | ret -11 |
| 254 | end |
| 255 | used = ulong 0 |
| 256 | for j ulong k |
| 257 | id = get Ract j |
| 258 | if eq md 1 |
| 259 | id = pick used |
| 260 | if ge id NCAND |
| 261 | ret -14 |
| 262 | end |
| 263 | used = or used shl ulong 1 id |
| 264 | end |
| 265 | put PlanA j id |
| 266 | put PlanP j get Rph j |
| 267 | end |
| 268 | for j ulong k |
| 269 | id = get PlanA j |
| 270 | if ge id NCAND |
| 271 | ret -1 |
| 272 | end |
| 273 | if denied permat id |
| 274 | ret -2 |
| 275 | end |
| 276 | if ne get Cgen id get Dsc 4 |
| 277 | ret -9 |
| 278 | end |
| 279 | ph = get PlanP j |
| 280 | if and ne ph 1 ne ph -1 |
| 281 | ret -3 |
| 282 | end |
| 283 | if dupat j id |
| 284 | ret -12 |
| 285 | end |
| 286 | end |
| 287 | if rangebad k |
| 288 | ret -15 |
| 289 | end |
| 290 | ret 0 |
| 291 | end |
| 292 | |
| 293 | note y = B.x + sum_j phase_j U_j (V_j . x), into a local, then published. |
| 294 | fn bxrow r ulong to long |
| 295 | s = long 0 |
| 296 | for c ulong 3 |
| 297 | s = add s mul get B add mul r 3 c get X c |
| 298 | end |
| 299 | ret s |
| 300 | end |
| 301 | |
| 302 | fn vdot id ulong to long |
| 303 | vi = mul id 3 |
| 304 | dot = long 0 |
| 305 | for c ulong 3 |
| 306 | dot = add dot mul get V add vi c get X c |
| 307 | end |
| 308 | ret dot |
| 309 | end |
| 310 | |
| 311 | fn compute k ulong to void |
| 312 | acc = new long 2 0 |
| 313 | put acc 0 bxrow 0 |
| 314 | put acc 1 bxrow 1 |
| 315 | for j ulong k |
| 316 | id = get PlanA j |
| 317 | f = mul get PlanP j vdot id |
| 318 | ui = mul id 2 |
| 319 | for r ulong 2 |
| 320 | d = mul f get U add ui r |
| 321 | put acc r add get acc r d |
| 322 | end |
| 323 | end |
| 324 | put Yv 0 get acc 0 |
| 325 | put Yv 1 get acc 1 |
| 326 | put Counts 0 add get Counts 0 1 |
| 327 | put Counts 1 add get Counts 1 k |
| 328 | end |
| 329 | |
| 330 | fn run to long |
| 331 | st = admit |
| 332 | if ne st 0 |
| 333 | ret st |
| 334 | end |
| 335 | compute get Req 5 |
| 336 | ret 0 |
| 337 | end |
| 338 | |
| 339 | note The 46 cases of fixtures/admission_v0.json, each from the baseline. |
| 340 | fn setcase n ulong to void |
| 341 | reset |
| 342 | if eq n 1 |
| 343 | put Dsc 0 2 |
| 344 | put Req 0 2 |
| 345 | end |
| 346 | if eq n 2 |
| 347 | put Req 0 2 |
| 348 | end |
| 349 | if eq n 3 |
| 350 | put Dsc 1 3 |
| 351 | put Req 1 3 |
| 352 | end |
| 353 | if eq n 4 |
| 354 | put Dsc 2 2 |
| 355 | put Req 2 2 |
| 356 | end |
| 357 | if eq n 5 |
| 358 | put Req 1 1 |
| 359 | end |
| 360 | if eq n 6 |
| 361 | put Req 2 4 |
| 362 | end |
| 363 | if eq n 7 |
| 364 | put Dsc 3 0 |
| 365 | put Req 3 0 |
| 366 | end |
| 367 | if eq n 8 |
| 368 | put Req 3 0 |
| 369 | end |
| 370 | if eq n 9 |
| 371 | put Req 3 xor BASEID 1 |
| 372 | end |
| 373 | if eq n 10 |
| 374 | put B 4 1 |
| 375 | end |
| 376 | if eq n 11 |
| 377 | put B 4 1 |
| 378 | put Dsc 3 ALTID |
| 379 | put Req 3 ALTID |
| 380 | end |
| 381 | if eq n 12 |
| 382 | put Req 4 6 |
| 383 | end |
| 384 | if eq n 13 |
| 385 | put Cgen 3 6 |
| 386 | end |
| 387 | if eq n 14 |
| 388 | put Cgen 1 8 |
| 389 | end |
| 390 | if eq n 15 |
| 391 | put Cgen 5 6 |
| 392 | end |
| 393 | if eq n 16 |
| 394 | put Dsc 4 9 |
| 395 | put Req 4 9 |
| 396 | for i ulong 8 |
| 397 | put Cgen i 9 |
| 398 | end |
| 399 | end |
| 400 | if eq n 17 |
| 401 | put Req 5 0 |
| 402 | end |
| 403 | if eq n 18 |
| 404 | put Req 5 4 |
| 405 | put Ract 0 0 |
| 406 | put Ract 1 2 |
| 407 | put Ract 2 4 |
| 408 | put Ract 3 6 |
| 409 | put Rph 1 1 |
| 410 | end |
| 411 | if eq n 19 |
| 412 | put Req 5 1 |
| 413 | put Ract 0 6 |
| 414 | put Rph 0 -1 |
| 415 | end |
| 416 | if eq n 20 |
| 417 | put Req 5 3 |
| 418 | put Ract 0 0 |
| 419 | put Ract 1 4 |
| 420 | put Ract 2 7 |
| 421 | end |
| 422 | if eq n 21 |
| 423 | put Ract 1 8 |
| 424 | end |
| 425 | if eq n 22 |
| 426 | put Ract 1 18446744073709551615 |
| 427 | end |
| 428 | if eq n 23 |
| 429 | put Ract 0 7 |
| 430 | end |
| 431 | if eq n 24 |
| 432 | put PermA 3 0 |
| 433 | end |
| 434 | if eq n 25 |
| 435 | put PermA 2 0 |
| 436 | end |
| 437 | if eq n 26 |
| 438 | put Rph 0 0 |
| 439 | end |
| 440 | if eq n 27 |
| 441 | put Rph 1 2 |
| 442 | end |
| 443 | if eq n 28 |
| 444 | put Rph 0 -1 |
| 445 | end |
| 446 | if eq n 29 |
| 447 | put Ract 0 3 |
| 448 | end |
| 449 | if eq n 30 |
| 450 | put Req 5 3 |
| 451 | put Ract 2 1 |
| 452 | put Rph 1 1 |
| 453 | end |
| 454 | if eq n 31 |
| 455 | for i ulong 8 |
| 456 | put PermA i get ScoreA i |
| 457 | put ScoreA i 1 |
| 458 | end |
| 459 | end |
| 460 | if eq n 32 |
| 461 | put PermA 5 2 |
| 462 | end |
| 463 | if eq n 33 |
| 464 | put Req 6 1 |
| 465 | put Rph 1 1 |
| 466 | end |
| 467 | if eq n 34 |
| 468 | put Req 6 1 |
| 469 | put Req 5 1 |
| 470 | put PermA 1 0 |
| 471 | end |
| 472 | if eq n 35 |
| 473 | put Req 6 1 |
| 474 | put Req 5 3 |
| 475 | end |
| 476 | if eq n 36 |
| 477 | put Req 6 1 |
| 478 | put Req 5 1 |
| 479 | for i ulong 8 |
| 480 | put PermA i 0 |
| 481 | end |
| 482 | end |
| 483 | if eq n 37 |
| 484 | put Req 6 1 |
| 485 | put Req 5 3 |
| 486 | for i ulong 8 |
| 487 | put PermA i 0 |
| 488 | end |
| 489 | put PermA 0 1 |
| 490 | put PermA 5 1 |
| 491 | end |
| 492 | if eq n 38 |
| 493 | put Req 6 2 |
| 494 | end |
| 495 | if eq n 39 |
| 496 | put X 0 65536 |
| 497 | put X 1 -65536 |
| 498 | put X 2 65536 |
| 499 | end |
| 500 | if eq n 40 |
| 501 | put X 0 65537 |
| 502 | end |
| 503 | if eq n 41 |
| 504 | put X 2 4611686018427387904 |
| 505 | end |
| 506 | if eq n 42 |
| 507 | put U 6 -65537 |
| 508 | end |
| 509 | if eq n 43 |
| 510 | put B 0 65537 |
| 511 | put Dsc 3 OVRID |
| 512 | put Req 3 OVRID |
| 513 | end |
| 514 | if eq n 44 |
| 515 | put U 10 70000 |
| 516 | end |
| 517 | if eq n 45 |
| 518 | put Req 6 1 |
| 519 | put Cgen 3 6 |
| 520 | end |
| 521 | end |
| 522 | |
| 523 | note Precommitted expect_status of every case (fixtures/admission_v0.json). |
| 524 | fn fillexp to void |
| 525 | put Exp 0 0 |
| 526 | put Exp 1 -4 |
| 527 | put Exp 2 -4 |
| 528 | put Exp 3 -5 |
| 529 | put Exp 4 -5 |
| 530 | put Exp 5 -5 |
| 531 | put Exp 6 -5 |
| 532 | put Exp 7 -6 |
| 533 | put Exp 8 -6 |
| 534 | put Exp 9 -7 |
| 535 | put Exp 10 -7 |
| 536 | put Exp 11 0 |
| 537 | put Exp 12 -8 |
| 538 | put Exp 13 -9 |
| 539 | put Exp 14 -9 |
| 540 | put Exp 15 0 |
| 541 | put Exp 16 0 |
| 542 | put Exp 17 -10 |
| 543 | put Exp 18 -11 |
| 544 | put Exp 19 0 |
| 545 | put Exp 20 0 |
| 546 | put Exp 21 -1 |
| 547 | put Exp 22 -1 |
| 548 | put Exp 23 0 |
| 549 | put Exp 24 -2 |
| 550 | put Exp 25 0 |
| 551 | put Exp 26 -3 |
| 552 | put Exp 27 -3 |
| 553 | put Exp 28 0 |
| 554 | put Exp 29 -12 |
| 555 | put Exp 30 -12 |
| 556 | put Exp 31 -13 |
| 557 | put Exp 32 -13 |
| 558 | put Exp 33 0 |
| 559 | put Exp 34 0 |
| 560 | put Exp 35 0 |
| 561 | put Exp 36 -14 |
| 562 | put Exp 37 -14 |
| 563 | put Exp 38 -16 |
| 564 | put Exp 39 0 |
| 565 | put Exp 40 -15 |
| 566 | put Exp 41 -15 |
| 567 | put Exp 42 -15 |
| 568 | put Exp 43 -15 |
| 569 | put Exp 44 0 |
| 570 | put Exp 45 -9 |
| 571 | end |
| 572 | |
| 573 | note Self-test: exit n+1 when case n returns another status, 47..50 when the |
| 574 | note final response or counters differ, 0 when all agree. The independent |
| 575 | note judge is native/collective/admit/run.sh with the Wolfram expectations. |
| 576 | fn main to int |
| 577 | fillexp |
| 578 | for n ulong NCASE |
| 579 | setcase n |
| 580 | s = run |
| 581 | if ne s get Exp n |
| 582 | ret int add n 1 |
| 583 | end |
| 584 | end |
| 585 | if ne get Yv 0 10 |
| 586 | ret 47 |
| 587 | end |
| 588 | if ne get Yv 1 10 |
| 589 | ret 48 |
| 590 | end |
| 591 | if ne get Counts 0 14 |
| 592 | ret 49 |
| 593 | end |
| 594 | if ne get Counts 1 28 |
| 595 | ret 50 |
| 596 | end |
| 597 | ret 0 |
| 598 | end |