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-k8/README.md # 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-k8 / README.md` 200 lines · 12293 bytes Raw Blame History Rendered 1 # GB10 kernels k8: pipelined 64×64 GEMM and per-kernel shared-memory TARGET (aien-train#52) 2 3 k8 software-pipelines the K loop of the 64×64 GEMM (`gk.om` `gkgemm64`, `gkld64`, `gksts64`). Each K tile 4 issues the global loads of the next tile into staging registers R142-R157 (predicated `@P1`, P1 = at 5 least two K tiles left), runs its 64 FFMA steps from the current shared buffer, then stores the staging 6 into the other buffer (two 4352-byte buffers, 8704 bytes) behind one barrier. k7b had two barriers per 7 tile and exposed the global-load latency on every tile. The kernels are 17008 bytes, so they move from 8 ids 32-39 (one 16 KiB slot each) to ids 40, 42, …, 54 (two slots each). 9 10 It took three windows. Every attempt is kept here, including the failed and the null one: 11 12 | dir | window | what ran | outcome | 13 |---|---|---|---| 14 | `a1/` | `20261102T153743Z-8dfb45` | k8 with `gkgpr` 160 | FAIL: every k8 run hung (rc 84) | 15 | `a2/` | `20261102T160003Z-6bddbf` | k8 with `gkgpr` 168 | bit-identical, slower: NULL under its prereg | 16 | `a3/` | `20261102T161059Z-25de8f` | new prereg: TARGET rule (`gksmw`), with and without k8 | k8 ADOPTED, product Q | 17 18 This commit is a3's product Q: k8, `gkgpr` 168 for ids 40-54, and the `gksmw` TARGET rule for every 19 `gk.om` kernel. It also adds the static GPR guard to `gpu-disasm.sh` / `gpu-dump.om`. 20 21 Status: EXERCISED on one GB10. All three windows were opened `--gb10 shared --quiet none`. 22 `spark-window` printed "quiet machine" at close, but the quiet lock was not taken, and the load average 23 was 1.27-2.15 at open and 2.09-2.79 at close (`a*/open.json`, `a*/close.json`). Timings are non-quiet. 24 Not QUALIFIED. 25 26 ## Setup 27 28 - omc `2c824805`… (omega-mv `e5b32567`). Binaries: `build.txt`. This commit's tree rebuilds a3's Q 29 (`0b701583`…) and QT (`3619ef31`…) byte for byte. Only a `gk.om` note changed after the window, which 30 moves the source sha256 and nothing else. 31 - Each `a*/prereg.txt` was written before its window opened (file times: a1 15:37:41Z, window 32 15:37:43Z; a2 15:59:59Z, window 16:00:03Z; a3 16:10:55Z, `prereg.sha256` 16:10:59.29Z, window 33 directory created 16:10:59.31Z). `a*/prereg.sha256` hashes the prereg (a1 `65ad423d`…, a2 `828feaf0`…, 34 a3 fbeecfaa…). a1 and a2 also hash `run.sh` (`57fa5a67`…, `c09972e3`…). a3's `run.sh` hashed to `5b826f92`… 35 before the window, but that hash was printed rather than written into `prereg.sha256`. In the committed 36 `run.sh`, `win-*.txt` and `open.json` the home prefix is replaced by `~/`, so the committed `run.sh` 37 files hash differently (`63d61758`…, `e9f62b57`…, `7aac3c71`…). Nothing else differs. 38 - Gates and checkpoints are as in `../gpu-k7b/`: GC2 and GA fields other than the wall timings (GC2 39 field 14, GA field 7) must equal the k7b receipts, `geval` reruns rung 5 `ck9000` and rung 6 40 `ck30000`, `t200` runs 200 `gtrainf` steps from rung 6 `ck9000`, and `gprof 3` profiles rung 6 41 `ck30000`. Mutant t (`--mutant t`) must fail `gcmp2` with rc 47. 42 43 ## a1: the hang, and the GPR guard 44 45 Every k8 run (P `115f984f`…, PT `66df07bb`…) printed `GX 99 -110 42 3 0 0 1` and exited rc 84: `gkmm` 46 false, launch wait timeout -110 at the 5 s `gkwait`, after 3 launches. B (k7b, `50dcd16e`…) was healthy 47 in the same window: `t200-B.txt` gives T 9200 `1508182` and `ck_after` `ec4a8c21`…, and every `prof-*-B.txt` 48 gives T 30003 `1298769`. 49 50 Cause: the 64×64 kernels use R158 (the buffer step) but declared `gkgpr` 160. On Volta and later, two 51 GPRs of the QMD count go to the program counter (Mesa NAK `src/nouveau/compiler/nak/sm70.rs:101` 52 `hw_reserved_gprs`, and `api.rs:275`, where the QMD count is `num_gprs + 2`). R158 and R159 therefore fall 53 outside the allocation. gr.om had the same failure with R69-R71 under 72 (`../geval/a1`). The rule is 54 that `gkgpr` must be at least the highest GPR + 3. 55 56 Fix: `gkgpr` 168 for ids 40-54. The kernel code is unchanged. At 64 threads, occupancy is 6 blocks per 57 SM under 160 and 168 alike (WolframLanguageEvaluator: `Floor[65536/(168*64)]` → 6; 58 `Floor[65536/(144*64)]` → 7 for k7b). 59 60 Guard: `gpu-dump.om` now also emits the `gkgpr` table (bytes 0-63 of its stderr record), and 61 `gpu-disasm.sh` prints `GPR max R need declared OK|LOW` for each slot. It ends with 62 `GPR_LOW` and exit 4 if any slot is LOW. Negative control `disasm-neg-gpr160.txt` (the a2 tree with 63 160): slots 40 and 54 LOW, exit 4. This commit's tree: all 31 slots OK at both shapes 64 (`disasm-parity.txt`, `disasm-max.txt`). 65 66 ## a2: correct and slower (NULL) 67 68 Correctness held. Every gate line equals k7b's: `gc2-small-s3-P`, `gc2-max-s7-P` and `ga-max-P` PASS rc 0; 69 `ge-max-9000-P` E 9000 2243 `1445466` 539226; `ge-max-30000-P` E 30000 2243 `1338156` 499194; PT FAIL rc 47 at 70 both shapes. `t200-B` and `t200-P` both give T 9200 `1508182`, `ck_after` `ec4a8c21`…, so P is bit-identical 71 to B over 200 steps. 72 73 The pre-registered direction (max P GEMM < min B GEMM) failed. P was slower in every round: 74 75 | round | B 64×64 (32-39) | P 64×64 (40-54) | B GEMM | P GEMM | B all | P all | 76 |---|---|---|---|---|---|---| 77 | 1 | `84601623` | `96179499` | `101512980` | `112729398` | `151255111` | `162922346` | 78 | 2 | `85861212` | `97654966` | `102465130` | `114242228` | `152718879` | `163696258` | 79 | 3 | `87105521` | `100626839` | `103915264` | `117865096` | `154157322` | `168759697` | 80 81 (ns of GPU wait summed over each id's launches in one profiled step.) P/B means: 64×64 1.14324, GEMM 82 1.11999. `t200` wall: P/B 1.06900 (WolframLanguageEvaluator: `Mean[p64]/Mean[b64]` → 1.14324, 83 `Mean[pg]/Mean[bg]` → 1.11999, `Min[p64] > Max[b64]` → True, ``36796113367`/`34420909746`` → 1.06900). k8 84 as pre-registered is a NULL result, and this record stands. 85 86 ## a3: why it was slower, as a new hypothesis 87 88 a2's prereg had flagged one occupancy risk [INFERENCE]: QMD word 36 was the fixed `78923776` + smem, 89 which encodes the SM shared-memory config MIN 9 / MAX 26 / TARGET 9 (32 / 100 / 32 KiB) for every kernel. 90 Mesa NAK sizes TARGET per kernel instead (`src/nouveau/compiler/nak/qmd.rs:580-606`, 91 `gv100_get_hw_smem_sizes`): it takes the smallest carveout that holds the shared memory of every 92 resident workgroup. The GB10 (sm121) carveouts are 0, 8, 16, 32, 64 and 100 KiB 93 (`src/nouveau/winsys/nouveau_device.c:218-231`). 94 95 `gksmw id` now computes word 36 that way. Residency is register-limited here, so it uses 96 `Floor[65536/(gkgpr·gkthr)]` blocks (WolframLanguageEvaluator, `a3/prereg.txt`): 97 98 | kernels | blocks × smem | need | TARGET | 99 |---|---|---|---| 100 | 32×32 GEMM (ids 0-7) | 9 × 4608 B | 41472 B | 17 (64 KiB) | 101 | 64×64 k7b (ids 32-39) | 7 × 4352 B | 30464 B | 9 (32 KiB, as before) | 102 | 64×64 k8 (ids 40-54) | 6 × 8704 B | 52224 B | 17 (64 KiB) | 103 | gr.om (64 threads, 72 GPR) | 14 × 1024 B | 14336 B | 9 (as before) | 104 105 MIN and MAX are unchanged (packed `3426304`; with TARGET 9 that gives the old `78923776`). `gpu-dump.om` 106 emits each id's TARGET (stderr bytes 64-127), and `gpu-disasm.sh` prints `SMEM target `. In this 107 commit's tree, ids 0-7 and 40-54 report 17 and ids 9-24 report 9, at both shapes. 108 109 The a3 arms isolate the two changes. Both add the same 28-line TARGET delta (`a3/srcdiff-b-to-c.txt` 110 and `a3/srcdiff-p-to-q.txt`): 111 112 | arm | binary | code | 113 |---|---|---| 114 | B | `50dcd16e`… | k7b (`git archive `fc9af27``, rebuilt byte-equal) | 115 | C | `58c207ea`… | k7b + TARGET rule. Kernel bytes equal k7b's (code_sha256 `9659b361`… / `cd777d34`…); only word 36 of ids 0-7 moves | 116 | Q | `0b701583`… | a2's k8 + TARGET rule. Kernel bytes equal a2's (`70e215af`… / `9b2e6d92`…) | 117 | QT | `3619ef31`… | Q mutant t | 118 119 Pre-registered decision rules [INFERENCE, not gates]. The metric is GPU wait per id group per profile: 120 R1 compares C and B on the 32×32 GEMM (GAIN if max C < min B, HARM if min C > max B, otherwise NULL). 121 R2 compares Q ids 40-54 with C ids 32-39 (ADOPT k8 if max Q < min C). The product table maps k8 adopted 122 and R1 not HARM to Q. 123 124 ### Gates 125 126 | prediction (`a3/prereg.txt`) | receipt | result | 127 |---|---|---| 128 | Q, C `gcmp2` small, 3 steps: rc 0, k7b line | `gc2-small-s3-{Q,C}.txt` GCMP2 PASS rc=0 | PASS | 129 | Q, C `gcmp2` max, 7 steps: rc 0, k7b line | `gc2-max-s7-{Q,C}.txt` GCMP2 PASS rc=0 | PASS | 130 | Q, C `gacmp` max rc 0 | `ga-max-{Q,C}.txt` GACMP PASS rc=0 | PASS | 131 | QT `gcmp2` small and max FAIL rc 47 | `gc2-*-QT.txt` GCMP2 FAIL rc=47 | PASS (caught) | 132 | Q, C `geval` E 9000 2243 `1445466` 539226 | `ge-max-9000-{Q,C}.txt` same line | PASS (Δ 0) | 133 | Q, C `geval` E 30000 2243 `1338156` 499194 | `ge-max-30000-{Q,C}.txt` same line | PASS (Δ 0) | 134 | `t200` B, C, Q: rc 0, T 9200 `1508182`, `ck_after` `ec4a8c21`… | `t200-{B,C,Q}.txt` | PASS (byte-equal) | 135 | every `gprof` run T 30003 `1298769` | `prof-*-{B,C,Q}.txt` | PASS | 136 137 ### Speed (non-quiet) 138 139 `gprof 3`, three rounds in rotated order (B C Q / Q B C / C Q B). The ns are summed over each id's 140 launches. The 32×32 GEMM launches only ids 0-1 at this shape. 141 142 | round | B 32×32 | C 32×32 | Q 32×32 | B 64×64 (32-39) | C 64×64 (32-39) | Q 64×64 (40-54) | 143 |---|---|---|---|---|---|---| 144 | 1 | `16459108` | `16524177` | `16441792` | `84905231` | `83783796` | `75138393` | 145 | 2 | `16663587` | `16413906` | `16948421` | `85800560` | `83075824` | `75750789` | 146 | 3 | `16749091` | `16819606` | `16777507` | `84865330` | `84192404` | `78239735` | 147 148 | round | B GEMM | C GEMM | Q GEMM | B all | C all | Q all | 149 |---|---|---|---|---|---|---| 150 | 1 | `101364339` | `100307973` | `91580185` | `151227974` | `150338927` | `141531873` | 151 | 2 | `102464147` | `99489730` | `92699210` | `152679985` | `149689072` | `142690663` | 152 | 3 | `101614421` | `101012010` | `95017242` | `151650481` | `151432860` | `145193708` | 153 154 - R1: NULL. GAIN False, HARM False. Means B 16.6239 ms, C 16.5859 ms, C/B 0.997712. 155 - R2: ADOPT k8. Max Q (78.240 ms) < min C (83.076 ms). Means C 83.6840 ms, Q 76.3763 ms, Q/C 0.912675. 156 - Product: Q. 157 - GEMM means: B 101.814, C 100.270, Q 93.0989 ms. Q/B 0.914399, Q/C 0.928483. 158 - All ids: B 151.853, C 150.487, Q 143.139 ms. Q/B 0.942615. 159 160 (WolframLanguageEvaluator over the triples above: `Max[c32]Max[b32]` → 161 False, `Mean[c32]/Mean[b32]` → 0.997712, `Max[q64]