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 / neuralese / nl1r-task / task.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note Frozen NL6-NL1R-20261028-1; imports unchanged capacity.om and wire.om. |
| 3 | note TC is shared task, seed, split; receiver reads only task plus explicit context. |
| 4 | global TC ulong 3 |
| 5 | global TL ulong 1 |
| 6 | |
| 7 | fn tpar id ulong to ulong |
| 8 | ret and xor xor id shr id 1 xor shr id 2 shr id 3 1 |
| 9 | end |
| 10 | fn tactive j ulong to bool |
| 11 | if eq get TC 0 1 |
| 12 | ret eq j 0 |
| 13 | end |
| 14 | if eq get TC 0 2 |
| 15 | ret ge j 2 |
| 16 | end |
| 17 | ret true |
| 18 | end |
| 19 | fn tprep id ulong to void |
| 20 | ninput id id |
| 21 | if eq get TC 0 1 |
| 22 | put NT 0 f64 tpar id |
| 23 | end |
| 24 | nsend |
| 25 | nrecv |
| 26 | note Inactive residuals are zero; their targets are not learned or communicated. |
| 27 | for j ulong 4 |
| 28 | if not tactive j |
| 29 | put NT j get NO j |
| 30 | end |
| 31 | end |
| 32 | end |
| 33 | fn tloss id ulong to f64 |
| 34 | tprep id |
| 35 | ret nloss |
| 36 | end |
| 37 | fn ttrain mask ulong to int |
| 38 | for epoch ulong 2000 |
| 39 | for id ulong 16 |
| 40 | if ne and shr mask id 1 0 |
| 41 | tprep id |
| 42 | ngrad |
| 43 | rc = nstep 0.1f64 |
| 44 | if ne rc 0 |
| 45 | ret rc |
| 46 | end |
| 47 | end |
| 48 | end |
| 49 | end |
| 50 | ret 0 |
| 51 | end |
| 52 | fn tclear to void |
| 53 | for i ulong 32 |
| 54 | put WB i uchar 0 |
| 55 | end |
| 56 | put TL 0 0 |
| 57 | end |
| 58 | fn tencode id ulong arm ulong variant ulong to int |
| 59 | tclear |
| 60 | if or gt id 15 or gt arm 4 gt variant 2 |
| 61 | ret 2 |
| 62 | end |
| 63 | if or eq variant 2 eq arm 3 |
| 64 | ret 0 |
| 65 | end |
| 66 | src = id |
| 67 | if eq variant 1 |
| 68 | src = and add id 1 15 |
| 69 | end |
| 70 | if eq arm 0 |
| 71 | v = src |
| 72 | if eq get TC 0 1 |
| 73 | v = tpar src |
| 74 | end |
| 75 | if eq get TC 0 2 |
| 76 | v = shr src 2 |
| 77 | end |
| 78 | put WB 0 uchar v |
| 79 | put TL 0 1 |
| 80 | ret 0 |
| 81 | end |
| 82 | if eq arm 4 |
| 83 | for j ulong 4 |
| 84 | put WB j uchar add and shr src j 1 48 |
| 85 | end |
| 86 | put TL 0 4 |
| 87 | ret 0 |
| 88 | end |
| 89 | ninput src src |
| 90 | nsend |
| 91 | v = ulong 0 |
| 92 | for j ulong 4 |
| 93 | h = get NH j |
| 94 | if not le fabs h 1.0f64 |
| 95 | ret 2 |
| 96 | end |
| 97 | q = ulong 0 |
| 98 | if eq arm 1 |
| 99 | note Exact frozen inference quantizer; not a straight-through training rule. |
| 100 | r = add div mul 3.0f64 add h 1.0f64 2.0f64 0.5f64 |
| 101 | q = ulong r |
| 102 | if gt q 3 |
| 103 | q = 3 |
| 104 | end |
| 105 | v = or v shl q mul j 2 |
| 106 | else |
| 107 | if ge h 0.0f64 |
| 108 | q = 1 |
| 109 | end |
| 110 | v = or v shl q j |
| 111 | end |
| 112 | end |
| 113 | put WB 0 uchar v |
| 114 | put TL 0 1 |
| 115 | ret 0 |
| 116 | end |
| 117 | fn tcanon context ulong to void |
| 118 | if eq get TC 0 1 |
| 119 | for j ulong 3 |
| 120 | put NO add j 1 0.0f64 |
| 121 | end |
| 122 | end |
| 123 | if eq get TC 0 2 |
| 124 | put NO 0 f64 and context 1 |
| 125 | put NO 1 f64 and shr context 1 1 |
| 126 | end |
| 127 | end |
| 128 | fn tbits value ulong context ulong to void |
| 129 | for j ulong 4 |
| 130 | put NO j f64 and shr value j 1 |
| 131 | end |
| 132 | tcanon context |
| 133 | end |
| 134 | fn tvalid arm ulong variant ulong context ulong bytes ulong to bool |
| 135 | if or gt get TC 0 2 or gt arm 4 gt variant 2 |
| 136 | ret false |
| 137 | end |
| 138 | if eq variant 2 |
| 139 | ret false |
| 140 | end |
| 141 | if eq get TC 0 2 |
| 142 | if gt context 3 |
| 143 | ret false |
| 144 | end |
| 145 | else |
| 146 | if ne context 0 |
| 147 | ret false |
| 148 | end |
| 149 | end |
| 150 | want = ulong 1 |
| 151 | if eq arm 3 |
| 152 | want = 0 |
| 153 | end |
| 154 | if eq arm 4 |
| 155 | want = 4 |
| 156 | end |
| 157 | ret eq bytes want |
| 158 | end |
| 159 | fn tdecode schema ulong arm ulong variant ulong context ulong bytes ulong effect ulong to int |
| 160 | note No sample ID, sender NX/NT, or training mask is consulted by this receiver. |
| 161 | if or ne schema 2 ne effect 0 |
| 162 | ret 2 |
| 163 | end |
| 164 | if ne get NSH 0 1 |
| 165 | ret 2 |
| 166 | end |
| 167 | if ne get NSH 1 4 |
| 168 | ret 2 |
| 169 | end |
| 170 | if ne get NSH 2 40 |
| 171 | ret 2 |
| 172 | end |
| 173 | if not tvalid arm variant context bytes |
| 174 | ret 2 |
| 175 | end |
| 176 | ret treceive arm context |
| 177 | end |
| 178 | fn treceive arm ulong context ulong to int |
| 179 | v = ulong get WB 0 |
| 180 | if eq arm 0 |
| 181 | limit = ulong 15 |
| 182 | if eq get TC 0 1 |
| 183 | limit = 1 |
| 184 | end |
| 185 | if eq get TC 0 2 |
| 186 | limit = 3 |
| 187 | end |
| 188 | if gt v limit |
| 189 | ret 2 |
| 190 | end |
| 191 | if eq get TC 0 2 |
| 192 | v = shl v 2 |
| 193 | end |
| 194 | tbits v context |
| 195 | ret 0 |
| 196 | end |
| 197 | if eq arm 4 |
| 198 | v = 0 |
| 199 | for j ulong 4 |
| 200 | c = get WB j |
| 201 | if not or eq c 48 eq c 49 |
| 202 | ret 2 |
| 203 | end |
| 204 | v = or v shl ulong sub c 48 j |
| 205 | end |
| 206 | if eq get TC 0 1 |
| 207 | v = tpar v |
| 208 | end |
| 209 | tbits v context |
| 210 | ret 0 |
| 211 | end |
| 212 | if and eq arm 2 gt v 15 |
| 213 | ret 2 |
| 214 | end |
| 215 | for j ulong 4 |
| 216 | h = 0.0f64 |
| 217 | if eq arm 1 |
| 218 | q = and shr v mul j 2 3 |
| 219 | h = div sub mul 2.0f64 f64 q 3.0f64 3.0f64 |
| 220 | end |
| 221 | if eq arm 2 |
| 222 | h = sub mul 2.0f64 f64 and shr v j 1 1.0f64 |
| 223 | end |
| 224 | put WH j h |
| 225 | end |
| 226 | note All schema, context, shape and bytes validated before output/state commit. |
| 227 | for j ulong 4 |
| 228 | put NH j get WH j |
| 229 | end |
| 230 | nrecv |
| 231 | tcanon context |
| 232 | ret 0 |
| 233 | end |
| 234 | fn tabst rc int to ulong |
| 235 | if ne rc 0 |
| 236 | ret 1 |
| 237 | end |
| 238 | for j ulong 4 |
| 239 | if and tactive j lt fabs sub get NO j 0.5f64 0.1f64 |
| 240 | ret 1 |
| 241 | end |
| 242 | end |
| 243 | ret 0 |
| 244 | end |