Archived
libr4d: the exact two-shot all-reduce takes every prefill-sized message
R4D_AR_TWOSHOT_WIDE_MAX_ELEMS was 20971520 -- a 4096-token chunk of a 5120-wide residual -- and the band above it went back to the one-shot, which sends (ws-1)*N bytes a rank where the two-shot sends 2*(ws-1)/ws*N. At the default --max-num-batched-tokens 8192, Gemma 4 26B-A4B's attention reduce is 8192 x 2816 = 23M elements and its feed-forward reduce, which carries both branches for their own post-norms, 46M: both over the bound, so every full prefill chunk went one-shot at twice the bytes. --profile-ops on 4x R9700, tp 4, a 20489-token prefill (chunks of 8192, 8192, 4105) fits one link rate across all of it: the attention reduces 16.8 ms the three calls (two one-shot, one two-shot) and the feed-forward reduces ~37 ms (all one-shot), 1.6 s of the 2.7 s prefill. The same rate with every call two-shot is ~9 and ~19 ms: about 0.8 s less a 20k prefill. The bound guards the kernel's int word offsets and nothing else -- the scratch already holds a full message per slot (r4d_ar_entry.hip build()), twice what the two-shot uses -- so it is now 2^28 elements, 2^26 words at fp32. The fold is the one-shot's, fp32 in ascending rank order, so the band edge moves no bits. Fewer bands also means one scratch set less: the old 20971520 band was its own instance, ~335 MiB a rank at tp 4. plugin_test: a 16384-token chunk is two-shot to its end, and the one-shot still takes a message past the bound. r4d_selftest's three-rank pattern walks a 46137344-element message, past the old ceiling. Not yet run on the cards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0d95046f6f
commit
a378b41abb
5 files changed
+22
-12
No files matched your search
+10
-5
@@ -901,13 +901,18 @@ TEST(libr4d_resolves_the_all_reduce_by_message_size) {
|
||||
CHECK_EQ(names(bands(2, 1, chunk)),
|
||||
"524288:ar_oneshot_2rank_exact 5242880:ar_oneshot_2rank_exact ");
|
||||
|
||||
/* Above the two-shot's cap the one-shot takes the message back. */
|
||||
/* A 16384-token chunk is two-shot to its end: the two-shot's bound is a guard on its word
|
||||
* offsets, not a prefill size, and a chunk past the old 20971520 went back to the one-shot's
|
||||
* twice-as-heavy send. */
|
||||
CHECK_EQ(names(bands(4, 1, 16384)),
|
||||
"524288:ar_oneshot_4rank_exact 20971520:ar_twoshot_4rank_exact "
|
||||
"41943040:ar_oneshot_4rank_exact ");
|
||||
"524288:ar_oneshot_4rank_exact 41943040:ar_twoshot_4rank_exact ");
|
||||
CHECK_EQ(names(bands(3, 1, 16384)),
|
||||
"524288:ar_oneshot_3rank_exact 20971520:ar_twoshot_3rank_exact "
|
||||
"41943040:ar_oneshot_3rank_exact ");
|
||||
"524288:ar_oneshot_3rank_exact 41943040:ar_twoshot_3rank_exact ");
|
||||
|
||||
/* Above the two-shot's bound the one-shot takes the message back. */
|
||||
CHECK_EQ(names(bands(4, 1, 131072)),
|
||||
"524288:ar_oneshot_4rank_exact 268435456:ar_twoshot_4rank_exact "
|
||||
"335544320:ar_oneshot_4rank_exact ");
|
||||
|
||||
/* A step that never exceeds the bound has one band, and it is the one-shot's. */
|
||||
CHECK_EQ(names(bands(4, 1, 128)), "327680:ar_oneshot_4rank_exact ");
|
||||
|
||||
Reference in new issue
Block a user