Archived
radiance 1.0.8
- Qwen3.8-Flash-Next serves at --tp 4, contributed by goodman-b (PR 9). Rank pairs share each of the model's two KV heads, every rank computes a slice of every expert's width, and four ranks run the unfused all-reduce plus a new four-rank all-gather for the vocab-parallel sampler. Two ranks declare and compute exactly as before. The README has a four-rank flag row; it pins --host-pool-mib on every card, 48 GiB in all. At four ranks the expert shares are not equal: ranks 0 and 1 compute three blocks of every even/odd pair of experts and ranks 2 and 3 two (docs/ARCHITECTURES.md). - The four- and eight-rank all-gathers require peer access between the cards, as every other collective does since 1.0.7, and the kernel library's selftest now refuses any multi-rank kernel that does not.
This commit is contained in:
1 parent
146318894d
commit
140987fa7b
13 files changed
+86
-63
No files matched your search
@@ -782,8 +782,8 @@ inline int geom_from(Geom& g, const RadModelMeta* m, const RadBuildCtx* c,
|
||||
* replaces (Flash-Next: 2 KV heads x 5120 x 256 rows read twice instead of once). What it buys
|
||||
* is that world 4 is declarable at all.
|
||||
*
|
||||
* When world <= n_head_kv_all the split below is untouched: TP2 stays byte-identical, the
|
||||
* geometry paro is served on cannot regress. */
|
||||
* When world <= n_head_kv_all the split below is untouched, so a world that divides the KV
|
||||
* heads -- TP2 on this family -- declares exactly as it did before replication existed. */
|
||||
if (g.world > g.n_head_kv_all) {
|
||||
if (g.world % g.n_head_kv_all != 0) {
|
||||
fprintf(stderr, "radiance: world_size = %d cannot replicate n_head_kv = %lld; "
|
||||
|
||||
@@ -103,7 +103,7 @@ inline int AttnGatedBF16::declare(RadBuilder* b, Names& nm, const Geom& geom, in
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
|
||||
/* KV-HEAD REPLICATION IS NOT PLUMBLED HERE. `geom_from` answers a world size above the KV head
|
||||
/* KV-HEAD REPLICATION IS NOT PLUMBED HERE. `geom_from` answers a world size above the KV head
|
||||
* count by giving every rank ONE kv head and a `kv_off` row span into a projection that stays
|
||||
* `n_head_kv_all * head_dim` rows in the container -- and this block declares its k and v with
|
||||
* the plain even row-shard, which at four ranks would hand a rank half of one KV head. The
|
||||
|
||||
@@ -1075,8 +1075,8 @@ inline int MoeFP8::declare(RadBuilder* b, Names& nm, const Geom& geom, int l,
|
||||
* tiles, which four ranks take as 3, 3, 2, 2. Every tile has exactly one owner, each
|
||||
* rank writes its own columns of gate/up and reads its own of down, and the block's
|
||||
* all-reduce sums the partials exactly as it does for the quantised experts and for
|
||||
* the shared arm. The even case keeps the old declaration verbatim -- no span at all --
|
||||
* so a rank count that divides stays byte-identical to the tree this fork started on. */
|
||||
* the shared arm. The even case keeps the even-split declaration verbatim -- no span
|
||||
* at all -- so a rank count that divides declares exactly as it did before. */
|
||||
psh_row = RAD_SHARD_ROW;
|
||||
psh_col = RAD_SHARD_COL;
|
||||
pparts = 2;
|
||||
|
||||
@@ -479,31 +479,33 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
g.w_bf16 = mc.expert_bf16 != 0;
|
||||
/* ...and the connections in front of the blocks emit no codes, since nothing reads any. */
|
||||
m.hccfg.quant = g.w_bf16 ? 0 : 1;
|
||||
/* ================= THE RANKS EITHER SLICE EVERY EXPERT, OR OWN WHOLE ONES =================
|
||||
/* ============================== EVERY RANK HOLDS A SLICE OF EVERY EXPERT ==============================
|
||||
*
|
||||
* An expert of this model is 640 columns, five 128-column blocks -- the fp8 scale block,
|
||||
* the 4-bit plane's scale group and the rotation's width all at once -- so two ranks
|
||||
* cannot halve one.
|
||||
*
|
||||
* AT TWO RANKS EVERY EXPERT IS SLICED BY PARITY: each rank takes three blocks of the
|
||||
* experts of one parity and two of the other's -- rank r's slice of expert e is the first
|
||||
* three blocks when e % 2 == r and the last two otherwise (MoeFP8::Config::ff_lo says why
|
||||
* by parity). The router stays replicated, every rank computes its slice of every routed
|
||||
* expert, and the block's all-reduce sums the partials.
|
||||
* THE SPLIT IS BY PARITY: each parity's five blocks are cut contiguously over the ranks,
|
||||
* and the rank that takes the extra block alternates with the expert's parity
|
||||
* (MoeFP8::Config::ff_lo says why by parity). At two ranks, rank r's slice of expert e is
|
||||
* the first three blocks when e % 2 == r and the last two otherwise. The router stays
|
||||
* replicated, every rank computes its slice of every routed expert, and the block's
|
||||
* all-reduce sums the partials.
|
||||
*
|
||||
* ABOVE TWO RANKS THE RANKS OWN WHOLE EXPERTS: rank r owns [r*E/W, (r+1)*E/W). A width
|
||||
* that divides into whole blocks at the rank count is still split evenly and has one
|
||||
* slice, but five blocks cannot be cut into four even whole-block slices, and the parity
|
||||
* trick is by construction a two-rank rule. So the block's all-reduce sums whole-expert
|
||||
* partials instead.
|
||||
* AT FOUR RANKS THE SHARES ARE NOT EQUAL. Parity gives the extra block only two places to
|
||||
* go, so ranks 0 and 1 compute three blocks of every even/odd pair of experts and ranks 2
|
||||
* and 3 compute two, and the all-reduce has ranks 2 and 3 wait for the other two. Equal
|
||||
* shares need the extra block rotated over four places -- the expert's number mod 4, four
|
||||
* slice tables where moe_gemm_q takes two.
|
||||
*
|
||||
* THE TRADE IS ROUTING BALANCE FOR A WORKING TP4. The bytes a rank reads are the same on
|
||||
* average either way, but which rank a routed expert lands on is a coin flip, and a verify
|
||||
* step's forty routed slots leave one rank about five experts ahead -- which the all-reduce
|
||||
* turns into the other ranks waiting, about a millisecond a step at one sequence. Split by
|
||||
* parity the ranks differ by a fifth of an expert per unit of the even/odd difference
|
||||
* instead. This is correctness-first v1: the follow-up is a 4-way block split, an
|
||||
* ff_lo[4]/ff_hi[4] generalising the parity tables, which keeps that balance at four.
|
||||
* WHY NOT EXPERT PARALLELISM, which splits the EXPERTS: rank r owns [r*E/W, (r+1)*E/W)
|
||||
* whole. The bytes a rank reads are the same on average either way, but which rank a
|
||||
* routed expert lands on is a coin flip, and a verify step's forty routed slots leave one
|
||||
* rank about five experts ahead -- which the all-reduce turns into the other ranks waiting,
|
||||
* about a millisecond a step at one sequence. Split by parity the ranks differ by a fifth
|
||||
* of an expert per unit of the even/odd difference instead. Whole experts would also break
|
||||
* the protected experts' pairing: the recipe protects them in pairs so each rank's count of
|
||||
* quantised experts stays even, which the two parity tables need.
|
||||
*
|
||||
* A CALIBRATION RUN SPLITS THE EXPERTS INSTEAD, whole experts per rank. The down
|
||||
* projection's Hessian is over an expert's whole K, and a rank holding a slice of each
|
||||
@@ -522,21 +524,9 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
mc.n_ff_exp = g.n_ff_all;
|
||||
mc.n_expert = per;
|
||||
mc.expert_base = (int64_t)g.rank * per;
|
||||
/* WHY this run owns whole experts: whichever of the three reasons applies. The parity
|
||||
* case says so by the block count, because that is the number that refuses the split. */
|
||||
char why[192];
|
||||
if (mc.calib)
|
||||
snprintf(why, sizeof why,
|
||||
"calibration (each expert's Hessian is over its whole width)");
|
||||
else if (mc.expert_bf16)
|
||||
snprintf(why, sizeof why, "bf16 experts");
|
||||
else
|
||||
snprintf(why, sizeof why,
|
||||
"%lld blocks of %d split %d ways are not whole blocks, so the ranks own "
|
||||
"whole experts", (long long)(g.n_ff_all / RAD_FP8_BLOCK),
|
||||
RAD_FP8_BLOCK, g.world);
|
||||
rad_note(b, "%s: rank %d owns experts [%lld, %lld) of %lld whole.",
|
||||
why, g.rank,
|
||||
mc.calib ? "calibration (each expert's Hessian is over its whole width)"
|
||||
: "bf16 experts", g.rank,
|
||||
(long long)mc.expert_base, (long long)(mc.expert_base + mc.n_expert),
|
||||
(long long)mc.n_expert_all);
|
||||
} else if (g.world > 1) {
|
||||
|
||||
Reference in new issue
Block a user