Archived
arch/gemma4: a prefill chunk in two slices, the all-reduces on the second lane beside the compute
On gemma-4-26B-A4B at tp 4 on 4x R9700 the all-reduces were 47% of a 20K-token prefill under --profile-ops (957 of 2020 ms): a layer reduces T x E after attention and both arms' 2T x E after the feed-forward, at ~16.5 GB/s a rank on the link, against ~8 ms of compute a layer at the average chunk. Run whole, the two take turns. A chunk of two routed passes or more (4096 tokens) now runs as two slices, and every trunk all-reduce rides the runtime's second lane (rad_lane) beside the other slice's compute: slice A's attention reduction under slice B's output projection, slice B's under slice A's two arms, slice A's feed-forward reduction under slice B's arms, and slice B's under the next layer's join and projections of slice A. Attention runs whole -- it reads every row's keys. A model of the measured times puts it at up to a quarter off an unprofiled prefill; --profile-ops syncs every op and cannot show it. The same bits as the whole step: the cut is a whole number of routed passes, so the routed arm makes the passes the whole step makes, and both slices are at least one pass, above every row band the sliced kernels have (the GEMM's 16 and 64, the reduction's one-shot edge) -- core's rule four for the second lane. The slice's partials sit dense-then-routed in its own run of the join buffer, so each slice's feed-forward reduction is one message. The order: a reduction is issued on lane 1 behind a join from lane 0, its producer; lane 0 joins lane 1 back before the consumer and before the next reduction is issued, since a join orders behind everything its lane has issued. The embedding's reduction stays on lane 0, ahead of everything lane 1 is first joined behind, so the collectives keep one order on every rank. The two buffers reduced in place are named to rad_buf_concurrent. Taken where the joins are fused, the wire is exact and there is more than one rank; RADIANCE_GEMMA4_OVERLAP=0 runs every chunk whole, and the startup note says which. A decode step never takes the lane. routed() takes a run of rows and the join row its partial lands at; attention between the projections and the output projection moves into attend(), which both paths issue. arch_test records the lane of each issue and where each join sits, and a new test holds a 6-layer 26B-A4B with the DFlash taps, at tp 4: no two issues on different lanes that touch a common element go unordered (taking every operand as read and written; dropping one wait makes it count six), lane 1 carries the trunk's 4 x 6 reductions at the slices' sizes and nothing else, the slices issue the whole step's rows by op and its routed passes, a 4095-token chunk and a decode step stay on one lane. GUIDE.md has the switch, ARCHITECTURES.md the paragraph. Not yet run on the cards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
743b7e1a6a
commit
34ee08ea5e
4 files changed
+466
-59
No files matched your search
+14
-2
@@ -492,8 +492,8 @@ The readings that stay plausible when wrong:
|
||||
pre_feedforward_layernorm_2's output. `per_expert_scale` multiplies the weight AFTER the
|
||||
renormalised top-k.
|
||||
- **The arms' two post-norms are per arm**, so under tensor parallel each arm's partial sum is
|
||||
reduced before its norm. The partials share one [2T, hidden] buffer, dense rows first, so one
|
||||
all-reduce carries both.
|
||||
reduced before its norm. The partials share one [2T, hidden] buffer, dense rows first -- each
|
||||
slice's own run of it when a prefill chunk is cut in two -- so one all-reduce carries both.
|
||||
- **The embedding scale is sqrt(hidden) rounded to bf16**: 53.0, not 53.066. The drafter reads the
|
||||
same scaled embedding.
|
||||
- **The sliding layers' KV group is `RAD_KV_FULL`**, with the window on the attention op. A
|
||||
@@ -511,6 +511,18 @@ The drafter's head is vocab-sharded with the trunk's: each rank's top-2 are all-
|
||||
`pair_argmax` picks the winner (two a rank, because a row-interleaved `all_gather` moves 16-byte
|
||||
words and one pair is 8 bytes).
|
||||
|
||||
**The prefill overlap.** At more than one rank, a prefill chunk of two routed passes or more (4096
|
||||
tokens, at the 2048-token pass) runs as two slices, and the trunk's all-reduces ride the runtime's
|
||||
second lane beside the other slice's compute: slice A's attention reduction runs under slice B's
|
||||
output projection, slice B's under slice A's two arms, and so on through the layer. Attention runs
|
||||
whole, since it reads every row's keys. The cut is a whole number of routed passes and both slices
|
||||
are above every row band the sliced kernels have, so the step issues the same kernels over the
|
||||
same rows and its output is the whole step's, bit for bit. On 4x R9700 the reductions were 47% of
|
||||
a 20K-token prefill under `--profile-ops`; a model of the measured times puts the overlap at up to
|
||||
a quarter off an unprofiled prefill. The per-op profile syncs every op, so it cannot show it --
|
||||
time a prefill without `--profile-ops`. `RADIANCE_GEMMA4_OVERLAP=0` runs every chunk whole, and the
|
||||
startup note says which. A decode step never takes the second lane.
|
||||
|
||||
**The draft head in fp8.** The drafter's head is the widest read on the draft path: the target's
|
||||
bf16 table, 352 MiB a rank at tp 4, every draft pass. A container converted with the line
|
||||
`dflash.draft_head.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16` (the three `-df` recipes
|
||||
|
||||
Reference in new issue
Block a user