Archived
libr4d: at eight ranks the exact one-shot ends at 8192 elements, the two-shot at 8 blocks
The exact all-reduce at eight ranks shared the three- and four-rank band: one-shot up to 524288 elements. The one-shot sends (ws-1)*N bytes a rank, seven times the message at eight ranks, where the two-shot sends 2*(ws-1)/ws*N, and on eight R9700 (PCIe P2P, bf16, warm) the two-shot is the faster from 16384 elements on. A decode step of eight streams with a draft window of six on GLM-5.3-Flash (4096 wide, an out-of-tree plugin) reduces 48 x 4096 = 196608 elements: 232 us one-shot, 68 us two-shot, where all_reduce was 20.7% of the step's device time. R4D_AR_8RANK_ONESHOT_MAX_ELEMS is 8192, a multiple of 64, the eight-rank two-shot's DIV; cArTsExact8 starts one element above it. The two-shot's block rule stops at 8 blocks at eight ranks: every block handshakes with seven peers, and past eight blocks the extra flag rounds cost more than the reduce bandwidth they add (4 blocks up to 393216 elements, 5 at 524288, 8 instead of 16 from 2097152). Both rows fold in fp32 in ascending rank order, so neither change moves a bit. numel before after 4096 one-shot 22.5 us one-shot nb 4 12.8 us 16384 one-shot 39.7 two-shot nb 4 21.5 131072 one-shot 176.3 two-shot nb 4 52.3 196608 one-shot nb 16 233.2 two-shot nb 4 68.7 524288 one-shot 573.7 two-shot nb 5 177.4 2097152 two-shot nb 16 615.8 two-shot nb 8 610.5 8388608 two-shot nb 16 2460 two-shot nb 8 2489 16777216 two-shot nb 16 4999 two-shot nb 8 4824 At 4096 the rule already chose 4 blocks; the 22.5 us was the microbenchmark's, ten launches after the host-side check, which now warms up with as many launches as it times. Band edges are the union over every candidate row (core/plugin/bands.cpp), so the edge at 8192 splits the two-, three- and four-rank bands too. Both halves resolve the same row, kernel and bits, at the cost of one more instance per (width, dtype) whose slot holds 8192 elements. Keeping the edge to eight ranks would need the band builder to skip rows whose fixed constraints the geometry rules out (world_size 8 here), a change to every op's bands for one row; plugin_test states the new edges instead. r4d_selftest runs the eight-rank rows (ar_oneshot_8rank_exact, ar_twoshot_8rank_exact, ar_gather_8rank) through the width-parametrised cases of the three- and four-rank ones instead of skipping them: the pattern's band edge is at 8192 and 8256 there, and a 9-word message must be refused. --perfar8 numel [iters] [dtype] times both rows, one thread a card, at the block rule and at 4 to 64 blocks, each checked bit for bit against the fold on every rank. On the cards: ar_oneshot_8rank_exact 20 ok, ar_twoshot_8rank_exact 16 ok, ar_gather_8rank 5 ok. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
8015d9a639
commit
0eb3d96ce1
6 files changed
+400
-65
No files matched your search
+10
-5
@@ -70,6 +70,11 @@
|
||||
* (32 sequences verifying four tokens) and a 2048-token prefill chunk is 10 MiB. A multiple of 128
|
||||
* (see pAllReduce's `numel`). */
|
||||
#define R4D_AR_WIDE_ONESHOT_MAX_ELEMS 524288
|
||||
/* The same bound at eight ranks, where the one-shot's (ws-1)*N is seven times the message and
|
||||
* loses early: on eight R9700 the two-shot is faster from 16384 elements on (21.6 against 26.3
|
||||
* us), at a 48-row decode message of 4096 wide 3.4 times. A multiple of 64, the 8-rank
|
||||
* two-shot's DIV. */
|
||||
#define R4D_AR_8RANK_ONESHOT_MAX_ELEMS 8192
|
||||
#define R4D_XSTR(v) R4D_STR(v)
|
||||
#define R4D_STR(v) #v
|
||||
|
||||
@@ -2675,9 +2680,9 @@ static const RadOpSchema kSchemas[] = {
|
||||
SCHEMA("all_reduce", pAllReduce, oAllReduce,
|
||||
"sum over the tensor-parallel group. `exact` separates the exact sum from the "
|
||||
"quantised wire and a caller that does not declare it gets no kernel. At 4 and 8 ranks "
|
||||
"the exact sum is one-shot up to " R4D_XSTR(R4D_AR_WIDE_ONESHOT_MAX_ELEMS) " elements and "
|
||||
"two-shot above, chosen by the "
|
||||
"message's band; `hops` is accepted and no row of this plugin reads it."),
|
||||
"the exact sum is one-shot up to " R4D_XSTR(R4D_AR_WIDE_ONESHOT_MAX_ELEMS) " elements "
|
||||
"(at 8 ranks " R4D_XSTR(R4D_AR_8RANK_ONESHOT_MAX_ELEMS) ") and two-shot above, chosen "
|
||||
"by the message's band; `hops` is accepted and no row of this plugin reads it."),
|
||||
SCHEMA("all_gather", pAllGather, oAllGather,
|
||||
"y is [world_size * numel] with rank r's contribution at offset r * numel. The bytes are "
|
||||
"moved and never summed: the vocab-parallel sampler's payload is (u32 token id, f32 "
|
||||
@@ -3483,7 +3488,7 @@ static const RadConstraint cArTsExact4Lane[] = {
|
||||
};
|
||||
static const RadConstraint cArTsExact8[] = {
|
||||
C_EQ("world_size", 8), C_EQ("exact", 1), C_IN("dtype", "bf16 fp16 fp32"),
|
||||
C_DIV("numel", 64), C_GE("numel", R4D_AR_WIDE_ONESHOT_MAX_ELEMS + 1),
|
||||
C_DIV("numel", 64), C_GE("numel", R4D_AR_8RANK_ONESHOT_MAX_ELEMS + 1),
|
||||
C_LE("numel", R4D_AR_TWOSHOT_WIDE_MAX_ELEMS),
|
||||
C_P2P,
|
||||
};
|
||||
@@ -5603,7 +5608,7 @@ R4D_WIN_PAIR(512, 1) R4D_WIN_PAIR(512, 2) R4D_WIN_PAIR(512, 4) R4D_WIN_PAIR(512,
|
||||
"all-reduce (sum), reduce-scatter + all-gather over P2P IPC scratch, per-block pipelined "
|
||||
"handshake",
|
||||
"exactly 8 ranks, all peer-accessible; messages above "
|
||||
R4D_XSTR(R4D_AR_WIDE_ONESHOT_MAX_ELEMS) " elements, two hops; shares the wide family's "
|
||||
R4D_XSTR(R4D_AR_8RANK_ONESHOT_MAX_ELEMS) " elements, two hops; shares the wide family's "
|
||||
"flag/seq/scratch set; message must shard evenly over the ranks; in place; cudagraph-safe",
|
||||
"bf16 / fp16 / fp32 payload, fp32 accumulate in ascending rank order, bit-identical across ranks",
|
||||
RAD_DOMAIN_DEVICE, R4D_PRIO_AR_TWOSHOT,
|
||||
|
||||
Reference in new issue
Block a user