libr4d: a three-rank two-shot all-reduce, with shards one word uneven

At three ranks the exact all-reduce was the one-shot at every size: the two-shot required the
message to shard evenly, and a 2048-wide bf16 row is 256 16-byte words, a multiple of 3 only one
step in three. Every prefill chunk therefore sent twice its message per rank where the two-shot
sends 4/3.

The two-shot kernel now splits n16 words into shards of n16/ws, the first n16 % ws one word longer,
with region B at the longest shard. At 4 and 8 ranks every message the entries accept divides, so
nothing there changes. ar_twoshot_3rank_exact takes the band above R4D_AR_WIDE_ONESHOT_MAX_ELEMS the
way the 4- and 8-rank rows do. Its fold is the one-shot's -- fp32, ascending rank order -- so the
band edge between the two rows changes no bits.

r4d_selftest runs both three-rank rows through a per-element oracle (bf16 and fp32, words % 3 of 0,
1 and 2, 16 words to the 20971520-element ceiling, in and out of place, back to back on one
instance).
This commit is contained in:
baKon authored and StillDeadcode committed 2026-10-08 17:16:10 +02:00
1 parent a97985e7c2
commit 6b4a67f52e
7 files changed
+282 -41

No files matched your search

+1
View File
@@ -185,6 +185,7 @@ int r4d_rad_ar_oneshot_3rank_exact(const RadArgs*, RadStream);
int r4d_rad_ar_gather_3rank (const RadArgs*, RadStream);
int r4d_rad_ar_oneshot_4rank_exact(const RadArgs*, RadStream);
int r4d_rad_ar_oneshot_8rank_exact(const RadArgs*, RadStream);
int r4d_rad_ar_twoshot_3rank_exact(const RadArgs*, RadStream);
int r4d_rad_ar_twoshot_4rank_exact(const RadArgs*, RadStream);
int r4d_rad_ar_twoshot_8rank_exact(const RadArgs*, RadStream);
int r4d_rad_ar_twoshot_4rank_ti8 (const RadArgs*, RadStream);