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
@@ -11241,7 +11241,7 @@ static void ar_three_rank(const Plugin& pl, const std::vector<int>& devs, const
|
||||
* sums correctly. This one gives every element its own value, so a word reduced by the wrong
|
||||
* owner, gathered from the wrong slot or dropped at a short shard's end is a wrong number at a
|
||||
* known index. The sizes walk the uneven split: words % 3 of 0, 1 and 2, from a 16-word message
|
||||
* to the row's 20971520-element ceiling, in place (how every block issues it) and once out of
|
||||
* to past the old 20971520 ceiling, in place (how every block issues it) and once out of
|
||||
* place, back to back on ONE instance so the slot parity and the changing block count are
|
||||
* exercised the way a step's mixed messages exercise them. The oracle is the fold the kernel
|
||||
* claims -- fp32 in ascending rank order, rounded once -- so it is bit for bit, and so it is also
|
||||
@@ -11320,8 +11320,9 @@ static void ar_three_rank_pattern(const Plugin& pl, const std::vector<int>& devs
|
||||
struct Run { const char* dtype; std::vector<int64_t> sizes; int oop; };
|
||||
const std::vector<Run> runs = {
|
||||
/* bf16, the residual: words = numel / 8. 2048 x 2048 rows is words % 3 == 2, x 2049 is
|
||||
* 0, x 2050 is 1; 128 is 16 words (1), 24008 is 3001 (1); 20971520 the ceiling (1). */
|
||||
{ "bf16", { 4194304, 128, 4196352, 24008, 4198400, 20971520, 4194304 }, 2 },
|
||||
* 0, x 2050 is 1; 128 is 16 words (1), 24008 is 3001 (1); 20971520 the old ceiling (1);
|
||||
* 46137344, Gemma 4's feed-forward reduce at an 8192-token chunk, past it (1). */
|
||||
{ "bf16", { 4194304, 128, 4196352, 24008, 4198400, 20971520, 46137344, 4194304 }, 2 },
|
||||
/* fp32: words = numel / 4. 8196 -> 2049 (0), 4100 -> 1025 (2), 1048580 -> 262145 (2). */
|
||||
{ "fp32", { 8196, 4100, 1048580 }, 0 },
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user