Archived
libr4d: moe_gemm_mxfp4a8's small-M form at GLM's TP8 slices -- a one-stream verify pass is a chain of short expert launches
At 1 to 48 tokens a chunk (8 to 384 routed rows) the expert-major forms spent their time around
the loads rather than on them. Taking the loads out left gate_up at 72 of its 115 us at six
tokens; what remained was the skeleton of each block: 289 grid rows for the few touched experts,
activation scales read row by row from LDS behind a divergent branch, weight rows loaded through
generic pointers (flat loads, which every LDS wait also waits for), loads behind branches so each
store waited for the whole prefetch, and __syncthreads' workgroup fence. With 160 blocks resident
at 21.8 KiB of LDS each, the last round of an expert-major launch ran nearly empty, at the latency
of one block's chain.
moe_mxfp4_small_kernel keeps the expert-major per-element sequence, and so its bytes:
- block row y takes the y-th touched expert, counted by ballot over the offsets, so the grid has
min(experts, rows) + 1 rows;
- weight codes stay packed in LDS and are decoded at the fragment read, halving the weight tile;
gate_up stages 512 of K, reading 256 bytes of each weight row at once, down its 128-byte rows
whole over four column tiles;
- loads are unconditional from clamped addresses and masked at the store, weight rows load
through global pointers, the barriers order LDS only, and a 128 of K reads its activation scales
and eight fragment pairs before its WMMA chains.
The rule takes it at GLM's TP8 slices for gate_up to 384 routed rows and down to 32; from five
tokens down reads 3 to 5 % slower than the staged form and keeps it. Other shapes are unchanged.
A deeper register prefetch, a barrier-free form with B straight from global memory and A tiles
sized to the chunk's tokens measured no faster.
Measured at the TP8 slices (r4d_selftest --cold 256 --perfmx), expert-major against small-M:
tokens 1 3 6 8 16 48
gate_up, us 36.8 79.5 120.5 145.0 230.3 416.7
31.4 69.5 101.4 122.4 206.8 390.0
tokens 1 2 3 4
down, us 21.2 26.0 34.3 39.5
16.4 22.5 33.2 37.9
Byte for byte against the expert-major forms over 1 to 48 tokens at every form tried (perfmx with
the old form kept beside it during the work), and in r4d_emu against the host restatement: three
GLM TP8 cases, with runs longer than one tile, dropped slots and E8M0 codes 0 and 255.
r4d_selftest checks the new band against libref at 1 to 48 tokens, and --perfmx names the form.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
332b5fa986
commit
961a9b3f13
3 files changed
+293
-6
No files matched your search
@@ -7,7 +7,8 @@
|
||||
* slice the P64 form with streamed A. Runs of 0, 1, 15, 16, 17, 63, 64, 65 and 130 rows, dropped
|
||||
* slots inside runs and past the routed rows, columns an odd expert does not have, a shorter K for
|
||||
* odd experts, E8M0 codes 0 and 255, parts 2, token and sorted rows, stacked planes and pointer
|
||||
* tables. The table decode is also held to the arithmetic one over every code. */
|
||||
* tables. At GLM's TP8 slices below P64 the small-M form, with runs longer than one tile. The
|
||||
* table decode is also held to the arithmetic one over every code. */
|
||||
#include "rad_abi.h"
|
||||
#include "rad_plugin.h"
|
||||
#include "r4d_plugin.h"
|
||||
@@ -201,6 +202,45 @@ int main() {
|
||||
glm_runs({ 200, 33, 300, 31, 200 }),
|
||||
20,
|
||||
"(moe_mxfp4_p64_kernel<32, 64, 256, 1, false>)" },
|
||||
{ "GLM TP8 gate_up, small-M form, four tokens",
|
||||
512,
|
||||
4096,
|
||||
512,
|
||||
4096,
|
||||
2,
|
||||
8,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
glm_runs({ 1, 2, 1, 3, 1, 6, 1, 2, 9, 1 }),
|
||||
5,
|
||||
"(moe_mxfp4_small_kernel<512, 1>)" },
|
||||
{ "GLM TP8 gate_up, small-M form, runs past one tile",
|
||||
512,
|
||||
4096,
|
||||
512,
|
||||
4096,
|
||||
2,
|
||||
8,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
glm_runs({ 12, 1, 16, 17, 3, 0, 5, 9, 2, 33 }),
|
||||
2,
|
||||
"(moe_mxfp4_small_kernel<512, 1>)" },
|
||||
{ "GLM TP8 down, small-M form, a run past one tile",
|
||||
4096,
|
||||
256,
|
||||
4096,
|
||||
256,
|
||||
1,
|
||||
8,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
glm_runs({ 3, 1, 17, 2, 1, 1, 1 }),
|
||||
5,
|
||||
"(moe_mxfp4_small_kernel<256, 4>)" },
|
||||
{ "GLM TP8 down, P64 BM32 BN64 K128 x4, A resident",
|
||||
4096,
|
||||
256,
|
||||
|
||||
Reference in new issue
Block a user