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-k8

c05b89f omegallm gpu k8: pipelined 64x64 GEMM, per-kernel QMD smem TARGET, GPR guard (aien-train#52) Drake Stapleton committed 2026-11-02
..
a1/
a2/
a3/
README.md12293
build.txt1813
disasm-max.txt5169
disasm-neg-gpr160.txt856
disasm-parity.txt5162

README.md

GB10 kernels k8: pipelined 64×64 GEMM and per-kernel shared-memory TARGET (aien-train#52)

k8 software-pipelines the K loop of the 64×64 GEMM (gk.om gkgemm64, gkld64, gksts64). Each K tile issues the global loads of the next tile into staging registers R142-R157 (predicated @P1, P1 = at least two K tiles left), runs its 64 FFMA steps from the current shared buffer, then stores the staging into the other buffer (two 4352-byte buffers, 8704 bytes) behind one barrier. k7b had two barriers per tile and exposed the global-load latency on every tile. The kernels are 17008 bytes, so they move from ids 32-39 (one 16 KiB slot each) to ids 40, 42, …, 54 (two slots each).

It took three windows. Every attempt is kept here, including the failed and the null one:

dirwindowwhat ranoutcome
a1/20261102T153743Z-8dfb45k8 with gkgpr 160FAIL: every k8 run hung (rc 84)
a2/20261102T160003Z-6bddbfk8 with gkgpr 168bit-identical, slower: NULL under its prereg
a3/20261102T161059Z-25de8fnew prereg: TARGET rule (gksmw), with and without k8k8 ADOPTED, product Q

This commit is a3's product Q: k8, gkgpr 168 for ids 40-54, and the gksmw TARGET rule for every gk.om kernel. It also adds the static GPR guard to gpu-disasm.sh / gpu-dump.om.

Status: EXERCISED on one GB10. All three windows were opened --gb10 shared --quiet none. spark-window printed "quiet machine" at close, but the quiet lock was not taken, and the load average was 1.27-2.15 at open and 2.09-2.79 at close (a*/open.json, a*/close.json). Timings are non-quiet. Not QUALIFIED.

Setup

  • omc 2c824805… (omega-mv e5b32567). Binaries: build.txt. This commit's tree rebuilds a3's Q (0b701583…) and QT (3619ef31…) byte for byte. Only a gk.om note changed after the window, which moves the source sha256 and nothing else.
  • Each a*/prereg.txt was written before its window opened (file times: a1 15:37:41Z, window 15:37:43Z; a2 15:59:59Z, window 16:00:03Z; a3 16:10:55Z, prereg.sha256 16:10:59.29Z, window directory created 16:10:59.31Z). a*/prereg.sha256 hashes the prereg (a1 65ad423d…, a2 828feaf0…, a3 fbeecfaa…). a1 and a2 also hash run.sh (57fa5a67…, c09972e3…). a3's run.sh hashed to 5b826f92… before the window, but that hash was printed rather than written into prereg.sha256. In the committed run.sh, win-*.txt and open.json the home prefix is replaced by ~/, so the committed run.sh files hash differently (63d61758…, e9f62b57…, 7aac3c71…). Nothing else differs.
  • Gates and checkpoints are as in ../gpu-k7b/: GC2 and GA fields other than the wall timings (GC2 field 14, GA field 7) must equal the k7b receipts, geval reruns rung 5 ck9000 and rung 6 ck30000, t200 runs 200 gtrainf steps from rung 6 ck9000, and gprof 3 profiles rung 6 ck30000. Mutant t (--mutant t) must fail gcmp2 with rc 47.

a1: the hang, and the GPR guard

Every k8 run (P 115f984f…, PT 66df07bb…) printed GX 99 -110 42 3 0 0 1 and exited rc 84: gkmm false, launch wait timeout -110 at the 5 s gkwait, after 3 launches. B (k7b, 50dcd16e…) was healthy in the same window: t200-B.txt gives T 9200 1508182 and ck_after ec4a8c21…, and every prof-*-B.txt gives T 30003 1298769.

Cause: the 64×64 kernels use R158 (the buffer step) but declared gkgpr 160. On Volta and later, two GPRs of the QMD count go to the program counter (Mesa NAK src/nouveau/compiler/nak/sm70.rs:101 hw_reserved_gprs, and api.rs:275, where the QMD count is num_gprs + 2). R158 and R159 therefore fall outside the allocation. gr.om had the same failure with R69-R71 under 72 (../geval/a1). The rule is that gkgpr must be at least the highest GPR + 3.

Fix: gkgpr 168 for ids 40-54. The kernel code is unchanged. At 64 threads, occupancy is 6 blocks per SM under 160 and 168 alike (WolframLanguageEvaluator: Floor[65536/(168*64)] → 6; Floor[65536/(144*64)] → 7 for k7b).

Guard: gpu-dump.om now also emits the gkgpr table (bytes 0-63 of its stderr record), and gpu-disasm.sh prints GPR <id> max R<n> need <n+3> declared <g> OK|LOW for each slot. It ends with GPR_LOW and exit 4 if any slot is LOW. Negative control disasm-neg-gpr160.txt (the a2 tree with 160): slots 40 and 54 LOW, exit 4. This commit's tree: all 31 slots OK at both shapes (disasm-parity.txt, disasm-max.txt).

a2: correct and slower (NULL)

Correctness held. Every gate line equals k7b's: gc2-small-s3-P, gc2-max-s7-P and ga-max-P PASS rc 0; ge-max-9000-P E 9000 2243 1445466 539226; ge-max-30000-P E 30000 2243 1338156 499194; PT FAIL rc 47 at both shapes. t200-B and t200-P both give T 9200 1508182, ck_after ec4a8c21…, so P is bit-identical to B over 200 steps.

The pre-registered direction (max P GEMM < min B GEMM) failed. P was slower in every round:

roundB 64×64 (32-39)P 64×64 (40-54)B GEMMP GEMMB allP all
18460162396179499101512980112729398151255111162922346
28586121297654966102465130114242228152718879163696258
387105521100626839103915264117865096154157322168759697

(ns of GPU wait summed over each id's launches in one profiled step.) P/B means: 64×64 1.14324, GEMM 1.11999. t200 wall: P/B 1.06900 (WolframLanguageEvaluator: Mean[p64]/Mean[b64] → 1.14324, Mean[pg]/Mean[bg] → 1.11999, Min[p64] > Max[b64] → True, 36796113367/34420909746 → 1.06900). k8 as pre-registered is a NULL result, and this record stands.

a3: why it was slower, as a new hypothesis

a2's prereg had flagged one occupancy risk [INFERENCE]: QMD word 36 was the fixed 78923776 + smem, which encodes the SM shared-memory config MIN 9 / MAX 26 / TARGET 9 (32 / 100 / 32 KiB) for every kernel. Mesa NAK sizes TARGET per kernel instead (src/nouveau/compiler/nak/qmd.rs:580-606, gv100_get_hw_smem_sizes): it takes the smallest carveout that holds the shared memory of every resident workgroup. The GB10 (sm121) carveouts are 0, 8, 16, 32, 64 and 100 KiB (src/nouveau/winsys/nouveau_device.c:218-231).

gksmw id now computes word 36 that way. Residency is register-limited here, so it uses Floor[65536/(gkgpr·gkthr)] blocks (WolframLanguageEvaluator, a3/prereg.txt):

kernelsblocks × smemneedTARGET
32×32 GEMM (ids 0-7)9 × 4608 B41472 B17 (64 KiB)
64×64 k7b (ids 32-39)7 × 4352 B30464 B9 (32 KiB, as before)
64×64 k8 (ids 40-54)6 × 8704 B52224 B17 (64 KiB)
gr.om (64 threads, 72 GPR)14 × 1024 B14336 B9 (as before)

MIN and MAX are unchanged (packed 3426304; with TARGET 9 that gives the old 78923776). gpu-dump.om emits each id's TARGET (stderr bytes 64-127), and gpu-disasm.sh prints SMEM <id> target <t>. In this commit's tree, ids 0-7 and 40-54 report 17 and ids 9-24 report 9, at both shapes.

The a3 arms isolate the two changes. Both add the same 28-line TARGET delta (a3/srcdiff-b-to-c.txt and a3/srcdiff-p-to-q.txt):

armbinarycode
B50dcd16e…k7b (git archive fc9af27, rebuilt byte-equal)
C58c207ea…k7b + TARGET rule. Kernel bytes equal k7b's (code_sha256 9659b361… / cd777d34…); only word 36 of ids 0-7 moves
Q0b701583…a2's k8 + TARGET rule. Kernel bytes equal a2's (70e215af… / 9b2e6d92…)
QT3619ef31…Q mutant t

Pre-registered decision rules [INFERENCE, not gates]. The metric is GPU wait per id group per profile: R1 compares C and B on the 32×32 GEMM (GAIN if max C < min B, HARM if min C > max B, otherwise NULL). R2 compares Q ids 40-54 with C ids 32-39 (ADOPT k8 if max Q < min C). The product table maps k8 adopted and R1 not HARM to Q.

Gates

prediction (a3/prereg.txt)receiptresult
Q, C gcmp2 small, 3 steps: rc 0, k7b linegc2-small-s3-{Q,C}.txt GCMP2 PASS rc=0PASS
Q, C gcmp2 max, 7 steps: rc 0, k7b linegc2-max-s7-{Q,C}.txt GCMP2 PASS rc=0PASS
Q, C gacmp max rc 0ga-max-{Q,C}.txt GACMP PASS rc=0PASS
QT gcmp2 small and max FAIL rc 47gc2-*-QT.txt GCMP2 FAIL rc=47PASS (caught)
Q, C geval E 9000 2243 1445466 539226ge-max-9000-{Q,C}.txt same linePASS (Δ 0)
Q, C geval E 30000 2243 1338156 499194ge-max-30000-{Q,C}.txt same linePASS (Δ 0)
t200 B, C, Q: rc 0, T 9200 1508182, ck_after ec4a8c21…t200-{B,C,Q}.txtPASS (byte-equal)
every gprof run T 30003 1298769prof-*-{B,C,Q}.txtPASS

Speed (non-quiet)

gprof 3, three rounds in rotated order (B C Q / Q B C / C Q B). The ns are summed over each id's launches. The 32×32 GEMM launches only ids 0-1 at this shape.

roundB 32×32C 32×32Q 32×32B 64×64 (32-39)C 64×64 (32-39)Q 64×64 (40-54)
1164591081652417716441792849052318378379675138393
2166635871641390616948421858005608307582475750789
3167490911681960616777507848653308419240478239735
roundB GEMMC GEMMQ GEMMB allC allQ all
110136433910030797391580185151227974150338927141531873
21024641479948973092699210152679985149689072142690663
310161442110101201095017242151650481151432860145193708
  • R1: NULL. GAIN False, HARM False. Means B 16.6239 ms, C 16.5859 ms, C/B 0.997712.
  • 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.
  • Product: Q.
  • GEMM means: B 101.814, C 100.270, Q 93.0989 ms. Q/B 0.914399, Q/C 0.928483.
  • All ids: B 151.853, C 150.487, Q 143.139 ms. Q/B 0.942615.

(WolframLanguageEvaluator over the triples above: Max[c32]<Min[b32] → False, Min[c32]>Max[b32] → False, Mean[c32]/Mean[b32] → 0.997712, Max[q64]<Min[c64] → True, Mean[q64]/Mean[c64] → 0.912675, Mean[qg]/Mean[bg] → 0.914399, Mean[qg]/Mean[cg] → 0.928483, Mean[qt]/Mean[bt] → 0.942615.)

t200, run in the order B, C, Q:

binarywallGPU wait (GT field 9)launcheswait per launch
B (k7b)34.205 s30.402 s638000.4765 ms
C (k7b + TARGET)34.490 s30.636 s638000.4802 ms
Q (product)33.144 s29.237 s638000.4583 ms

Q/B: wall 0.968991 (−3.10%, 5.30 ms per step) and wait 0.961688. Q/C: wall 0.960984, wait 0.954339. B ran 1.0031× the k7b window's 34.101 s (WolframLanguageEvaluator: 33144257073/34204930629 → 0.968991, 29236810718/30401563512 → 0.961688, (1 − 33144257073/34204930629)·100 → 3.10094, (34204930629 − 33144257073)/200/10^6 → 5.30337, 33144257073/34489929937 → 0.960984, 29236810718/30635671386 → 0.954339, 29236810718/63800/10^6 → 0.458257, 34204930629/34100849240 → 1.00305).

Caveat: the identical-kernel spread

C's ids 32-39 run exactly B's kernel bytes and QMD (TARGET 9 in both), yet C was below B in every round: C/B 0.982318, max C < min B True. That ~1.8% is an artifact of the non-quiet box and of the run order, not of code. R2's gain (1 − 0.912675) is 4.93854× that artifact, and min C / max Q is 1.06181 (WolframLanguageEvaluator: Mean[c64]/Mean[b64] → 0.982318, Max[c64]<Min[b64] → True, (1 − Mean[q64]/Mean[c64])/(1 − Mean[c64]/Mean[b64]) → 4.93854, Min[c64]/Max[q64] → 1.06181).

Reading

The TARGET mechanism itself was not measured. Nothing here reads the carveout the hardware chose. The reversal is what TARGET-limited residency predicts: under TARGET 9 the pipelined kernel was 1.12× slower than k7b, and under its own TARGET 17 it is 0.913× of the same-window k7b kernel [INFERENCE]. Under a 32 KiB carveout, 8704 B blocks allow Floor[32768/8704] = 3 per SM against 6 by registers. For the 32×32 GEMM, R1 found no effect beyond the spread, and Q's ids 0-1 sit at Q/B 1.00593. The rule stays because the 64×64 kernel needs it and because it is the Mesa policy, not because it sped up the 32×32 GEMM.

Next

Fusion: softmax into the attention GEMMs, id 46 (256×256×32; k7b id 35, mapped 32 + i → 40 + 2i) and ids 0-1 (256×32×256).