arch/common: DFlash2's split fc gathers its message as a range

The context pass's all_gather declared numel as a fixed crows * n_embd. crows is max_tok, so every
sizing declare (RadBuildCtx::shape_probe) changed a fixed parameter and was refused: with a
block-fp8 fc at TP > 1 no arena level was planned and nothing was lent to the expert slab. numel
is now a range with the trunk all-reduce's bound, issued at T * n_embd, as the reference reads it
(band_rows).

arch_test: the fc split's gather is the trunk's bound, as a range.
This commit is contained in:
keptn42 committed 2026-11-04 22:08:06 +01:00
1 parent 19d4e8fe0e
commit e0c3f971dc
2 files changed
+12 -4

No files matched your search

+7 -3
View File
@@ -555,12 +555,15 @@ inline int Dflash2::declare(RadBuilder* b, Names& nm, const Geom& geom, const Co
if (fc_rows) {
/* The split (SHARDING above): this rank's block-aligned rows into `cpart`, its window of
* them gathered into `c`. The GEMM takes its K split from the whole width. The gather
* rides the trunk's all-reduce instance (the same numel bound, so the same instance). */
* rides the trunk's all-reduce instance (the same numel bound, so the same instance).
* The message is a range, as the all-reduce's: a fixed numel follows max_tok, and the
* arena's sizing declare (RadBuildCtx::shape_probe) refuses a fixed parameter that
* changes with the step size. */
op_cfc = w_fc.gemm(b, crows, fc_rows, cfg.n_taps * g.n_embd, {w.srcq, w.srcs}, {w.cpart},
g.n_embd);
op_cgath = rw(b, RAD_OP(b, "all_gather",
RAD_PARAMS(RAD_INT("world_size", g.world),
RAD_INT("numel", crows * g.n_embd),
RAD_RANGE("numel", g.n_embd, crows * g.n_embd),
RAD_STR("dtype", g.dtype), RAD_INT("row", fc_share)),
RAD_NOWEIGHTS),
{w.cpart}, {w.c});
@@ -1090,7 +1093,8 @@ inline void Dflash2::context(RadCtx* c, const RadBatch* batch) const {
if (fc_rows) {
RAD_ISSUE_N(c, op_cfc, T, brows(w.srcq, T), brows(w.srcs, T), RAD_W(w_fc.w), RAD_W(w_fc.s),
brows(w.cpart, T), RAD_NONE, w_fc.bref());
RAD_ISSUE_N(c, op_cgath, T, bcol(w.cpart, fc_off, fc_share, T), brows(w.c, T));
RAD_ISSUE_N(c, op_cgath, T * g.n_embd, bcol(w.cpart, fc_off, fc_share, T),
brows(w.c, T));
} else {
RAD_ISSUE_N(c, op_cfc, T, brows(w.srcq, T), brows(w.srcs, T), RAD_W(w_fc.w), RAD_W(w_fc.s),
brows(w.c, T), RAD_NONE, w_fc.bref());
+5 -1
View File
@@ -8012,7 +8012,11 @@ TEST(gemma4_31b_dflash2_fc_splits_by_rows_without_changing_a_bit) {
}
if (o.op == "all_gather" && pint(&o, "row") == cs.share) {
++fc_gathers;
CHECK_EQ(pint(&o, "numel"), (long long)(2048 * E)); /* the trunk's instance */
/* The trunk's instance, and a range: a sizing declare may not change it. */
const RecParam* ne = param(&o, "numel");
REQUIRE(ne != nullptr);
CHECK_EQ(ne->kind, (int)RAD_P_RANGE);
CHECK_EQ(ne->ihi, (long long)(2048 * E));
CHECK_EQ(pint(&o, "world_size"), (long long)cs.world);
}
}