the narrow overlap all-reduce at three and eight ranks only on request: R4D_AR_LANE_3_8

The three- and eight-rank `overlap` rows (ar_twoshot_3rank_exact_lane, ar_twoshot_3rank_ti8_lane,
ar_twoshot_8rank_exact_lane) took the four-rank lane rows' narrow launch for every collective a plugin
issues beside compute: qwen4exp's --prefill-span, gemma4's prefill trunk overlap and the image and
video plugins' second-lane collectives included. That changed a default above two ranks without a
measurement, and a narrow grid can lose there too: where the all-reduce is the longer of the two (a
large message, slow or shared links, seven peers to feed at eight ranks) the step waits on a slower
collective. They now launch exactly as the wide rows by default (tArTs38Lane holds tAr's defaults: the
same grid, the same bits, the same time); R4D_AR_LANE_3_8=1, read once at load, gives them the
four-rank lane's four blocks of 1024. The bits are the same either way.

r4d_selftest checks the defaults both ways (failed before the change: nblocks 4 where the wide rows'
rule is 0). GUIDE §4.7 (with what to set and what it may gain or cost), §4.5, the environment table,
OPS, TP3 and libr4d/README say it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
mici81andClaude Opus 5.5 authored and StillDeadcode committed 2026-10-24 11:10:08 +02:00
1 parent 0d2b502d51
commit 48e41fda1e
2 files changed
+77 -18

No files matched your search

+41
View File
@@ -400,6 +400,47 @@ static void cross_check(const Plugin& pl) {
ok("every row that needs two or more ranks requires device.p2p 1 or 0", no_p2p == 0,
p2pdetail);
/* The three- and eight-rank `overlap` rows launch as their wide rows unless R4D_AR_LANE_3_8=1
* (r4d_rows.cpp, tArTs38Lane): every axis default the wide row's, nblocks 4 under the variable.
* The four-rank lane rows keep their measured narrow launch either way. */
{
const char* env = std::getenv("R4D_AR_LANE_3_8");
const bool narrow = env && env[0] == '1' && !env[1];
auto row = [&](const char* n) -> const RadKernelInfo* {
for (int k = 0; k < nk; ++k)
if (!std::strcmp(pl.kernel_at(k)->name, n)) return pl.kernel_at(k);
return nullptr;
};
auto deflt = [](const RadKernelInfo* r, const char* key) -> long long {
for (int v = 0; v < r->n_tunables; ++v)
if (!std::strcmp(r->tunables[v].key, key)) return (long long)r->tunables[v].deflt;
return -1;
};
static const char* const pairs[][2] = {
{ "ar_twoshot_3rank_exact_lane", "ar_twoshot_3rank_exact" },
{ "ar_twoshot_8rank_exact_lane", "ar_twoshot_8rank_exact" },
{ "ar_twoshot_3rank_ti8_lane", "ar_twoshot_3rank_ti8" },
};
int bad = 0;
std::string detail;
for (const auto& pr : pairs) {
const RadKernelInfo* l = row(pr[0]);
const RadKernelInfo* w = row(pr[1]);
if (!l || !w) { ++bad; detail += std::string(pr[0]) + " or its wide row absent; "; continue; }
for (const char* key : { "nblocks", "nthreads", "drain", "acq" }) {
const long long want = narrow && !std::strcmp(key, "nblocks") ? 4 : deflt(w, key);
if (deflt(l, key) != want) {
++bad;
detail += std::string(pr[0]) + ":" + key + " " + std::to_string(deflt(l, key)) +
" (want " + std::to_string(want) + "); ";
}
}
}
ok(narrow ? "the 3/8-rank overlap rows take the narrow launch (R4D_AR_LANE_3_8=1)"
: "the 3/8-rank overlap rows launch as their wide rows (R4D_AR_LANE_3_8 unset)",
bad == 0, detail);
}
/* The libr4d orderings the integer priority has to preserve. */
int p_ts = -1, p_os = -1, p_dec = -1, p_pre = -1, p_m16 = -1, p_m64 = -1, p_bt = -1;
int p_g2dec = -1, p_g2pre = -1, p_g2win = -1;