Archived
gemma3 + libr4d: the fused all-reduce junction on the lossy wire, for rows of whole 64-element groups
Under --tp-wire wht6 a TranslateGemma step of 2-3 sequences (16-24 rows) sent its junction as three launches (the standalone lossy all_reduce, rmsnorm, rmsnorm_quant_fp8): the fused ar_rmsnorm_post_quant_fp8 sent the exact wire only, and the compressed fused form needed a row of whole 512-element chunks, which Gemma 3 27B's 5376 is not (10.5). - r4d_fused_quant_fp8.hip: a row of whole 64-element groups that is not whole chunks ends in a partial chunk whose missing groups go out as zeros and are not stored back. Every real group is the same 64 elements as in the flat message, so its bytes and the sum are the standalone wire's. The (row, chunk) mapping is a template parameter (PAD, wire 6 only), so a row of whole chunks (Qwen3.8's 5120) runs exactly the code it ran before; as a runtime branch it cost a Qwen3.8 x4 step 1.3-1.6 %. POST (the sandwich post-norm) on either wire. - r4d_ar_entry.hip: K % 64 instead of K % 512 for wire 6, a size check of the padded message against the slot and the local pack, and the local pack's scale region a sixteenth of the slot instead of a thirty-second (padding adds up to 7 groups a row: a 2048-row prefill chunk would have overrun the old size). - gemma3: the junction declares its lossy twin (op_ar6) and takes it up to kAr6MaxRows (24); a taller step keeps the standalone all-reduce, which spread over more blocks wins there (the fused kernel gives a block one row). TranslateGemma-27B MXFP4 + DFlash2, 2x R9700, --tp-wire wht6 --draft-short-from 8, greedy, aggregate tok/s, two rounds, junction limit never / 24 / any: 2 streams (16 rows) 350.7 346.2 / 370.4 367.0 / 357.7 356.0 3 streams (24 rows) 455.8 451.2 / 462.8 460.6 / 437.3 436.8 4 streams (32 rows) 553.7 553.6 / 553.9 560.2 / 521.0 523.0 8 streams (32 rows) 717.4 718.0 / 716.7 720.8 / 662.4 661.9 So 2 streams +6 %, 3 +2 %, 4 and 8 unchanged. Bit identity: with --tp-wire-min-kb 1 (one stream's steps go out lossy) the fused path gives the unfused one's greedy top-5 logprobs, 300 of 300 tokens, max |d| 0, on two pieces (x1 there 197.6 -> 212.6 tok/s). Qwen3.8-27B MXFP4: 300 of 300 identical on two prompts, speed unchanged. Tests: arch_test (the lossy-wire junction test now also expects a 24-row step to fuse through the twin, other op instances than the 8-row step's, and the 64-row prefill to stay unfused). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
9497bf9061
commit
812cdeceb0
6 files changed
+156
-45
No files matched your search
+7
-6
@@ -1448,7 +1448,7 @@ static const RadOperandSpec oArRmsNormQuantFp8[] = {
|
||||
};
|
||||
|
||||
/* ar_rmsnorm_post_quant_fp8: the same with a sandwich post-norm of the reduced sum before the add
|
||||
* (Gemma 3's junction, arch/gemma3), exact wire only. Its own op: an optional seventh operand on
|
||||
* (Gemma 3's junction, arch/gemma3), on either wire. Its own op: an optional seventh operand on
|
||||
* ar_rmsnorm_quant_fp8 would break every plugin that issues that op's six. */
|
||||
static const RadOperandSpec oArRmsNormPostQuantFp8[] = {
|
||||
{ "x", RAD_OPD_INOUT, 0 },
|
||||
@@ -3529,7 +3529,7 @@ static const RadOpSchema kSchemas[] = {
|
||||
|
||||
SCHEMA("ar_rmsnorm_post_quant_fp8", pArRmsNormQuantFp8, oArRmsNormPostQuantFp8,
|
||||
"ar_rmsnorm_quant_fp8 with a post-norm of the reduced sum against w_post before the "
|
||||
"residual add (a sandwich-norm junction), exact wire only, byte-identical to all_reduce, "
|
||||
"residual add (a sandwich-norm junction), either wire, byte-identical to all_reduce, "
|
||||
"rmsnorm, rmsnorm_quant_fp8."),
|
||||
SCHEMA("ar_rmsnorm_quant_fp8", pArRmsNormQuantFp8, oArRmsNormQuantFp8,
|
||||
"the two-rank all-reduce and the residual add, RMS norm and block-scaled fp8 "
|
||||
@@ -8756,7 +8756,7 @@ R4D_WIN_PAIR(512, 1) R4D_WIN_PAIR(512, 2) R4D_WIN_PAIR(512, 4) R4D_WIN_PAIR(512,
|
||||
"exactly 2 ranks; n a multiple of 8 and x unpitched, because x is the message and a block pushes "
|
||||
"its rows as 16B words; group 128; a block owns whole ROWS, so the block count is clamped to M; "
|
||||
"either wire, chosen by `wire` -- the rotated 6-bit payload additionally needs n to be a "
|
||||
"multiple of 512, so that a chunk never straddles a row; residual and out_bf16 may be null",
|
||||
"multiple of 64, so that a group never straddles a row (a row's last 512-element chunk may be partial); residual and out_bf16 may be null",
|
||||
"bf16 in, E4M3 out with an f32 scale per (row, 128 columns) and an optional bf16 out; codes "
|
||||
"taken over the BF16-ROUNDED norm output, and the reduced sum rounded to bf16 exactly as the "
|
||||
"standalone all-reduce of the SAME wire stores it -- byte-identical to the pair it replaces",
|
||||
@@ -8773,7 +8773,7 @@ R4D_WIN_PAIR(512, 1) R4D_WIN_PAIR(512, 2) R4D_WIN_PAIR(512, 4) R4D_WIN_PAIR(512,
|
||||
"back",
|
||||
"exactly 2 ranks; n a multiple of 128 (a rotation block cannot straddle a row) and x unpitched; "
|
||||
"group 128; a block owns whole ROWS, so the block count is clamped to M; either wire, chosen by "
|
||||
"`wire` -- the rotated 6-bit payload additionally needs n to be a multiple of 512; residual and "
|
||||
"`wire` -- the rotated 6-bit payload pads a row's partial last 512-element chunk; residual and "
|
||||
"out_bf16 may be null",
|
||||
"bf16 in, int8 out with an f32 scale per (row, 128 columns) and an optional bf16 out of the "
|
||||
"UNROTATED norm output; x and the residual are ar_rmsnorm_quant_fp8's bytes, and the codes "
|
||||
@@ -8786,8 +8786,9 @@ R4D_WIN_PAIR(512, 1) R4D_WIN_PAIR(512, 2) R4D_WIN_PAIR(512, 4) R4D_WIN_PAIR(512,
|
||||
{ "ar_rmsnorm_post_quant_fp8", "ar_rmsnorm_post_quant_fp8", "quant",
|
||||
"the two-rank all-reduce, a post-norm of the reduced sum, the residual add, RMS norm and "
|
||||
"block-scaled fp8 quantisation in one kernel: a sandwich-norm junction (Gemma 3)",
|
||||
"exactly 2 ranks, the exact wire; n a multiple of 8 and x unpitched; group 128; a block owns whole "
|
||||
"rows; the residual is required",
|
||||
"exactly 2 ranks, either wire chosen by `wire` (the rotated 6-bit payload needs n a multiple of 64; "
|
||||
"a row's last 512-element chunk may be partial); n a multiple of 8 and x unpitched; group 128; a "
|
||||
"block owns whole rows; the residual is required",
|
||||
"bf16 in, E4M3 out with an f32 scale per (row, 128 columns); x receives the reduced sum",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY,
|
||||
ROW(cArRmsNormQuantFp8), ROW(tAr), nullptr,
|
||||
|
||||
Reference in new issue
Block a user