Archived
four-rank ar_gather_hc_write: the MoE gather in front of the exact one-shot write
At --tp 4 each MoE connection ran moe_gather and the fused write as two launches, three or four with the inverse table. ar_gather_hc_write_4rank runs r4d_ar_gather_word as the prologue of ar_hc_write_4rank, with the two-rank slot table and grid rule. The arithmetic is moe_gather's plus ar_hc_write_4rank's, so the bytes are unchanged. One and two ranks unchanged.
This commit is contained in:
1 parent
c36e6fa2b3
commit
2f56e3c477
12 files changed
+415
-36
No files matched your search
+29
-1
@@ -2163,7 +2163,8 @@ static const RadOpSchema kSchemas[] = {
|
||||
SCHEMA("ar_gather_hc_write", pArGatherHcWrite, oArGatherHcWrite,
|
||||
"moe_gather, then ar_hc_write, in one kernel: the routed experts' rows summed back to "
|
||||
"token order (with the shared arm folded when present) ARE the all-reduce's message, "
|
||||
"and the gated residual's write follows the reduction. Both wires."),
|
||||
"and the gated residual's write follows the reduction. Both wires at two ranks, the "
|
||||
"exact one at four."),
|
||||
};
|
||||
|
||||
/* ================================================================================ constraints
|
||||
@@ -2738,6 +2739,13 @@ static const RadConstraint cArGatherHcWrite[] = {
|
||||
C_EQ("world_size", 2), C_GE("top_k", 1), C_LE("top_k", 64),
|
||||
C_P2P,
|
||||
};
|
||||
/* The same at four ranks, exact wire only for cArHcWrite4's reason: the init and the entry refuse a
|
||||
* declared `wire` 6, since the exact op declares no `wire` and an absent key fails a constraint. */
|
||||
static const RadConstraint cArGatherHcWrite4[] = {
|
||||
C_GE("M", 1), C_DIV("n", 8), C_GE("hc", 2), C_LE("hc", 8), C_IN("dtype", "bf16"),
|
||||
C_EQ("world_size", 4), C_GE("top_k", 1), C_LE("top_k", 64),
|
||||
C_P2P,
|
||||
};
|
||||
static const RadConstraint cGatedQuantFp8[] = {
|
||||
C_DIV("n", 4), C_EQ("group", R4D_FP8_BLOCK), C_IN("dtype", "bf16"),
|
||||
};
|
||||
@@ -4815,6 +4823,26 @@ static const RadKernelInfo kKernels[] = {
|
||||
r4d_rad_ar_gather_hc_write_scratch, nullptr, nullptr,
|
||||
r4d_shape_ar_gather_hc_write, nullptr, r4d_fuse_ar_gather_hc_write },
|
||||
|
||||
{ "ar_gather_hc_write_4rank", "ar_gather_hc_write", "norm",
|
||||
"moe_gather folded in front of the four-rank ar_hc_write: each block sums its words' tokens "
|
||||
"back from the routed experts' rows, keeps the result as its message and pushes it, and then "
|
||||
"reduces and writes exactly as ar_hc_write_4rank does",
|
||||
"exactly 4 ranks, all peer-accessible; exact wire only; n a multiple of 8, y unpitched and "
|
||||
"y_expert's pitch a multiple of 8, because both move as 16B words; top_k <= 64; the stream "
|
||||
"pitch a multiple of 8; hc 2..8; the wide one-shot's handshake and slots on the plain four-rank "
|
||||
"all-reduce's instance; the grid widened until a block's slot table fits in LDS, or the "
|
||||
"inverse table in the scratch where that would take more blocks than the reduction asks for; "
|
||||
"cudagraph-safe",
|
||||
"bf16 throughout; the gather's sums and narrows are moe_gather's (round-to-nearest-even, the "
|
||||
"shared arm's product rounded before the add), the sum in fp32 in ascending rank order and "
|
||||
"rounded to bf16 exactly as the four-rank exact all-reduce stores it, and the write in "
|
||||
"hc_write's arithmetic over that bf16 value -- byte-identical to the three kernels it replaces",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_ONLY,
|
||||
ROW(cArGatherHcWrite4), ROW(tAr), nullptr,
|
||||
r4d_rad_ar_hc_wide_init, r4d_rad_ar_fini, r4d_rad_ar_gather_hc_write_4rank,
|
||||
r4d_rad_ar_gather_hc_write_scratch, nullptr, nullptr,
|
||||
r4d_shape_ar_gather_hc_write, nullptr, r4d_fuse_ar_gather_hc_write },
|
||||
|
||||
{ "qk_norm_rope_gate", "qk_norm_rope_gate", "attn",
|
||||
"the gated-attention QKV preamble in one pass: split [q|gate] per head, QK RMS norm over the "
|
||||
"head, partial NeoX RoPE and the gate copy",
|
||||
|
||||
Reference in new issue
Block a user