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/OMEGALLM/gpu-k9/srcdiff-q-to-p.txt # 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 / OMEGALLM / gpu-k9 / srcdiff-q-to-p.txt` 366 lines ยท 9720 bytes Raw Blame History 1 5926,`5928c5926`,5928 2 < note 23 batch magic, 24 minus level-2 count, 25 alpha bits, 26-28 causal (gkczx, gkczk). beta true 3 < note adds the old C. 4 < fn gkgemm ma uint mb uint beta bool to void 5 --- 6 > note 23 batch magic, 24 minus level-2 count, 25 alpha bits, 26-28 causal (gkczx, gkczk), 30/31 the 7 > note fused epilogue's second pointer (gkope). beta true adds the old C; ep is the fused epilogue. 8 > fn gkgemm ma uint mb uint beta bool ep uint to void 9 `5993c5993` 10 < gkepi beta 11 --- 12 > gkepi beta ep 13 `5996c5996`,5999 14 < fn gkepi beta bool to void 15 --- 16 > note Fused epilogue ep (gkope, beta false): 1 also stores Y = C > 0 ? C : 0 at the second pointer 17 > note (words 30/31, base R90), the FFN ReLU forward; 2 loads M at the second pointer's same offsets 18 > note into R40-55 and stores M > 0 ? C : 0, the FFN ReLU backward mask (NaN M gives 0). 19 > fn gkepi beta bool ep uint to void 20 6013,`6017c6016`,6024 21 < for i uint 4 22 < r0 = add 56 mul i 8 23 < gkimadw r0 14 i 88 24 < for j uint 3 25 < gkimadw add r0 mul add j 1 2 15 add j 1 r0 26 --- 27 > if ne ep 0 28 > gkldc64 10 1016 29 > gkimadw 90 12 1 10 30 > end 31 > gkldc 12 996 false 32 > if eq ep 2 33 > gkadr32 90 34 > for k uint 16 35 > gkldg add 40 k add 56 mul k 2 0 ne k 0 36 `6020c6027` 37 < gkldc 12 996 false 38 --- 39 > gkadr32 88 40 `6032a6040`,6045 41 > if eq ep 2 42 > t = gkthm 92 43 > for k uint 16 44 > gkepm add 16 k add 40 k t 45 > end 46 > end 47 `6035a6049`,6057 48 > if eq ep 1 49 > for k uint 16 50 > gkepm add 16 k add 16 k 255 51 > end 52 > gkadr32 90 53 > for k uint 16 54 > gkstg add 56 mul k 2 add 16 k 0 ne k 0 55 > end 56 > end 57 `6037a6060`,6086 58 > note Address pairs R56-87 of the thread's 4x4 block (row stride R14, column stride R15) from base b. 59 > fn gkadr32 b uint to void 60 > for i uint 4 61 > r0 = add 56 mul i 8 62 > gkimadw r0 14 i b 63 > for j uint 3 64 > gkimadw add r0 mul add j 1 2 15 add j 1 r0 65 > end 66 > end 67 > end 68 > note Fused epilogue select: P2 = R m > R t, R e = P2 ? R e : 0 (FSETP.GT, FSEL; gr.om's encoders, 69 > note verified against nvdisasm there). t is RZ (255) except under mutant m. 70 > fn gkepm e uint m uint t uint to void 71 > grfsetp 2 m t 4 72 > grfsel e e 255 2 73 > end 74 > note Mutant m: 1 in the product, 0 in the mutant, whose fused backward mask (ep 2) is M > 2^-10 (the 75 > note forward and its stored FP unchanged). gkthm loads that threshold into R r and returns the 76 > note mask's compare register: RZ (255) in the product, r in the mutant. 77 > const OMUTM ulong 1 78 > fn gkthm r uint to uint 79 > if eq OMUTM 0 80 > gkmovi r grf 0.`0009765625f64` 81 > ret r 82 > end 83 > ret 255 84 > end 85 `6159c6208` 86 < fn gkgemm64 ma uint mb uint beta bool to void 87 --- 88 > fn gkgemm64 ma uint mb uint beta bool ep uint to void 89 `6213c6262` 90 < gkepi64 beta 91 --- 92 > gkepi64 beta ep 93 6220,`6235c6269`,6275 94 < note +32 columns R11), alpha R141, old C in R112-127 when beta, store. 95 < fn gkquad64 rh uint ch uint beta bool to void 96 < qb = uint 128 97 < if eq rh 1 98 < gkimadw 130 10 1 128 99 < qb = 130 100 < end 101 < if eq ch 1 102 < gkimadw 130 11 1 qb 103 < qb = 130 104 < end 105 < for i uint 4 106 < r0 = add 80 mul i 8 107 < gkimadw r0 14 i qb 108 < for j uint 3 109 < gkimadw add r0 mul add j 1 2 15 add j 1 r0 110 --- 111 > note +32 columns R11), alpha R141, old C in R112-127 when beta, store. Fused epilogue ep as in gkepi, 112 > note second base R142 (quadrant base R144); ep 2 loads M into R112-127 (beta is false there). 113 > fn gkquad64 rh uint ch uint beta bool ep uint to void 114 > if eq ep 2 115 > gkqadr rh ch 142 144 116 > for k uint 16 117 > gkldg add 112 k add 80 mul k 2 0 ne k 0 118 `6237a6278` 119 > gkqadr rh ch 128 130 120 `6250a6292`,6297 121 > if eq ep 2 122 > t = gkthm 140 123 > for k uint 16 124 > gkepm gkacc64 rh ch k add 112 k t 125 > end 126 > end 127 `6254a6302`,6329 128 > if eq ep 1 129 > for k uint 16 130 > e = gkacc64 rh ch k 131 > gkepm e e 255 132 > end 133 > gkqadr rh ch 142 144 134 > for k uint 16 135 > e = gkacc64 rh ch k 136 > gkstg add 80 mul k 2 e 0 ne k 0 137 > end 138 > end 139 > end 140 > note Address pairs R80-111 of quadrant (rh, ch) from thread base b (quadrant base in R t when moved). 141 > fn gkqadr rh uint ch uint b uint t uint to void 142 > qb = b 143 > if eq rh 1 144 > gkimadw t 10 1 b 145 > qb = t 146 > end 147 > if eq ch 1 148 > gkimadw t 11 1 qb 149 > qb = t 150 > end 151 > for i uint 4 152 > r0 = add 80 mul i 8 153 > gkimadw r0 14 i qb 154 > for j uint 3 155 > gkimadw add r0 mul add j 1 2 15 add j 1 r0 156 6256,`6257c6331`,6335 157 < note 64x64 epilogue: C base of the thread (R128), quadrant offsets R10/R11, then four quadrants. 158 < fn gkepi64 beta bool to void 159 --- 160 > end 161 > end 162 > note 64x64 epilogue: C base of the thread (R128), second base R142 when fused, quadrant offsets 163 > note R10/R11, then four quadrants. 164 > fn gkepi64 beta bool ep uint to void 165 `6273a6352`,6355 166 > if ne ep 0 167 > gkldc64 10 1016 168 > gkimadw 142 12 1 10 169 > end 170 `6278c6360` 171 < gkquad64 shr h 1 and h 1 beta 172 --- 173 > gkquad64 shr h 1 and h 1 beta ep 174 `6283c6365`,6367 175 < note (40 + 2 (ma + 2 mb + 4 beta), two slots each: the pipelined K loop does not fit in one). 176 --- 177 > note (40 + 2 (ma + 2 mb + 4 beta), two slots each: the pipelined K loop does not fit in one). Fused 178 > note epilogue kernels (gkope, beta false): 25 (32x32) and 56 (64x64) ep 1 with ma 1 mb 0 (the FFN W1 179 > note forward, ggxw), 26 and 58 ep 2 with ma 1 mb 1 (the FFN dF backward, ggxwt). 180 `6293c6377` 181 < for g uint 16 182 --- 183 > for g uint 20 184 `6295c6379`,6389 185 < ns = uint 1 186 --- 187 > ma = and g 1 188 > mb = and shr g 1 1 189 > bt = ne and g 4 0 190 > ep = uint 0 191 > if ge g 16 192 > ep = add and g 1 1 193 > ma = 1 194 > mb = sub ep 1 195 > bt = false 196 > end 197 > big = and ge g 8 and ne g 16 ne g 17 198 `6298d6391` 199 < ns = 2 200 `6299a6393`,6406 201 > if ge g 16 202 > id = add 24 ep 203 > end 204 > if ge g 18 205 > id = add 54 mul ep 2 206 > end 207 > if not gkemit id ma mb bt ep big 208 > ret false 209 > end 210 > end 211 > ret true 212 > end 213 > note Emit one GEMM kernel into slot id (two slots when big, the 64x64 kernel); false on overflow. 214 > fn gkemit id uint ma uint mb uint bt bool ep uint big bool to bool 215 6301,`6309c6408`,6410 216 < ma = and g 1 217 < mb = and shr g 1 1 218 < bt = ne and g 4 0 219 < if lt g 8 220 < gkgemm ma mb bt 221 < put gkgpr id 104 222 < put gksm id 4608 223 < else 224 < gkgemm64 ma mb bt 225 --- 226 > ns = uint 1 227 > if big 228 > gkgemm64 ma mb bt ep 229 `6311a6413`,6417 230 > ns = 2 231 > else 232 > gkgemm ma mb bt ep 233 > put gkgpr id 104 234 > put gksm id 4608 235 `6317d6422` 236 < end 237 `6368c6473`,6474 238 < note pipelined 64x64 GEMM (6 * 8704 B) (evidence/OMEGALLM/gpu-k8). Only ids with gkthr set may call this. 239 --- 240 > note pipelined 64x64 GEMM (6 * 8704 B): under it the pipelined kernel was 1.12x slower than the k7b one, 241 > note under this rule 0.91x (evidence/OMEGALLM/gpu-k8). Only ids with gkthr set may call this. 242 `6750a6857`,6878 243 > note Fused epilogue ep for the next gkmm, which consumes it (see gkepi): 1 also stores 244 > note Y = C > 0 ? C : 0 at y, 2 stores M > 0 ? C : 0 with M read at y; y has C's strides. ep 1 needs 245 > note operand modes ma 1 mb 0 and ep 2 ma 1 mb 1 (the only fused kernels, gkall), both beta false. 246 > global gkep uint 1 247 > fn gkope ep uint y ulong to void 248 > put gkep 0 ep 249 > put gkarg 30 gblo y 250 > put gkarg 31 gbhi y 251 > end 252 > note true when fused epilogue ep may run with the pending operand modes and beta 253 > fn gkepok ep uint beta bool to bool 254 > if eq ep 0 255 > ret true 256 > end 257 > if or gt ep 2 beta 258 > ret false 259 > end 260 > if ne get gkmd 0 1 261 > ret false 262 > end 263 > ret eq get gkmd 1 sub ep 1 264 > end 265 `6751a6880`,6886 266 > ep = get gkep 0 267 > put gkep 0 0 268 > if not gkepok ep beta 269 > put gkcz 0 0 270 > put nverr 0 neg long 22 271 > ret false 272 > end 273 `6770a6906`,6917 274 > id = gkmmid t beta ep 275 > ret gklaunch id div n t div m t nz 276 > end 277 > note kernel id of a gkmm (gkall's table) for tile t, beta and fused epilogue ep; sets the arg count 278 > fn gkmmid t uint beta bool ep uint to uint 279 > if ne ep 0 280 > put gkna 0 32 281 > if eq t 64 282 > ret add 54 mul ep 2 283 > end 284 > ret add 24 ep 285 > end 286 `6779c6926` 287 < ret gklaunch id div n t div m t nz 288 --- 289 > ret id 290 7141,`7143c7288`,7289 291 < note 17 RELUF y = x > 0 ? x : 0; 18 RELUB dy = x > 0 ? dy : 0; 19 COPY; 20 ZERO; args n then pointers 292 < note Mutant m: 1 in the product, 0 in the mutant, whose RELUB mask is x > 2^-10 (RELUF unchanged). 293 < const OMUTM ulong 1 294 --- 295 > note 19 COPY y = x; 20 ZERO; args n then pointers. The FFN ReLU forward and backward mask are fused 296 > note into the GEMM epilogue (gk.om gkepi, kernels 25/26/56/58), so slots 17/18 stay empty. 297 7150,`7154d7295` 298 < grew2 kind 299 < end 300 < gkexit 301 < end 302 < fn grew2 kind uint to void 303 7157,`7173d7297` 304 < if eq kind 18 305 < gkldg 33 12 0 true 306 < end 307 < if eq kind 17 308 < grfsetp 1 32 255 4 309 < grfsel 34 32 255 1 310 < end 311 < if eq kind 18 312 < if eq OMUTM 0 313 < gkmovi 35 grf 0.`0009765625f64` 314 < grfsetp 1 32 35 4 315 < else 316 < grfsetp 1 32 255 4 317 < end 318 < grfsel 34 33 255 1 319 < end 320 < if eq kind 19 321 `7174a7299` 322 > gkstg 12 34 0 false 323 `7176c7301` 324 < gkstg 12 34 0 false 325 --- 326 > gkexit 327 `7365c7490` 328 < note emit slots 9..22 for dims V T D H F B; false when a kernel overflows its 16 KiB slot 329 --- 330 > note emit slots 9..24 (12, 17 and 18 empty) for dims V T D H F B; false when a kernel overflows its 16 KiB slot 331 `7406c7531` 332 < if and ge id 17 le id 20 333 --- 334 > if and ge id 19 le id 20 335 `7430c7555` 336 < note open the chip with gk slots 0..8 and row slots 9..22 for the given dims, arena asz bytes 337 --- 338 > note open the chip with the row slots 9..24 for the given dims, then gkopen's GEMM slots, arena asz bytes 339 `7738c7863` 340 < note 17 RELUF, 18 RELUB, 19 COPY (x into y), 20 ZERO (x) over n elements 341 --- 342 > note 19 COPY (x into y), 20 ZERO (x) over n elements (the FFN ReLU is fused into the GEMMs, gkope) 343 `7914a8040`,8041 344 > y = ggl l 11 345 > gkope 1 y 346 7916,`7917c8043` 347 < x = ggl l 11 348 < ggew 17 mul ggr f fp x 349 --- 350 > x = y 351 `7971c8097`,8098 352 < note layer l FFN backward: DH holds d out on entry, d hm on exit 353 --- 354 > note layer l FFN backward: DH holds d out on entry, d hm on exit. The dF GEMM's fused epilogue (gkope 2) 355 > note applies the ReLU mask FP > 0; the forward W1 GEMM (ggffn, gkope 1) stores both FP and Y. 356 `7979d8105` 357 < ggxwt dh w df f d false 358 `7981c8107`,8108 359 < ggew 18 mul ggr f x df 360 --- 361 > gkope 2 x 362 > ggxwt dh w df f d false 363 `8563c8690` 364 < note then zero dF where the chip's FP is not > 0, the chip RELUB mask (NaN included). 365 --- 366 > note then zero dF where the chip's FP is not > 0, the chip's fused dF mask (gkope 2; NaN included).