arch: the experts stay on the rotation; only the delta net goes remainder-first

An expert block is a whole GEMM of every routed token; a rank taking the
extra block of every class became the step's slowest rank. Measured on
Flash-Next at three ranks, interleaved image A/B, two reps each: experts
50/25/25 cost 25% a step single-stream; one class's extra block
(37/25/37) swung 16.5-19.1 ms between boots; the delta-net head alone on
the attention-zero rank gave 15.6 ms both reps against 16.7-17.2, c1
+10-16%, c4 +4%, c8 +2-3%, acceptance unchanged at 2.54 tokens a step.
The experts cut as every world always has; TP2 and TP4 are untouched.
This commit is contained in:
baKon authored and StillDeadcode committed 2026-10-06 11:23:06 +02:00
1 parent 2d93182213
commit 92b8aaff2b
2 files changed
+21 -15

No files matched your search

+8 -7
View File
@@ -733,11 +733,12 @@ inline long long meta_int2(const RadModelMeta* m, const char* gguf_key, const ch
* count). With it set, a width the world does not divide is left whole in g.n_ff and the plugin
* takes its slice from there; without it the refusal stands, because for every other plugin g.n_ff
* IS the per-rank width. A width that does divide is unaffected either way. */
/* THE REMAINDER-FIRST ORDER OF THE RANKS. Whatever does not divide evenly over the world -- the
* extra block of an expert's width, the extra delta-net head -- goes to the ranks with NO
* attention first: they pay nothing for attention (rad_block_attn_gated_fp8.h: one fill) and keep
* no attention cache (rad_kv_group_zero), so they have the time and the memory for it, and every
* rank with heads is lighter for it. This is a rank's PLACE in that order: the attention-zero ranks
/* THE REMAINDER-FIRST ORDER OF THE RANKS. What does not divide evenly over the world and is a
* HEAD'S worth of work -- the extra delta-net head -- goes to the ranks with NO attention first:
* they pay nothing for attention (rad_block_attn_gated_fp8.h: one fill) and keep no attention
* cache (rad_kv_group_zero), so they have the time for it, and the rank that held the extra head
* AND attention -- the step's slowest -- is lighter for it. An expert's extra block is not a
* head's worth (qwen4exp_fp8.cpp says why it stays on the rotation). This is a rank's PLACE in that order: the attention-zero ranks
* take places 0..n-1 whatever `parity` is, and the attention ranks follow in today's rotation by
* `parity` -- so where no rank is attention-zero (every world the heads divide) the place is
* exactly (rank - parity) mod world and every cut is what it always was, byte for byte. */
@@ -823,8 +824,8 @@ inline int geom_from(Geom& g, const RadModelMeta* m, const RadBuildCtx* c,
g.attn_zero = g.rank >= g.attn_world;
g.attn_rank = g.attn_zero ? g.attn_world - 1 : g.rank;
fprintf(stderr, "radiance: world_size = %d over n_head_kv = %lld: attention on %d rank(s), "
"rank(s) %d..%d carry no attention and take the delta net's and the "
"experts' remainders first\n", g.world, (long long)g.n_head_kv_all,
"rank(s) %d..%d carry no attention and take the delta net's remainder "
"first\n", g.world, (long long)g.n_head_kv_all,
g.attn_world, g.attn_world, g.world - 1);
}
const int aw = g.attn_world, ar = g.attn_rank;