interplane.Get Omega
Read in your language

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

branch main Branches Tags History

aien-train / evidence / OMEGALLM / gpu-k3 / README.md

99 lines · 6860 bytes Raw Blame History Rendered
1# GB10 kernels k3: warp-per-row RMS norm (aien-train#52)
2
3After `../gpu-k2/`, `prof-C2.txt` put 22.36 ms of the profiled step's 203.30 ms GPU wait in the two
4RMS norm kernels (`gr.om` ids 10 `grrmsf` and 11 `grrmsb`), which ran one thread per row: each thread
5walked its row's D columns, so a warp's loads touched 32 rows at a stride of 4·D bytes, and both
6kernels read their inputs twice (sum pass, then output pass). This change runs one warp per row:
7
8- Lane l of row r holds columns l + 32u (u < D/32) in registers, so every warp load and store is one
9 coalesced 128-byte line. `grrmsf` reads v once (k2 read it twice); `grrmsb` fuses its two passes
10 and reads v, g, da, dh and s once.
11- Row sums are a per-lane FFMA chain followed by a 16-8-4-2-1 `SHFL.BFLY` butterfly (`grwred`). The
12 summation order differs from k2, so results are not bit-identical to k2; every element-wise
13 operation keeps k2's order.
14- `gg.om` launches R·32 threads for these two kernels (arg 0 = R·32, grid `ggcd r 64 1 1`). `grall`
15 refuses D or T that is not a multiple of 32 (the model's shapes are D 256, T 256; the small test
16 shape is D 64).
17- New build-time mutant r (`build.sh --mutant r`, `gr.om` `OMUTR 0`): `grrmsb`'s row sum
18 sum(da·g·v) skips the lane-1 butterfly step. Mutants s, p and t still build from this tree but were
19 not rerun; the kernels they mutate did not change (`disasm.txt`: only slots 10 and 11 differ).
20
21Status: EXERCISED on one GB10, window `20261102T135748Z-ed1c5b` (`win-k3-chk2.txt`), opened
22`--gb10 shared --quiet none`. The quiet lock was not taken; the rung-6 P5 CPU `eval` held core 7 and
23the load average was 1.52 at open and 3.77 at close (`open.json`, `close.json`), so the timings are
24non-quiet. The first attempt, window `20261102T135737Z-bafe66` (`win-k3-chk1.txt`), ran nothing:
25`run.sh` was not executable (exec rc 126). Its mode was changed, not its content, and the same
26`run.sh` ran in k3-chk2. Not QUALIFIED.
27
28## Setup
29
30- Binaries (`build.txt`): product K3 836d3be1…, mutant r fcd3fe11…, omc 2c824805… (omega-mv
31 e5b32567). After the window the committed tree was rebuilt and gave the same two sha256s. The
32 timing base C2 44ea8a17… is the parent commit's product (`../gpu-k2/`), run again in this window.
33- Static checks before the window, as recorded in `prereg.txt`, and repeated on this commit's tree
34 in `disasm.txt` (`tests/omegallm/gpu-disasm.sh 10 11`, nvdisasm `-b SM121`): the 64-slot code dump
35 differs from the parent commit's dump in slots 10 and 11 only; slot 10 (864 B) has 5 `SHFL.BFLY`
36 and one `MUFU.RSQ`, slot 11 (1216 B) has 5 `SHFL.BFLY`; mutant r's slot 11 has 4, masks 0x10 0x8
37 0x4 0x2. Each slot has two EXITs: the out-of-range row guard and the end.
38- `prereg.txt` was written before the window opened; `prereg.sha256` holds its hash (42be5b4e…) and
39 that of `run.sh` (99bfa445…). The `run.sh` hash was taken after the window; the file was not edited
40 between writing and running (only its mode changed). In the committed `run.sh`, the `win-*.txt`
41 files and the window JSON the home prefix is replaced by `~/`, so the committed `run.sh` hashes to
42 6c5c79cb…; nothing else differs.
43- Checkpoints as in `../gpu-k2/`: `gc2-small` the small-shape checkpoint, `gc2-max` rung 5's `ckb8`,
44 `ga-max` rung 5's `ck250`, `ge-max-9000` rung 5's `ck9000`, `ge-max-30000` rung 6's `ck30000`,
45 `t200` a fresh copy of rung 6's `ck9000` per binary.
46
47## Results
48
49| prediction (`prereg.txt`) | receipt | result |
50|---|---|---|
51| K3 `gcmp2` small, 3 steps, rc 0 | `gc2-small-s3-K3.txt` GCMP2 PASS rc=0 | PASS |
52| K3 `gcmp2` max, 7 steps, rc 0 | `gc2-max-s7-K3.txt` GCMP2 PASS rc=0 | PASS |
53| K3 `gacmp` max rc 0 | `ga-max-K3.txt` GACMP PASS rc=0 | PASS |
54| mutant r `gcmp2` max FAIL rc 47 | `gc2-max-s7-KR.txt` GCMP2 FAIL rc=47 | PASS (caught) |
55| mutant r `gcmp2` small FAIL rc 47 | `gc2-small-s3-KR.txt` GCMP2 FAIL rc=47 | PASS (caught) |
56| K3 `geval` of rung 5 `ck9000`: \|E − 1445466\| < 10 (CPU `eval`) | `ge-max-9000-K3.txt` E 9000 2243 1445466 539226 | PASS (Δ 0) |
57| K3 `geval` of rung 6 `ck30000`: \|E − 1338156\| < 10 (C2 chip value) | `ge-max-30000-K3.txt` E 30000 2243 1338156 499194 | PASS (Δ 0) |
58| `gprof` K3: ids 10 and 11 launch gx = R·32/64 | `prof-K3.txt` rc=0: 17 launches each, gx 8192 at the max shape (k2: 256) | PASS |
59| `t200` C2 then K3, both rc 0; K3 T line reported | `t200-C2.txt` T 9200 1507707, `ck_after` fde1fae9… (same as `../gpu-k2/`); `t200-K3.txt` T 9200 1508121, `ck_after` 70ede05c… | PASS (both rc 0) |
60
61The K3 training loss after 200 steps is 414 µnats above C2's. The two runs differ only in the RMS
62sum order, so the trajectories diverge after the first step; one pair of 200-step runs says nothing
63about whether either order trains better [INFERENCE: one sample, no repeat].
64
65## Speed (non-quiet)
66
67`t200`: 200 `gtrainf` steps 9000→9200 from rung 6's `ck9000`, both binaries in this window, C2 first.
68
69| binary | wall | GPU wait (GT field 9) | launches | wait per launch |
70|---|---|---|---|---|
71| C2, k2 | 44.674 s | 40.848 s | 63800 | 0.6402 ms |
72| K3, this tree | 42.241 s | 38.398 s | 63800 | 0.6019 ms |
73
74K3 is 1.0576× faster than C2 in wall time (−5.45%) and 1.0638× in GPU wait (WolframLanguageEvaluator:
7544674481439/42241119437 → 1.05761, 40847864725/38398155652 → 1.06380). The wait is 90.90% of K3's
76wall. C2 ran 0.231 s faster here than in the k2 window (44.906 s).
77
78`prof-K3.txt` (one profiled step, ns summed over launches):
79
80| id | kernel | launches | k2 ms | k3 ms | speed-up | k3 ms per launch | k3 GB/s |
81|---|---|---|---|---|---|---|---|
82| 10 | `grrmsf` | 17 | 6.022 | 2.406 | 2.503 | 0.1415 | 237.6 |
83| 11 | `grrmsb` | 17 | 16.338 | 6.614 | 2.470 | 0.3890 | 215.8 |
84
85GB/s counts the bytes the k3 kernel must move at the max shape (16384 rows × 256 columns, f32):
86`grrmsf` reads v and writes y (2 × 16 MiB) plus s and g; `grrmsb` reads v, da, dh and writes dh, w
87(5 × 16 MiB) plus s and g (WolframLanguageEvaluator: (2·16777216+65536+1024)/(2405773/17) → 237.58,
88(5·16777216+65536+1024)/(6613658/17) → 215.80). Counted the same way, k2 moved 94.9 and 87.4 GB/s.
89The two kernels saved 13.34 ms of the profile; its total fell from 203.30 ms to 192.63 ms (1.0554×),
90so the other kernels came out 2.67 ms slower in this single profiled step, which is within the
91run-to-run spread of one profile [INFERENCE: one profile per binary, no repeat]. The RMS kernels are
92now 4.68% of the profiled wait.
93
94## Next targets
95
96Unchanged from `../gpu-k2/` apart from the RMS kernels: `grce` (id 21, one thread per row, 13.2 ms in
97k2's profile) is next, but a warp-parallel sum changes the Kahan sum that mutant k removes, so it
98needs a new mutant design; then the attention batched GEMMs (QK^T id 35 writes the T×T score tensor),
99via causal tile skipping or a fused attention kernel; then the softmax kernels.