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 / tests / adtrain / mutate.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note Native source fault injector for native/adtrain/mlp.om. |
| 3 | note Read one ASCII mode byte then mlp.om. Exactly one match is required. |
| 4 | note Mode 0 reverses the update direction, 1 drops the data-hash binding check, |
| 5 | note 2 drops the checkpoint checksum check. tests/adtrain/run-adtrain.sh must |
| 6 | note catch each one. |
| 7 | global Input uchar 65536 |
| 8 | global Mode ulong 1 |
| 9 | text SN "p = sub get MP i mul lr get MG i" |
| 10 | text SR "p = add get MP i mul lr get MG i" |
| 11 | text MN "if ne mlget 48 mlhash\n" |
| 12 | text MR "if false\n" |
| 13 | text RN "if ne mlget 528 mlimgfnv 528\n" |
| 14 | text RR "if false\n" |
| 15 | |
| 16 | fn size to ulong |
| 17 | if eq get Mode 0 0 |
| 18 | ret len SN |
| 19 | end |
| 20 | if eq get Mode 0 1 |
| 21 | ret len MN |
| 22 | end |
| 23 | ret len RN |
| 24 | end |
| 25 | |
| 26 | fn patbyte i ulong to uchar |
| 27 | if eq get Mode 0 0 |
| 28 | ret get SN i |
| 29 | end |
| 30 | if eq get Mode 0 1 |
| 31 | ret get MN i |
| 32 | end |
| 33 | ret get RN i |
| 34 | end |
| 35 | |
| 36 | fn emit to void |
| 37 | if eq get Mode 0 0 |
| 38 | n = write 1 SR 0 len SR |
| 39 | if ne n long len SR |
| 40 | exit 74 |
| 41 | end |
| 42 | ret |
| 43 | end |
| 44 | if eq get Mode 0 1 |
| 45 | n = write 1 MR 0 len MR |
| 46 | if ne n long len MR |
| 47 | exit 74 |
| 48 | end |
| 49 | ret |
| 50 | end |
| 51 | n = write 1 RR 0 len RR |
| 52 | if ne n long len RR |
| 53 | exit 74 |
| 54 | end |
| 55 | end |
| 56 | |
| 57 | fn matches pos ulong to bool |
| 58 | for i ulong size |
| 59 | if ne get Input add pos i patbyte i |
| 60 | ret false |
| 61 | end |
| 62 | end |
| 63 | ret true |
| 64 | end |
| 65 | |
| 66 | fn main to int |
| 67 | p = ulong 0 |
| 68 | reading = true |
| 69 | while reading bound 65537 |
| 70 | if eq p 65536 |
| 71 | ret 75 |
| 72 | end |
| 73 | n = read 0 Input p sub 65536 p |
| 74 | if eq n 0 |
| 75 | reading = false |
| 76 | else |
| 77 | if lt n 0 |
| 78 | ret 74 |
| 79 | end |
| 80 | p = add p ulong n |
| 81 | end |
| 82 | end |
| 83 | if lt p 2 |
| 84 | ret 75 |
| 85 | end |
| 86 | m = get Input 0 |
| 87 | if or lt m 48 gt m 50 |
| 88 | ret 75 |
| 89 | end |
| 90 | put Mode 0 ulong sub m 48 |
| 91 | length = size |
| 92 | if le p length |
| 93 | ret 75 |
| 94 | end |
| 95 | found = ulong 0 |
| 96 | where = ulong 0 |
| 97 | for start ulong sub p length |
| 98 | pos = add start 1 |
| 99 | if matches pos |
| 100 | found = add found 1 |
| 101 | where = pos |
| 102 | end |
| 103 | end |
| 104 | if ne found 1 |
| 105 | ret 76 |
| 106 | end |
| 107 | n = write 1 Input 1 sub where 1 |
| 108 | if ne n long sub where 1 |
| 109 | ret 74 |
| 110 | end |
| 111 | emit |
| 112 | tail = add where length |
| 113 | n = write 1 Input tail sub p tail |
| 114 | if ne n long sub p tail |
| 115 | ret 74 |
| 116 | end |
| 117 | ret 0 |
| 118 | end |