libr4d: RADIANCE_AR8_SHARD_WEIGHTS=duplex -- shard weights from the both-directions link model, 8 to 1 instead of 4 to 1

The eight-rank two-shot in pieces runs both hops on a link at once, so each direction of rank r's
link carries (1 + 6 x_r) N for a shard fraction x_r: N - x_r N out in the reduce-scatter and
7 x_r N out in the all-gather, the same in. The slowest rank sets the time. The quadratic rule
(round(4 (rate / max)^2)) gives four Gen5 x16 and four Gen5 x8 cards 4 and 1: x8 carries 1.3 N at
28.6 GB/s (763 us for 16 MiB) while x16 carries 2.2 N at 57.1 (647 us), so the x16 links idle
15% of the time.

r4d_ar_weights_duplex equalises the ranks instead: x_r = (T B_r - 1) / 6 where positive, the x
summing to 1, filled from the fastest rank down. On that board it gives x16 2/9 and x8 1/36,
weights 64 and 8, and both kinds of card carry the same time's bytes: 7/6 N / 28.6 GB/s, 685 us
for 16 MiB, 10% under the quadratic rule's 763. On the earlier board with two Gen4 x8 links it
gives 64,9,0,64,0,9,64,64: the Gen4 cards nothing, as the measured best 4,1,0,4,0,1,4,4 did, the
Gen5 x8 ones half of what it gave them.

It is a new value of the variable, not a new default: unset and "auto" keep the quadratic rule,
so nothing runs differently until a measurement on the board says so. Which rank owns a word
changes only the link it crosses, not its fold, so the bits are those of every other table.
--perfar8 reads the variable the same way. r4d_ar_links_test checks both boards, equal links and
that every rank with a shard finishes together.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
NunzeandClaude Fable 5.1 authored and StillDeadcode committed 2026-10-22 11:54:56 +02:00
1 parent 91200c900b
commit 5b9bc13e5f
5 files changed
+95 -16

No files matched your search

+5 -4
View File
@@ -22581,7 +22581,8 @@ static void ar8_print_timeline(const std::vector<Ar8Perf>& t, size_t cfg, double
* `how` names the source and, for "auto", every rank's link. */
static bool ar8_weights_as_plugin(const std::vector<int>& devs, int* w, std::string* how) {
const char* e = std::getenv(R4D_AR8_SHARD_WEIGHTS_ENV);
if (e && *e && std::strcmp(e, "auto")) {
const bool duplex = e && !std::strcmp(e, "duplex");
if (e && *e && std::strcmp(e, "auto") && !duplex) {
if (!std::strcmp(e, "off")) { *how = " (off)"; return false; }
if (r4d_ar_shard_weights_parse(e, 8, w)) { *how = " (set)"; return true; }
*how = fmt(" (%s=\"%s\" is invalid)", R4D_AR8_SHARD_WEIGHTS_ENV, e);
@@ -22599,11 +22600,11 @@ static bool ar8_weights_as_plugin(const std::vector<int>& devs, int* w, std::str
gbs[r] = r4d_ar_link_gbs(l);
links += fmt("%s r%d %.1f GT/s x%d", r ? "," : "", r, l.gts, l.width);
}
if (!r4d_ar_weights_from_rates(gbs, 8, w)) {
*how = " (auto: a link is unreadable;" + links + ")";
if (!(duplex ? r4d_ar_weights_duplex(gbs, 8, w) : r4d_ar_weights_from_rates(gbs, 8, w))) {
*how = fmt(" (%s: a link is unreadable;", duplex ? "duplex" : "auto") + links + ")";
return false;
}
*how = " (auto:" + links + ")";
*how = fmt(" (%s:", duplex ? "duplex" : "auto") + links + ")";
for (int r = 1; r < 8; ++r) if (w[r] != w[0]) return true;
return false;
}