libr4d: --tp-wire wht6 at three ranks, the tiered-int8 wire over the uneven two-shot

--tp 3 --tp-wire wht6 had no kernel: the lossy rows were world_size 2 (rotated 6-bit) and 4
(tiered int8 over the two-shot). The tiered-int8 two-shot is already written over the world size,
and what kept it at four was the even split it shards by -- numel % (32 x ws) -- which a 2048-wide
row (64 groups) meets at three ranks one step in three.

The kernel now splits ng = numel/32 groups as evenly as they divide, the first ng % ws shards one
group longer, and lays every slot out for the longest shard, so writer and reader agree on one
number. At four ranks the entry still requires numel % 128 and the split is the even one it was.
ar_twoshot_3rank_ti8 is the only lossy row at three, so as at four it resolves at every size; a
message under min_bytes, or not whole groups, goes to the exact one-shot.

r4d_selftest holds it to what a lossy wire can be held to: every rank the same bytes, the declined
messages the exact fold bit for bit, and the rest within the int8 wire's error of the fp32 sum
(relative RMS < 1%), over groups % 3 of 0, 1 and 2 with outliers, to the 20971520 ceiling. The
--tp-wire help, the startup LOSSY warning, README, GUIDE and TP3.md say three ranks.
This commit is contained in:
baKon authored and StillDeadcode committed 2026-10-08 17:16:10 +02:00
1 parent 6b4a67f52e
commit 9238b1f23d
11 files changed
+246 -28

No files matched your search

+17
View File
@@ -2691,6 +2691,11 @@ static const RadConstraint cArWht6[] = {
C_EQ("world_size", 2), C_EQ("exact", 0), C_IN("dtype", "bf16 fp16"), C_DIV("numel", 64),
C_P2P,
};
/* DIV 32, not 96: the three-rank split is uneven in whole groups (r4d_rad_ar_twoshot_3rank_ti8). */
static const RadConstraint cArTi8Ts3[] = {
C_EQ("world_size", 3), C_EQ("exact", 0), C_IN("dtype", "bf16 fp16"), C_DIV("numel", 32),
C_P2P,
};
static const RadConstraint cArTi8Ts4[] = {
C_EQ("world_size", 4), C_EQ("exact", 0), C_IN("dtype", "bf16 fp16"), C_DIV("numel", 128),
C_P2P,
@@ -4484,6 +4489,18 @@ static const RadKernelInfo kKernels[] = {
r4d_rad_ar_init, r4d_rad_ar_fini, r4d_rad_ar_oneshot_8rank_exact, nullptr, nullptr, nullptr,
r4d_shape_all_reduce },
{ "ar_twoshot_3rank_ti8", "all_reduce", "ar",
"all-reduce (sum), reduce-scatter + all-gather; both hops ride the tiered-int8 wire (double "
"quant, the owner storing the decode of its own words) -- lossy",
"exactly 3 ranks, all peer-accessible; groups of 32, split over the shards as evenly as they "
"divide (the first groups % 3 take one more); under min_bytes the exact one-shot; cudagraph-safe",
"bf16 / fp16 payload, int8 + fp16 scale + u32 record per group on the wire, fp32 accumulate in "
"ascending rank order, bit-identical across ranks",
RAD_DOMAIN_DEVICE, R4D_PRIO_AR_ONESHOT,
ROW(cArTi8Ts3), ROW(tAr), nullptr,
r4d_rad_ar_init, r4d_rad_ar_fini, r4d_rad_ar_twoshot_3rank_ti8, nullptr, nullptr, nullptr,
r4d_shape_all_reduce },
{ "ar_twoshot_4rank_ti8", "all_reduce", "ar",
"all-reduce (sum), reduce-scatter + all-gather; both hops ride the tiered-int8 wire (double "
"quant, the owner storing the decode of its own words) -- lossy",