Repository navigation
feat(ep/v2): bf16 push combine on gfx1250, chosen per call - #964
Conversation
A gfx1250 intranode op with a bf16 combine and quant_type="none", under bf16 or fp8 dispatch, can now push: each rank reads its expert-output rows where they are and writes them into a landing area on the token's source rank, which reduces them. The gather combine reads its input from the op's staging rows (combine_in_view()), so an input passed as a plain tensor is first copied there; the push needs no copy. The op builds the push plans next to its gather ones when its geometry comes from the tuning tables, it is not entirely within the LL128 range, and _BF16_PUSH_TABLE has its shape (EP4 and EP8, hidden 7168, topk 6). A call takes LL128 at up to 64 tokens a rank as before; the gather combine when it asks for the weight fold, passes a snapshot handle, or passes an input already in combine_in_view() at up to in_view_pull_max tokens a rank (EP4 4096, EP8 2048); the push otherwise, bucketed by token count. All ranks of a call must choose alike, which holds when they pass their input the same way and, from combine_in_view(), stay on one side of in_view_pull_max, as with the LL128 split. No new argument, switch or env var; lookup() and dispatch_combine_op.py are as on main, and a Cfg without combineBf16Push compiles the code it did. Cost: a landing area of about 0.47 GB a GPU at EP4 and 0.70 GB at EP8 for 8192 tokens a rank, and three more combine kernels to JIT. Where the fp4 / fp8 push overlaps its reduce with the send, the bf16 push takes that path with a bf16 wire row; 24-warp blocks with more than four rows a token reduce 16 elements a lane a pass, and four rows and fewer move 8-byte pieces that run across the lanes. Elsewhere it sends runs of rows with TDM, dealing them to the blocks in turn, meets every rank, then reduces. test_bf16_push_select.py is new; bench_ep.py CHECK verifies the call the op answers and the weight fold in a second pair.
jhchouuu
left a comment
There was a problem hiding this comment.
Tested on gfx1250: EP4, hidden 7168, topk 6, 8 experts per rank, bf16. Main at this PR's merge-base vs this PR.
Blocking: ranks can take different combines in the same call, and the result is then silently wrong.
_pull_or_push decides on each rank from that rank's own num_tokens and from whether its own input is combine_in_view(). A push needs every rank to push: a rank that pulls never writes the other ranks' landing rows, so the pushing ranks reduce whatever is already there. Under DP the token counts differ from rank to rank, so ranks on opposite sides of in_view_pull_max (4096 at EP4, 2048 at EP8) disagree.
Wrong tokens per rank, one call each:
| per-rank tokens / input | main | this PR |
|---|---|---|
| all ranks: 5000, plain | 0 | 0 (push) |
all ranks: 3000, combine_in_view() |
0 | 0 (pull) |
rank 0: 4000, ranks 1-3: 4200, all combine_in_view() |
0 | rank 0: 0; ranks 1-3: 3583 / 3538 / 3569 of 4200 |
all ranks: 3000; rank 0 combine_in_view(), ranks 1-3 plain |
0 | rank 0: 3000 of 3000; ranks 1-3: 2567 / 2565 / 2548 of 3000 |
Neither case hangs or raises an error. The choice has to come from something every rank agrees on, or the ranks have to agree on it before the call. For example: push for every call except weights and snapshot calls, which every rank makes alike. test_bf16_push_select.py uses the same count on every rank, so it cannot catch this; a case where the per-rank counts fall on both sides of in_view_pull_max would.
Memory, and no way to opt out. Every bf16 op whose shape is in _BF16_PUSH_TABLE now allocates the landing area (about 0.47 GB at EP4 and 0.70 GB at EP8 for 8192 tokens per rank), whether or not any call pushes. The only way to avoid it is to pin the geometry. A caller that sizes the cco communicator with its own formula rather than describe() will now fail to allocate. Please add an opt-out (a config field or an env var) and mention it in the description.
Performance. The description gives no numbers. On our gfx1250 parts, the overlapped push path is slow for main's existing fp4 push combine as well: 64x24 takes 1387 us at 4096 tokens, against 148 us for the bf16 pull. So we could not evaluate the gain here. Please post the push vs pull numbers the table is based on (combine us per token count, EP4 and EP8). Where this PR still pulls, its combine times match main's: 52.2 / 84.1 / 147.9 us at 1024 / 2048 / 4096 tokens.
Smaller points.
bf16_push()reads_device_key(). Since #874, the other tables go through_device_keys()so that gfx1250-strict parts can have their own rows. After the rebase, this table should do the same; otherwise strict parts take gfx1250 rows that were never measured there.- The PR is based on a commit before #874 and needs a rebase.
|
GPU CI for
Test groups (the steps that run in those jobs): epv2. Lanes follow the changed files. Adding |
|
Sorry for the close/reopen. It re-triggers CI on the current main, which runs only the tests this PR's changes need (#970) instead of the full suite. Nothing in the PR changed. CI now runs only the build and the EPv2 tests. |
…mbine the same way on every rank Brings in #874 and the KernelConfig schedule; the push plans are keyed by tuning.KernelConfig like the schedule's. Review changes: - Above LL128's max_tok a combine pulls only when it asks for the weight fold or combines a snapshot handle, which every rank of a call does alike, and pushes otherwise, whatever its token count and wherever its input lives; in_view_pull_max is gone. Before, each rank chose from its own token count and from whether its own input was in combine_in_view(), so the ranks of one call could disagree, and the pushing ranks then reduced landing rows nobody wrote. - The push geometry still comes from the rank's own token count; ranks of one call may run different push geometries, since the landing rows and their signals do not depend on it. - bf16_push() reads _device_keys()[0], so gfx1250-strict parts have no row and build no push plans. - MORI_EP_BF16_PUSH=0 builds no push plans and no landing area; any value but 0 or 1 raises. - test_bf16_push_select.py: token counts crossing max_tok and every push bucket edge, the same on every rank and different on each, with the input passed five ways (plain tensor, combine_in_view(), combine_in_view() on alternate ranks only, with weights, through a snapshot handle); under MORI_EP_BF16_PUSH=0 it checks that no push plan is built. - README: the push plans, which combine a call runs, and the opt-out.
|
Thanks for testing this and for the repro table. The blocking issue was real. It's fixed in 602e8ce together with the other points, and the description is updated. Ranks taking different combines. Fixed the way you suggested. Above LL128's
On MI450 (gfx1250, not strict), EP4, 96 experts per rank, with this head's tree, all 16 checks pass at M=1024 (1 round) and at M=8192 (2 rounds). I haven't run EP8 on this head yet; I don't have two nodes free right now. Related, and unchanged from main: the LL128 split itself ( Memory / opt-out. Performance. Combine latency in us, medians of 3 alternating rounds. MI450 rev 1 (256 CUs), HIP graph, ITERS=50, hidden 7168, topk 6, 96 experts per rank, capacity 8192 tokens, bf16 dispatch, CHECK passed first. Measured on development commits squashed into the previous head 196ca3e; not re-timed after bringing in main. EP4 (one node):
EP8 (two nodes):
The pull at 96 and 192 is slow on main too. A later commit in 196ca3e sped up the geometries that do not overlap the reduce: EP8 push at 128 / 256 went to 24.22 / 36.44 against copy-then-pull 26.38 / 39.03 in the same run, and EP4 64x16 got 2.2-2.8 faster at 160-256. The description also has EP8 with fp8 dispatch. What the fix costs: an input already in Your 1387 us for the fp4 64x24 push fits #874's note that 24-warp pushes are several times slower on ASIC revision 0. If your parts are revision 0, they resolve to Smaller points. |
jhchouuu
left a comment
There was a problem hiding this comment.
Approving. The per-rank choice is fixed, and the new head matches the description:
- A combine pulls only for the weight fold or a snapshot handle, so the choice no longer depends on anything that differs between ranks.
- Ranks of one call running different push geometries is fine. The non-overlapped barrier and
EpFp4OvlArriveboth write the call's phase into the sameoffXdb[rank]slot on every peer once all rows are sent, and the overlapped reduce accepts that slot for a source's rows. Both sends land a row at its receive index pluslandFrom. The test'se/e + 1calls cover the 64x16 / 64x24 boundary at EP4. MORI_EP_BF16_PUSH=0and_device_keys()[0]look good; gfx1250-strict gets no push plans.
Not blocking:
- EP8 hasn't run on this head. At EP8 64x16 also takes the overlapped reduce, so the non-overlapped / overlapped boundary is 192 / 193 rather than 512 / 513. One EP8 run of
test_bf16_push_select.pybefore merging would cover it. - The performance tables come from the development commits before main came in, and #874 changed the schedule. Re-timing on this head would make the description match what merges.
- The LL128 split you mention (
_pick, chosen from each rank's ownnum_tokens) looks worse than one bad call, from reading the code. The bf16 LL128 combine counts with its own_lcSeqand never advancesxdbFlag, while push and pull advance it on every call. After one call whose per-rank counts straddlemax_tok, the ranks' phases stay apart, so later calls compare different phases: a rank can wait forever, or read rows before they land. Under DP decode, per-rank counts around 64 often differ. This is already on main, so not for this PR.
will be updated on another PR. |
Checked against main after merging it: #975, #964 and the anvil changes landed since the last merge. EP: - gfx1250 is EPv2 only: since #975, EPv1 refuses wave32 GPUs. IntraNode's gfx125x launch default goes with it. - The HIP backend also has the gfx125x push combine (fp8_blockwise or FP4, plus the per-call bf16 push on gfx1250). The package README said FlyDSL was the default everywhere and that HIP only gathers. - The quick start's combine passes no weights: the weight fold is for training backward. The package README has no per_rank_vmm section. - README: the backend-parity test and bench_ep.py run under torchrun, and the intranode test's matrix is for gfx942/gfx950. CCO and CCL: - Single-node GDA is gda_connection_type = GDA_CONNECTION_FULL; MORI_CCO_GDA_CONN is only example 03's switch. - GdaCallerOrdered has no signal, and only its own flushes release posts. - mori.ccl no longer binds AllGatherIntoTensor, and HierAllGather crosses nodes over an RDMA ring. Fused operators: - gemm_ar's fp8 gather is an LSA pull by default, its window has a tmp slot, and its op test runs on 2 ranks. bf16 also takes block_m=128. Only bench_a2a_gemm runs every mode by default. - a2a_gemm: mismatched chunks hang or give wrong results, depending on which side has more. The example needs MORI_ENABLE_SDMA=1. - anvil.cpp is cited without a line number. The a2a VMM sizing is the overview's, not the tests'. UMBP: - Single-node script: MORI_PIP_FLAGS never reaches pip, SGLANG_REPO is not used, and the server runs from NFS_BASE whatever MORI_REPO says. - Only clients log the activity summary, and at INFO while the default level is error. Remote puts fail at once on a full SSD staging arena. - StandaloneClient is gone; the design doc now gives CreateUMBPClient's current choices. Site: - MORI-IR-GUIDE.html and MORI_IR_INTEGRATION.html redirect to the SHMEM guide's IR section. The README has the MORI-IR tests again, and the SHMEM guide links python/mori/ir/README.md. - Internal hosts, private IPs, local paths and archive names are replaced with placeholders or dropped. - Smaller fixes: the profiler's clock helper returns kHz, a self-link, a doubled "and", a conf.py comment. python -m sphinx -E -n -W --keep-going -b html passes, and tools/check_docs_links.py reports 0 errors over 3330 local links. Co-Authored-By: Claude <[email protected]>
… again on gfx1250 On a gfx1250 op with bf16 push plans, a combine that is not on the LL128 plans and whose input already sits in combine_in_view() runs the schedule's gather combine again, at every token count: #964's first rule without its in_view_pull_max cap. A plain tensor still pushes, read where it is with no copy; weights and snapshot handles still pull; which calls go to LL128 is unchanged (low_latency, or max_num_inp_token_across_ranks at most the LL128 max_tok). All ranks of a call must pass their input the same way, from combine_in_view() or not; their token counts may differ. Where the bf16 card fold is on (EP8 on 96-CU gfx1250 partitions), an input in combine_in_view() pushes, as before. test_bf16_push_select.py expects an input in combine_in_view() to pull, or to push where the fold is on, and drops the case that passed it from combine_in_view() on alternate ranks only.
…ce a card and folds each card's rows (#1007) * perf(EPv2/gfx1250): EP8 bf16 on the 96-CU partitions sends a token once a card and folds the rows of each card in the push combine Two partitions share a card. For bf16 dispatch with the bf16 push combine, EP8, hidden 7168, topk 6 on gfx1250/96cu: a token with experts on both partitions of another card is sent to only one of them, picked by token parity, and the other gets a forward entry; that partition then copies the row from its sibling over the in-card link, in a second launch for calls up to 256 tokens and in 16 extra blocks of the dispatch launch above that. The LL128 dispatch sends the units past the first of such a token once to the card, and the partition they land on writes them on to its sibling (ll128Dedup). In the push combine the landing partition adds its sibling's row into its own before the row leaves the card, so each card sends back one row a token; with the fold on, the LL128 path covers up to 160 tokens a rank instead of 176. Tables: _CARD_TABLE (16 pull blocks, second launch up to 256 tokens) and the gfx1250/96cu rows of _BF16_PUSH_TABLE and _LL128_TABLE; the device keys gain the CU count when it is known. dispatch(snapshot=True) is refused on this geometry, since the fold reads the latest dispatch; MORI_EP_BF16_PUSH=0 restores the previous path. * perf(EPv2/gfx1250): EP8 bf16 on the 96-CU partitions takes half the blocks of an EP4 rank Two ranks share each card. For bf16 dispatch with the bf16 push combine, EP8, hidden 7168, topk 6 on gfx1250/96cu, each rank now takes half the blocks the gfx1250 EP4 rows give a rank at the same tokens a card: dispatch 32x16 up to 1024 tokens a rank and 64x16 above, the push combine 32 blocks, LL128 32x16, and 8 card pull blocks instead of 16. The fp8 and fp4 dispatch rows stay those of gfx1250. * fix(EPv2/gfx1250): keep the plain dispatch's machine code that of main The card forward holder was declared in every dispatch build. Unused, it still changed the register allocation of the plain fp8 dispatch (EP4 64x8, 64x16 and 128x16 with scales: 116 VGPRs to 115). It is now an int unless cardDedup is on, and the plain kernels again differ from main only in kernarg offsets and an assert line. * perf(EPv2/gfx1250): the 96-CU partitions pull with 4 blocks The sibling pull of the card dedup took 8 blocks a rank. With 4 the EP8 bf16 dispatch plus combine (hidden 7168, topk 6, MI450 in DPX) is unchanged up to 1024 tokens a rank and 0.5-1.7% slower at 2048 and 4096, and every rank keeps 4 more CUs for the GEMMs that run beside it. * test(ep/v2): expect the snapshot refusal in test_bf16_push_select where the bf16 card fold is on * perf(ep/v2): a bf16 combine whose input is in combine_in_view() pulls again on gfx1250 On a gfx1250 op with bf16 push plans, a combine that is not on the LL128 plans and whose input already sits in combine_in_view() runs the schedule's gather combine again, at every token count: #964's first rule without its in_view_pull_max cap. A plain tensor still pushes, read where it is with no copy; weights and snapshot handles still pull; which calls go to LL128 is unchanged (low_latency, or max_num_inp_token_across_ranks at most the LL128 max_tok). All ranks of a call must pass their input the same way, from combine_in_view() or not; their token counts may differ. Where the bf16 card fold is on (EP8 on 96-CU gfx1250 partitions), an input in combine_in_view() pushes, as before. test_bf16_push_select.py expects an input in combine_in_view() to pull, or to push where the fold is on, and drops the case that passed it from combine_in_view() on alternate ranks only. * perf(EPv2/gfx1250): the 96-CU partitions pull with 8 blocks again On a second MI450 node in DPX + NPS2, 4 pull blocks cost 5.4-6.6% of the EP8 bf16 dispatch plus combine (hidden 7168, topk 6) at 2048, 4096 and 8192 tokens a rank, all of it in dispatch: 527.57 / 996.51 / 1933.86 us against 500.40 / 939.83 / 1814.49 with 8 (one build, only the pull blocks changed, 4 alternating rounds). 16 blocks would take off another 9.61 / 10.62 / 20.01 us (1.1-1.9%). Calls of up to 256 tokens a rank launch no pull blocks and are unchanged; the push combine stays at 32 blocks. * perf(EPv2/gfx1250): LL128 on the 96-CU partitions takes calls below 128 tokens a rank With 32x16 blocks, the LL128 dispatch and combine of EP8 bf16 (hidden 7168, topk 6) on gfx1250/96cu took 102.9 us at 128 tokens a rank, against 77.7 us for the 32-block dispatch and push combine (one build, LL128 on or off, 3 alternating rounds). The edges the row had, 176 tokens and 160 with the card fold on, were set for LL128 64x16. It now covers up to 127 tokens with the fold on or off, so ll128() loses its card_fold argument. Calls of 1 to 96 tokens a rank have not been timed against the 32-block schedule. * perf(EPv2/gfx1250): LL128 on the 96-CU partitions takes calls below 64 tokens a rank With 32x16 blocks, the LL128 dispatch and combine of EP8 bf16 (hidden 7168, topk 6) on gfx1250/96cu beat the 32-block dispatch and push combine at every power of two from 1 to 32 tokens a rank (24.8 against 45.5 us at 1 token, 44.1 against 56.1 us at 32) and lost at 64 (64.5 against 62.9 us) and 128 (102.9 against 77.7 us); one build, LL128 on or off, 4 alternating rounds (3 at 128). The edge is set on powers of two, so it moves from 127 to 63 tokens. * perf(EPv2/gfx1250): the bf16 card fold sends rows for other cards from every block all the way The push combine with the card fold (EP8 bf16 on the 96-CU partitions) changes in three places. No table, no other plan and no Python changes. - The reducing warps of a block hand its rows to the sibling device (the copy into the window and the flag) right after the block's sort. The store waves did that while they waited for a chunk, or after their last store; with the fabric busy they seldom waited, so the rows that add a sibling row were held back until the sibling's block had sent everything. - From 96 received rows a block (1024 tokens a rank in the bench), block b takes rows b, b + blocks, b + 2 * blocks, ... instead of one contiguous range, and starts at its own place in that list, so the blocks of all ranks do not send to the same rank at the same time. A row that adds its sibling's is sorted with its token group instead of after every other row; the sort table's top bit marks it. The received rows are ordered by source rank: of 32 blocks, 8 held only rows of their own card and were done after a third of the send, and the tokens of the folded rows completed in its last third. Now every block sends to other cards from start to end and tokens complete all along. - On a call with at most 8 reduce units a reducing warp (up to 292 tokens a rank here) the 7 passes of a token's reduce are units of their own, so the warps that have nothing to send share a token. Measured on one node of MI450 in DPX mode (8 devices of 96 CUs), EP8, bf16, hidden 7168, topk 6, 48 experts a rank, HIP graph, no MORI_EP_* variable, the parent commit against this one in one batch: per token count one eager CHECK run each (all pass), then 4 alternating rounds (ITERS=50); dispatch + combine = sum in us, medians: tokens a rank parent this commit change 64 31.84 + 31.04 = 62.88 31.23 + 29.93 = 61.16 -2.7% 128 40.70 + 36.82 = 77.52 40.19 + 35.63 = 75.82 -2.2% 256 55.20 + 51.89 = 107.09 54.74 + 51.41 = 106.15 -0.9% 512 78.50 + 78.09 = 156.59 78.71 + 78.03 = 156.74 +0.1% 1024 129.07 + 135.16 = 264.23 128.81 + 130.56 = 259.37 -1.8% 2048 227.72 + 245.54 = 473.26 225.98 + 235.88 = 461.86 -2.4% 4096 422.78 + 472.00 = 894.78 417.17 + 442.67 = 859.84 -3.9% 8192 815.03 + 917.80 = 1732.83 796.98 + 837.91 = 1634.89 -5.7% Every round of every count but 512 has this commit ahead; at 512 it is 0.0 to 0.6 us behind a round. Calls below 64 tokens a rank run the LL128 plans, whose instructions are the parent's. Checks: eager CHECK passes at 1, 2, 4, ..., 8192 tokens a rank (from 2048 up without the weighted pair), at 200, 292, 293, 300, 680, 700, 720, 1000, 3000 and 5000 with another seed, and at 128, 300, 1024 and 4096 with the combine input in a buffer of its own; test_ll128_split.py (97) and test_bf16_push_select.py (17) pass; test_jit_binding.py -k card (18) and test_gfx1250_strict_arch.py pass without a GPU. clang-format 20.1.8 changes no line. Compiled without a GPU, 13 combine plans without the fold (bf16 push at 8, 16 and 24 warps, fp8 and fp4 push, pull; EP4 and EP8) have the parent's instructions line for line; so have the 60 other plans this configuration compiled (LL128, dispatch, pull combine), 4 of them apart from code offsets. * perf(EPv2/gfx1250): fp8 / fp4 take the card dedup and the card fold on the 96-CU partitions, 32 blocks for every dtype The card dedup and the card fold of the bf16 path now serve the fp8 and fp4 dispatches and the fp8 / fp4 push combines (e8m0 scales), and every 96-CU row runs 32 blocks, half the 64 that every unpartitioned row keeps under the capped profile. - EpCardDedupOk admits an fp4 dispatch wherever its payload takes the general loops (past four ranks, more warps a block than ranks), as fp8 and bf16 do; EpCardCombineOk admits the fp8 / fp4 push combine on 16 warps. No kernel source changes; plans without the card options compile to the same code as before. - The op turns the card layout on for quant_type fp8_blockwise / fp4_blockwise when every combine row of its schedule is 16 warps and within the fold's rows a block; the LL128 plans of a split op stay unfolded. - gfx1250/96cu rows: dispatch 32x16 for every dtype (plus the 8 pull blocks), the gather combine 32x8, the fp8 / fp4 push combine 32x16, LL128 up to 64 tokens a rank for fp8 (from 96 the schedule's plans are ahead: 62.0 against 64.0 us at 96, 65.6 against 79.1 at 128) and up to 128 for fp4. Measured on one node of MI450 in DPX mode (8 devices of 96 CUs), EP8, hidden 7168, topk 6, 48 experts a rank, HIP graph, no MORI_EP_* variable; per token count one eager CHECK run (all pass), then one graph round (ITERS=50); us: tokens a rank fp4 dispatch fp4 combine fp8 dispatch fp8 combine bf16 dispatch bf16 combine 1 11.41 10.33 11.88 10.65 13.61 11.21 2 11.75 10.35 12.24 10.65 14.92 11.54 4 12.37 10.95 13.47 11.42 16.72 11.90 8 13.51 10.71 15.52 12.56 17.74 12.62 16 15.13 11.91 17.35 12.57 20.17 14.87 32 17.13 12.43 20.64 15.35 23.88 20.20 64 20.97 17.83 28.24 21.17 31.04 29.90 128 29.83 27.02 32.56 33.07 40.25 35.47 256 34.84 37.98 45.00 49.85 54.73 51.33 512 49.09 47.12 58.44 65.86 78.42 78.18 1024 68.57 76.23 88.20 104.74 128.88 130.51 2048 115.71 127.99 146.67 177.87 230.31 232.79 4096 201.66 221.48 258.27 316.24 426.01 437.33 8192 372.31 410.06 483.70 585.66 815.54 834.57
A gfx1250 intranode op with a bf16 combine and
quant_type="none", under bf16 or fp8 dispatch, can now push: each rank reads its expert-output rows where they are and writes them into a landing area on the token's source rank, which reduces them. The pull (gather) combine reads its input from the op's staging rows (combine_in_view()), so an input passed as a plain tensor is first copied there; the push needs no copy.Which ops build the push plans
gfx1250, intranode, not async_ll,
quant_type="none", bf16 combine, bf16 or fp8 dispatch, geometry from the tuning tables (not pinned by the caller), an op not entirely within the LL128 range, and an entry in the new_BF16_PUSH_TABLE(EP4 and EP8 at hidden 7168, topk 6).bf16_push()reads that table through_device_keys()[0], so gfx1250-strict parts have no row and build no push plans. Such an op builds the push plans next to its pull ones: three more combine kernels to JIT, and a landing area of about 0.47 GB a GPU at EP4 and 0.70 GB at EP8 for 8192 tokens a rank.Opt-out:
MORI_EP_BF16_PUSH=0builds no push plans and no landing area, so the arena anddescribe()are what main gives and every combine runs main's. Any value but0or1raises.Which combine a call runs
max_toktokens on this rank (64 for these shapes): LL128, as on main.snapshot=Truehandle: the schedule's pull combine (the push folds no weights and reads routing state that the next dispatch rewrites).Rules 2 and 3 depend only on what every rank of a call does alike, so all ranks take the same combine. Ranks of one call may run different push geometries (their counts fall in different buckets): the landing rows and their arrival signals do not depend on the geometry, and the test runs such calls. Rule 1 is main's LL128 split, which is picked from each rank's own count.
Kernel (
ep_intranode_1250x.hpp,ep_spec.cpp,ep_cfg.hpp)(k*32+lane)*8, so one load instruction covers 256 contiguous bytes; the stores use the same layout. Same loads per pass, same summation order.warpId * gridDim.x + blockIdx.xfirst so that consecutive runs go to different blocks, meet every rank, then reduce.continuepast eight rows, as the fp4 / fp8 ones do since Fix/epv2 1250x r1 combine #886.Tests
test_bf16_push_select.py(new;torchrun --standalone --nproc_per_node=4, or 8; bf16 dispatch): token counts crossingmax_tokand every push bucket edge both ways, first the same on every rank, then a different count on each rank (including rank 0 at 4000 and the others at 4200). Each call passes its input as a plain tensor, fromcombine_in_view(), fromcombine_in_view()on alternate ranks only, with weights, and (abovemax_tok) through asnapshot=Truehandle. It checks which combine ran (only a push lands rows inpush_landing()), the bf16 sum against a host reference, every result equal to the plain one bit for bit, and the whole sequence again back to back. UnderMORI_EP_BF16_PUSH=0it checks that no push plan is built.Run on MI450 (gfx1250, not strict), EP4, 96 experts a rank, with this head's tree: 16 of 16 checks pass at M=1024 (1 round) and at M=8192 (2 rounds); with
MORI_EP_BF16_PUSH=0, 11 of 11 at M=1024. EP8 not run on this head.bench_ep.py: the CHECK call passes no weights, so it takes the same combine as the timed call; the weight fold is checked by a second pair.Performance
MI450 (gfx1250, ASIC revision 1, 256 CUs), HIP graph mode, ITERS=50, capacity 8192 tokens a rank, 96 experts a rank, hidden 7168, topk 6, bf16 dispatch. Combine latency in us, medians of 3 alternating rounds; CHECK passed at every count first. These ran on development commits squashed into the previous head 196ca3e: EP4 on 6c7359c9c, EP8 on 463a73be6 (its EP8 64x16 / 64x24 push kernels compile to the same instructions as those of 6c7359c9c). Not re-timed after merging main.
EP4 (one node):
combine_in_view(), then pullcombine_in_view()EP8 (two nodes):
combine_in_view(), then pullcombine_in_view()The pull at 96 and 192 tokens is slow on main too; this PR does not change it.
b2552a4b0 (later, in 196ca3e) changed the send of the geometries that do not overlap the reduce. EP8 combine at 128 / 256 tokens: push 24.22 / 36.44, copy-then-pull 26.38 / 39.03, the push faster in all 3 rounds. EP4 64x16 got 2.2 to 2.8 faster at 160 to 256 tokens, and 64x8 0.35 slower at 128.
EP8 with fp8 dispatch (bf16 combine), c8e74974e, dispatch capped at 64 blocks:
combine_in_view(), then pullWhat the per-call rule costs: an input already in
combine_in_view()is now pushed at every count abovemax_tok. In the tables above that push is 2.5 to 7.8 us slower than the pull at EP4 128 to 2048 tokens and 2.2 to 12.1 us slower at EP8 128 to 2048 (192 aside), within 1.8 us at EP4 4096, and faster at 8192. A plain-tensor input gains at every count (EP8 128 and 256 since b2552a4b0).MORI_EP_BF16_PUSH=0restores main's combines.Not measured
ep_intranode_1250x.hpponly in a compile-time arch check and in the fp8 / fp4 dispatch scale path, but headers it includes changed too.