four-rank Flash-Next: the routed experts in four classes

The parity split gave ranks 0..3 30/30/20/20 % of the routed work. The extra
block of each five-block expert now goes round all four ranks by expert id
mod 4: rank r takes two blocks of class r and one of each other class, a
quarter each. The plain experts' extra tiles move to ranks 0 and 1 so they
do not stack on the shared expert's. One and two ranks declare as before.
This commit is contained in:
keptn42 authored and StillDeadcode committed 2026-10-05 12:52:44 +02:00
1 parent bc2e6ba614
commit 63d35ff791
4 files changed
+324 -82

No files matched your search

+10 -7
View File
@@ -307,13 +307,16 @@ above the block count is refused at declare, by name: a rank with an empty slice
and still joins the all-reduce. The shared expert's 640 columns split as evenly as whole blocks
allow: five blocks over four ranks is rank 2 `[0, 256)` and one block each on ranks 3, 0 and 1.
**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 routed experts and ranks 2 and 3
compute two. What does not divide elsewhere is cut from the other end: the shared expert's extra
block is rank 2's, and the protected bf16 experts' ten 64-wide tiles go 2, 2, 3, 3. That takes one
shared block off rank 0, the slowest rank, and leaves ranks 0 and 1 still a routed block per
even/odd pair ahead of ranks 2 and 3 at every block's all-reduce. Equal shares need the extra block
rotated by the expert's number mod 4: four slice tables where `moe_gemm_q` takes two.
**At four ranks the classes are four.** Parity gives the extra block only two places to go, so
ranks 0 and 1 would compute three blocks of every even/odd pair of routed experts and ranks 2 and 3
two, and every block's all-reduce would have 2 and 3 wait. So at four ranks the cut above is made
per class of the expert's number mod 4, the rank's place shifted by the class: rank `r` takes
`[0, 2)` blocks of class `r` and one block of each other class, five blocks of every four experts
on every rank. That is `moe_gemm_q_mod4`, four slice tables where `moe_gemm_q` takes two
(`docs/OPS.md`), and every slice is one a rank already took of some parity. A layer that keeps two
experts plain bf16 has 510 quantised ones, and its first two classes are one expert longer. What
does not divide elsewhere stays apart: the shared expert's extra block is rank 2's and the
protected bf16 experts' ten 64-wide tiles go 3, 3, 2, 2.
Expert parallelism — whole experts a rank — is what this replaced, and why it stays replaced: the
recipe protects its bf16 experts in pairs precisely so each rank's quantised count stays even, and
sharding experts by rank breaks that parity property the weight tables rest on.