Archived
libr4d: gemm_nt_f32 keeps steps of k in flight below 64 rows -- GLM's router read its weights at 150 GB/s
The router (288 x 4096 f32, every MoE layer, the MTP layer in every draft pass) and the index
head gates (32 x 4096) took 26 to 36 us a call at decode's few rows: a lane loaded one weight a
step and fed it straight to its FMA, so a wave had one request in flight. The tile kernel now
loads U steps of k before their FMAs; each lane keeps its ascending fmaf chain and the butterfly,
so every form gives the same bytes, and U = 1 is the tile form as it was.
Below 64 rows the rule takes 2 x 2 tiles with 16 steps, at the router's width from 17 rows 8 x 1
with 8; the wave-per-output kernel for one row goes. Measured (r4d_selftest --cold 256 --perff32,
K 4096), us:
rows 1 4 8 16 24 48
N 288, before 28.1 36.0 36.3 41.9 45.4 47.9
after 14.4 14.5 15.0 19.1 21.6 35.5
N 32, before 27.3 33.3 32.9 36.4 36.2 36.1
after 9.8 9.8 9.9 9.9 10.0 10.2
r4d_selftest's byte comparison with the host arithmetic passes at every form tried, r4d_emu gains
three shapes with K short of and past whole groups of steps.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4fdc786332
commit
1ff9abe2ba
2 files changed
+48
-39
No files matched your search
@@ -1,8 +1,8 @@
|
||||
/* tests/r4d_emu: gemm_nt_f32 (r4d_glm.hip) on the host SIMT emulator. The form the launcher picks
|
||||
* at each shape (one wave an output at one row, else a tile of rows x columns a wave, by M; the
|
||||
* shapes reach every one) must match the arithmetic written out here bit for bit: lane l folds
|
||||
* k = l, l+32, ... with fmaf, then the xor butterfly over 16, 8, 4, 2, 1. Tail rows and columns
|
||||
* and the pitch's padding stay untouched.
|
||||
* at each shape (a tile of rows x columns a wave with its steps of k in flight, by M and N; the
|
||||
* shapes reach every one, with K past and short of whole groups of steps) must match the
|
||||
* arithmetic written out here bit for bit: lane l folds k = l, l+32, ... with fmaf, then the xor
|
||||
* butterfly over 16, 8, 4, 2, 1. Tail rows and columns and the pitch's padding stay untouched.
|
||||
*
|
||||
* router_sigmoid_topk from the same unit: the wave-per-row select must match a serial scan written
|
||||
* out here bit for bit, on random and on tied ranks, with the outputs' pitch padding untouched. */
|
||||
@@ -147,9 +147,10 @@ int main() {
|
||||
int M, N, K;
|
||||
};
|
||||
// One wave an output (M 1), the 2x1, 4x1 (M under 16 or N up to 8), 4x4 and 8x4 tiles.
|
||||
const Shape shapes[] = { { 1, 288, 512 }, { 2, 288, 129 }, { 3, 36, 129 },
|
||||
{ 8, 288, 129 }, { 33, 32, 512 }, { 70, 36, 129 },
|
||||
{ 70, 4, 512 }, { 7, 31, 129 }, { 65, 13, 130 } };
|
||||
const Shape shapes[] = { { 1, 288, 512 }, { 2, 288, 129 }, { 3, 36, 129 },
|
||||
{ 8, 288, 129 }, { 33, 32, 512 }, { 70, 36, 129 },
|
||||
{ 70, 4, 512 }, { 7, 31, 129 }, { 65, 13, 130 },
|
||||
{ 16, 288, 1056 }, { 24, 288, 1040 }, { 40, 36, 1024 } };
|
||||
int fails = 0, cases = 0;
|
||||
for (const Shape& sh : shapes) {
|
||||
const int M = sh.M, N = sh.N, K = sh.K, xp = K + 5, yp = N + 3;
|
||||
|
||||
Reference in new issue
Block a user