Skip to content

Wide ep tuning - #843

Merged
zhangfei829 merged 60 commits into
mainfrom
wide-ep-tuning
Oct 31, 2026
Merged

zhangfei829 merged 60 commits into
mainfrom
wide-ep-tuning

Conversation

@zhangfei829

Copy link
Copy Markdown
Collaborator

ep v2 gfx1250: LL128 small-token dispatch / combine; EP16 / EP32 dispatch tuning

An op of at most a per-shape capacity (hip_tuning_configs._LL128_TABLE: EP4 / EP8 / EP16 / EP32,
hidden 7168, topk 6) runs dispatch and combine on the LL128 protocol: 128-byte lines that carry
120 data bytes and an 8-byte call number, polled by the receiver, so neither kernel needs a fence,
a grid barrier or a separate signal. The plan is chosen per op (EpCfg::ll128), stays on 64 blocks
(the rest of the CUs belong to the co-resident GEMM), and is taken only when amdgpu runs with
mtype_local=0 (MTYPE_RW); every other op and part keeps the schedule. The LL128 token count
carries its call number and snapshot routing handles copy the receive maps, so the #733 handles
keep working.

EP4 on C17, 2026-10-16, HIP graph, 3 alternating rounds, schedule -> LL128 (us; the LL128 code
as measured there, f490e25):
fp4, op of 256 (64x16 + 64x16), 1 / 64 / 128 / 256 tokens:
dispatch 18.0 -> 8.1, 22.9 -> 10.9, 21.1 -> 12.2, 22.4 -> 18.9
combine 12.2 -> 7.6, 14.7 -> 8.7, 15.1 -> 9.9, 16.7 -> 15.1
fp8, op of 128 (64x8 + 64x8), 1 / 16 / 64 / 128:
dispatch 18.2 -> 8.2, 22.8 -> 9.5, 24.2 -> 12.6, 24.6 -> 14.5
combine 12.2 -> 8.1, 13.7 -> 8.6, 15.2 -> 9.9, 16.3 -> 13.7
bf16, op of 64 (64x16 + 64x16), 1 / 16 / 64:
dispatch 18.5 -> 9.6, 25.2 -> 10.8, 27.2 -> 14.7
combine 19.5 -> 9.9, 16.1 -> 10.6, 16.4 -> 16.0

EP32 on eight C-rack hosts (C17 among them), 3 alternating rounds, us. LL128 is against the
schedule; each dispatch / table row is against the commit before it, not against main:
LL128, fp4 op of 64, 1 / 16 / 64 tokens: dispatch 22.1 -> 13.1, 25.9 -> 15.9, 26.5 -> 20.4;
combine 14.8 -> 8.5, 15.5 -> 9.4, 16.2 -> 11.7
LL128, fp8 op of 16, 1 / 16 tokens: dispatch 21.7 -> 13.2, 25.8 -> 24.0;
combine 16.3 -> 9.1, 17.1 -> 10.5
fp4 dispatch: LDS metadata runs 36.29 -> 33.78 at 512; LDS token counter and the scale sent
with the payload 141.02 -> 132.46 at 4096, 420.78 -> 417.29 at 16384; fp4 tables
-45 (dispatch) / -105 (combine) at 16384
fp8: tables dispatch 828.31 -> 772.96 and combine 871.56 -> 691.93 at 16384, combine
55.75 -> 44.14 at 512; the fp4 send paths for fp8 (scale with payload, token counter, LDS
metadata runs) dispatch 43.64 -> 40.70 at 512, 773.52 -> 751.57 at 16384
EP8 / EP16 rows are in the _LL128_TABLE comment.

Also: EP16 pinned-destination geometry, payload-first stores, scale staging linear in world size
(EP32 compiles past 4096 tokens), and bench_ep CHECK comparing the forwarded ids, weights and
scales and the pull combine's weight fold.

…at its base modulo a power of two >= maxTokPerRank (aggReserve), so EP32 fp4/fp8 dispatch compiles past 4096 tokens (16384: 256 MiB, was 4 GiB)
… the plan's aggReserve. Under aggReserve the scale rows wrap at 2 x pow2ceil(maxTokPerRank) a peer, which at one or two ranks is past the recv cap, so the buffer #764 sized without it was short there (one rank, 64 tokens a rank, a 224 B scale row: 128 rows a peer against 64). Plans that differ in aggReserve no longer share a buffer.
…roadcast with the slot, so the copy no longer reads s_base[d] from LDS per destination
…chedule): 16384 tokens dispatch -45 us, combine -105 us
…okMax): the code that depends on one call's token count (kCuAlways, kPlainMeta, kRowPre, the scale staging wrap) reads the bucket's edge, maxTokPerRank stays the index stride; EP16 fp4 gets a 512-token bucket; kDPin back to EP16 only (EP32 128x16 pinned: +15..+50 us at 9216-14336 tokens, 387 / 509 us at 16384 across two runs)
…-37 us, 64x16 kept to 512 where it is 1.7-4.1 us faster)
…MetaAllW, EP32 below 32 warps): a warp holding two runs loads both, waits once and stores both
…row before the metadata pass and stores it right after the metadata stores, one completion wait instead of two (kPayFirst)
… s_wait_tensorcnt is scalar, and under the exec-masked branch the compiler emitted it ran with EXEC off, so both waits were taken every time
…d row; the reload in the payload pass, behind the metadata stores, returned only once they were acknowledged
… and srcmap with the lanes; the direct stores' fence moves to the final barrier
…(EP8 fp4 64x16 sized to 1024: +0.2..+0.5 us at 1 token, +0.1..+0.3 at 64; no EP4 / EP8 bucket measured faster)
…wards with the senders' too, each against a control that must fail, and a rank that received no row still joins the check's all_reduce instead of leaving the others in it
… warps a block (kPayFirstPlain), the pl tree's dispatch
…t most 512 tokens a rank, chosen per op by hip_tuning_configs._LL128_TABLE through a Cfg field ll128, on MTYPE_RW parts only (EP4 on C17 against pl, dispatch + combine us: fp4 30.2 -> 15.7 at 1 token, 36.2 -> 21.5 at 128, 42.6 -> 35.1 at 512; fp8 30.8 -> 16.4, 41.0 -> 23.5, 53.3 -> 47.0)
…ded weights too, beside a control that must miss every row
…6 ops of at most 256 tokens a rank, with the weights folded as the pull combine folds them
…ch (EpCfg::ll128CombineOnly) for fp4 ops of 513..2048 tokens a rank (EP4 on C17, an op of 2048 tokens a rank against pl, combine us: 12.8 -> 7.7 at 1 token, 31.2 -> 23.4 at 1024, 50.8 -> 40.8 at 2048; the dispatch, the same kernel, 31.1 -> 32.6 at 1024 and 40.1 -> 41.0 at 2048)
…ispatch and combine; the rest of the CUs belong to the co-resident GEMM), fp4 / fp8 ops of at most 128 tokens a rank and bf16 of at most 16, where both kernels are faster than the schedule's on that grid; the LL128 combine alone leaves the table (it loses on 64 blocks: fp4 combine 19.5 -> 23.7 at 512, 31.7 -> 44.0 at 1024)
… 64x16 up to 256 tokens a rank (combine 16.7 -> 15.1 at 256), fp8 on 64x8 + 64x8 up to 128, bf16 on 64x16 + 64x16 up to 64 (dispatch 27.2 -> 14.7, combine 16.4 -> 16.0 at 64)
…_TABLE, 64 blocks: fp4 up to 128 tokens a rank on 64x16 dispatch + 64x8 combine (on 64x16 the combine is capped at 256 VGPRs and spills 230; 64x8 keeps 365, combine 25.4 -> 15.6 at 128), fp8 up to 128 on 64x8 + 64x8, bf16 up to 16 on 64x16 + 64x8 (past 16 its combine loses to the pull: 17.2 -> 23.7 at 64). C14 + C17, against f490e25, 3 alternating rounds, all one direction: fp4 dispatch 18.7 -> 8.6 / 24.5 -> 20.0 and combine 13.3 -> 8.0 / 15.8 -> 15.6 at 1 / 128; fp8 dispatch 18.9 -> 8.9 / 25.5 -> 24.0, combine 14.7 -> 8.9 / 19.2 -> 18.9; bf16 dispatch 20.4 -> 10.0 / 22.7 -> 14.4, combine 24.8 -> 10.2 / 15.4 -> 11.3 at 1 / 16
…ty stage, fp8 combine without spills

Dispatch: the stage serves up to waveSize ranks (was 8). From 8 ranks a row's first unit goes to every rank and the rest only to the ranks it is routed to (a token reaches about 4.4 of 8 and 5 of 16 ranks); a destination decides a row from its first unit. From 16 ranks that always holds; at 8 ranks a call of at most 512 unit stores sends every unit, and the destination applies the same rule to the source's count. Count words and rows alternate between two copies by the call number's low bit: a source with no token on a rank does not wait for it, and on EP16 (C1 C4 C11 C14, 10-17 06:44Z) one late rank missed a count word that the source's next call had overwritten ([LLTMO], 1 cell of about 250).

Combine: the fp8 LL combine from 8 ranks held 6 rows x 16 units in registers (512 VGPRs, 18 spilled, 9 calls); a poll round now holds at most 64 units and the two-wave run that needs 72 is not built (385 VGPRs, no spill; EP4 and every fp4 / bf16 instance unchanged in machine code).

Table: EP8 fp8 dispatch on 64x16; EP16 fp4 / fp8 up to 128 tokens a rank (dispatch 64x16, combine 64x8), bf16 up to 16. EP16 against the schedule, 3 alternating rounds, all one direction, at 1 / 16 / 64 / 128: fp4 dispatch 19.8 -> 9.3, 24.0 -> 12.2, 24.9 -> 15.0, 25.2 -> 21.8, combine 14.3 -> 8.5 ... 17.4 -> 16.8; fp8 dispatch 20.6 -> 9.7 ... 27.9 -> 27.3; bf16 at 1 / 16 dispatch 22.8 -> 10.7, 25.1 -> 12.9, combine 28.2 -> 10.6, 15.7 -> 12.1. EP8 (C1 C4) against 9839ee2 at 16 / 128: fp4 dispatch 11.3 -> 9.5, 20.1 -> 16.1; fp8 11.6 -> 10.7, 24.1 -> 19.3; bf16 at 16 14.4 -> 11.5; at 1 token within 0.1. EP4 machine code is that of the measured two-parity build, within 0.2 of 9839ee2. EP16 and EP4 machine code is identical to the build those numbers come from; EP8 measured on this one, with uneven-count CHECKs.
The bf16 LL128 combine splits a row into parts of 4 units from 8 ranks on 16 warps a block (8 otherwise): parts of 8 on 64x16 needed 256 VGPRs and spilled 94, parts of 4 take 181 with no spill, and the smaller parts spread a token's rows over twice the waves at both ends. EP8 (C1 C4, 3 alternating rounds, all one direction) against 59210c7's 64x8 at 1 / 4 / 16 tokens: combine 10.3 -> 8.6, 10.6 -> 8.9, 11.3 -> 9.6 us, dispatch within 0.1. EP4 keeps parts of 8 (with 4 its 64-token combine was 0.4 slower). Machine code: every instance in the EP4 / EP8 / EP16 caches of 59210c7's runs is unchanged; the new EP8 instance is identical to the one measured.
EP16 on C1 C4 C13 C14, 3 alternating rounds, all one direction, at 1 / 4 / 16 tokens: combine 10.6 -> 8.9, 11.2 -> 9.5, 12.1 -> 10.7 us against 7816598's 64x8, dispatch within 0.1; against the schedule 26.4 -> 8.9, 30.7 -> 9.5, 15.8 -> 10.7. Same run: 7816598 itself passed the uneven-count CHECKs on EP16 (fp4 / fp8 at 7, 64, 128, bf16 at 7, 16), no LL128 time-out in any log.
…p8 up to 16

EP32 on C1 C2 C4 C6 C9 C11 C14 C17 (one boot batch, BPC21 driver D, 28 two-node probes clean), 3 alternating rounds, all one direction, against the schedule: fp4 at 1 / 4 / 16 / 64 tokens dispatch 22.1 -> 13.1, 23.2 -> 13.3, 25.9 -> 15.9, 26.5 -> 20.4 us, combine 14.8 -> 8.5, 15.3 -> 9.2, 15.5 -> 9.4, 16.2 -> 11.7; fp8 at 1 / 4 / 16 dispatch 21.7 -> 13.2, 22.5 -> 13.3, 25.8 -> 24.0, combine 16.3 -> 9.1, 16.8 -> 9.6, 17.1 -> 10.5. CHECK passed at these capacities, uneven counts included, no LL128 time-out. fp4 at 128 and fp8 at 64 the dispatch loses. No bf16 entry: the schedule's bf16 op failed its window import on EP32 (no baseline).
…uns in LDS while a token-free warp reserves the slots (kLdsMeta). EP32 on C1 C2 C4 C6 C9 C11 C14 C17, an op of 512 tokens a rank, 3 alternating rounds against 9839ee2, dispatch us: 26.51 -> 24.23 / 27.02 -> 24.39 / 28.44 -> 26.38 / 36.29 -> 33.78 at 64 / 128 / 256 / 512, combine unchanged; CHECK incl. uneven per-rank counts and the 512 bucket of a 16384 op. Machine code of every other dispatch (EP4 / EP8 / EP16, EP32 128x16 / 256x16, LL128, fp8) unchanged
…send, the LDS token counter and the LDS metadata runs that fp4 takes (kScPayOn / kDynTok / kLdsMeta key on a byte dtype instead of Fp4x2). C2 C5 C6 C7 C9 C11 C14 C17, 12 experts a rank, an op per size group, 3 alternating rounds against d5f505f (e32ab_fp8_dsg.log), dispatch us: 27.12 -> 24.33 at 64, 28.50 -> 25.58 at 128, 34.62 -> 31.91 at 256, 43.64 -> 40.70 at 512 (the LDS metadata runs), 402.92 -> 400.49 at 8192, 773.52 -> 751.57 at 16384 (scale with payload and the token counter), every round one-signed; 224.29 -> 224.59 at 4096 (+0.22 / +0.01 / +0.30); the 1024 and 2048 buckets take neither path. Combine code unchanged, its differences mixed-signed or within 0.3. CHECK fp8 every group (rows, metadata, scales). Machine code changes only in EP32 fp8 instances, 64x16 from 512 tokens a call, 128x16 past 1024, 256x16 past 2048 (24 of 82 cached dispatch instances); every fp4, bf16, EP8 and EP16 instance is unchanged, and the reference arm of the A/B builds what d5f505f builds and its flagged arm what this commit builds, 82 of 82
…dup, LL128 unit order; EP32 tables at EP4 block counts

Dispatch (ep_intranode_1250x.hpp), all at 32 ranks only, so every EP4 / EP8 / EP16 instance builds the same code: where the scale rides with the payload and a warp holds at most two tokens, the indices, weights and srcmap go from the lanes with each row and the metadata pass sends no run (kRide); past two tokens a warp the payload pass takes tokens from one grid counter in _resState (kGDyn); the count and the assignment find a token's distinct ranks with topk - 1 compares instead of a ballot per rank (EpFirstOfDest); the LL128 dispatch numbers its units unit-major past 4 tokens, so the tokens' first units sit on different blocks.

Tables (hip_tuning_configs.py): EP32 dispatch and push combine take EP4's block count at every token count; the push combine runs 8 warps up to 512 tokens (fp4) / 384 (fp8), where the 16-warp overlapped path loses.
…dles copy the recv maps

#733 moved the total_recv reset into the dispatch and lets a routing handle keep a copy of the count and combine more than once (dispatch(..., snapshot=True)). The LL128 combines still cleared totalRecvTokenNum at their end, and the bf16 LL128 combine read each slot's source and expert ids from the arena, which the next dispatch overwrites.

- An LL128 op's count is the low half of a 64-bit word whose high half is the call number the count is for (two ints instead of one, allocated with the op). The dispatch's block 0 starts the word over with one store when the call starts, and each slot is one 64-bit add: an add that returns the last call's number landed before that store, so the wave takes its slot again once the store is in. Nothing else waits. Both LL128 combines only read the count, which stays until the op's next call. Callers and routing handles still see total_recv as one int, and reset() zeroes the whole word.

- EpArgs gains recvToSrc / recvIdx, where the bf16 LL128 combine reads each slot's source and ids: the op's own arena regions, or for a snapshot routing handle (EpDispatchRoutingHandle.recv_maps) copies of them taken right after its dispatch. The LL128 dispatch writes both regions from this rank, so the copies need no barrier. The dispatch itself is unchanged. Snapshot handles are gather only, so the push (fp4 / fp8) LL128 combine keeps reading the arena.

EP4 on C17, hip, bf16 LL128 64x16: test_routing_snapshot.py 9/9 (5/9 before). CHECK fp4 1/7/64/128, fp8 1/16/128, bf16 1/16/64 pass. A count test (two ops of one config alternating their calls, reset() between calls, some or all ranks sending no tokens, each count checked against the routing and each combine against the input) passes 34/34; on the merge it fails at its first combine, which clears the count. With block 0's store held back about 25 us, so that the adds for every row past the first token's land before it (dispatch 35 us), the count test and every CHECK above still pass.

Three alternating rounds against the merge (ab_1020_095313_1520748 and ab_1020_095615_1527455 fp4, ab_1020_095513_1525146 fp8, ab_1020_095413_1522928 bf16): fp4 dispatch +0.1-0.8 us at 64 / 128 tokens in one run, mixed-signed in the other and at 1 / 7; fp8 dispatch 0.3-1.5 faster at 1 token, mixed at 16, +0.1-0.3 at 128; bf16 dispatch mixed-signed at every size. Against writing the snapshot copies from inside the dispatch behind a null check, in the same rounds: never slower in all three rounds, fp8 dispatch 0.6-0.9 faster at 1 token and combine 0.15-0.3 faster at 16. Zeroing the count when the call starts and having each wave wait for a mark cost +0.2-0.7 us of dispatch at fp8 128 / bf16 64, and two alternating slot counters with every slot also added to the count +0.3-1.7.
…y op

An intranode op whose capacity is past the LL128 table's max_tok now builds the LL128 dispatch and combine for max_tok tokens a rank next to the schedule's plans, bound to recv regions of their own (ll_*), and picks per call: a call of at most max_tok tokens takes LL128 and its combine follows from the handle's token count. Every rank of a call must be on the same side of max_tok. No kernel change.

Only the op picks: EpDispatchPlan, lookup() and the kernels are unchanged, so a caller that builds its own plans (aiter's mega_moe) runs as before and needs no change. A snapshot dispatch on a push-quant op keeps the schedule's plans, since that LL128 combine reads the slot map from the arena. Memory: the LL128 staging in tok_off plus the ll_* regions, 118 MiB a rank at EP8 bf16 cap 512 by the region sizes. test_ll128_split.py alternates the two paths synced, back to back, under graph replay and with snapshot handles.
The dispatch slot allocator word always lives in the cco window now. Removed: the TokOffExt IPC allocation and its env var, EpRequest.tokOffExt (aggReserve is on for every gfx125x dispatch), the tokOffPeers branch in EpTokOff, the op plumbing, the README paragraph and its test.

Kept for the aiter mega_moe, which imports TokOffExt and passes tok_off_peers on every dispatch launch: TokOffExt is a no-op class whose peers is None, and EpArgs.tokOffPeers stays in the schema, read by no kernel, so the EpArgs layout is unchanged. aiter needs no change; its dispatch now uses the window word, as with MORI_EP_TOKOFF_EXT=0.
…on per call

Every gfx125x dispatch is built with aggReserve: the blocks of a rank add up their tokens for each destination, and the last block to arrive reserves the total with one RMW on the slot word. The branches for aggReserve off (an RMW per block, the 32-bit count signal and its wait) were reachable only through tokoff-ext, removed in the previous commit. The dispatch body now static_asserts aggReserve.

No gfx125x dispatch Cfg had aggReserve off after the previous commit, so only if-constexpr branches that were never instantiated are gone; the machine code is expected to be unchanged, to be confirmed by comparing the ISA with the previous commit.
…after every call

dispatch(snapshot=True) is intranode gather only and every push-quant op scatters, so the fp8 and fp4 runs raised in the snapshot section before any kernel ran. Skip that section there.

Between two schedule-path calls a fast rank's next dispatch writes into a slow rank's receive rows, and its next combine restages rows the slow rank still reads, so without a barrier the bf16 snapshot_combine check failed. Barrier after every snapshot dispatch and combine as test_routing_snapshot.py does, and report each pairing of the two paths on its own.

C12 EP4 on 0a73255's package: 0 failures over bf16, fp8 and fp4.
Conflicts with #768 (AsyncLL on cco), both sides kept: hip_backend._build makes the device communicator for an AsyncLL op too and drops the tok_off slot-word decision, since TokOffExt is a stub on this branch; dispatch keeps the snapshot recv maps next to AsyncLL's pending send-half state; combine passes the snapshot maps to whichever kernel table runs.

ll128_layout returns None for an AsyncLL op: its kernel set holds only AsyncLL's plans, and a gfx1250 bf16 or fp8 AsyncLL op past the table's max_tok would otherwise pick the LL128 spec and find no kernel.
… adds to it

6622403 made the LL128 dispatch reset the count at its start and check a call
number on every slot it took, so dispatches could follow each other with no
combine in between. On EP4 fp4 that cost 1.0 us at 128 tokens and 1.4-1.7 at 256.
This goes back to the protocol before it: the dispatch takes each slot with a
plain 32-bit add and the last block of either LL128 combine clears the count.

Around it:
- A split op gives its LL128 plans their own count. The schedule's dispatch
  stores its total and nothing clears it, so on a shared int an LL128 call after
  a regular one would count on from that total. total_recv is the one the last
  dispatch used.
- A snapshot dispatch copies the count and then zeroes the op's, and the LL128
  combine of a snapshot handle clears a copy of the handle's count, so the
  handle combines again.
- A dispatch without snapshot= has to be followed by its combine before the
  next dispatch, as before 6622403.

EP4 fp4 on C12, 3 alternating rounds, graph replay, against 710fd70, header
blob 537ca01:
- LL128 op of 256 tokens a rank: dispatch -1.0 us at 128 tokens and -1.4..-1.5
  at 256; combine +0.16..+0.21 at 256.
- Split op of 1024 tokens a rank: at 256 dispatch -1.3..-1.7 and combine
  +0.16..+0.20; at 512 and 1024 (regular plans) dispatch and combine within
  0.42 either way.

Tests on C12, EP4: test_routing_snapshot at M=64 and M=128, 9/9 each;
test_ll128_split at M=512 for bf16, fp8 and fp4, no failures.
…EP4 / EP8 / EP16

An op with quant none, an fp8 dispatch and a bf16 combine (collectivex fp8 decode) had no LL128 entry, so every call ran the schedule's kernels. Its new row in the none table takes the dispatch geometry of the fp8_blockwise LL128 dispatch and the combine geometry of the bf16 LL128 combine, at the smaller max_tok of the two. MakeEpCfg accepts an fp8 dispatch for the bf16 LL128 kernels; ll128_layout keeps an op with quant none and a combine other than bf16 off LL128. test_ll128_split adds a none_fp8 case with 56 four-byte scales a token.
Size the LL128 arena regions through #844's plan info: EpRegionOutTokBytes counts the LL128 landing rows, the LL128 dispatch reports its stage in region.tokOff, and a split op's ll_* regions come from its LL128 plans' describe(). Every dispatch variant (callTokMax) is described, so stagingBytes covers them all, and the fallback staging key carries callTokMax. Drop the tok_off_ext request and the TokOffExt gate main added; this branch removed both.
…old for a warp's single long item

When a warp holds one item longer than two half-size tiles (EP8 bf16 T=256 and 512 at 64 blocks x 8 warps), the next chunk's TDM loads go into a second set of tiles while the current set is folded. Shorter items and warps that walk several items keep the single set of full-size chunks; the fold is shared by both loops.

UT bench, C1+C5 EP8 topk 6, graph, combine p50, 3 alternating rounds against b6e9968 (measured as 773dcbd6e with -DMORI_CPIPE=1): bf16 T=256 -1.50..-1.75 us, T=512 -1.80..-2.07 us; fp8 dispatch with bf16 combine T=256 -1.45..-1.80, T=512 -1.69..-2.04; T=32..128 and 1024..2048 within +-0.4 either sign. CHECK passed at T=32..2048 for both.
… pull combine's barrier without a grid rendezvous (worlds of up to 8)

Block 0 polled the peers' flags with a 15-unit sleep, then wrote a release line for each other block, which those blocks polled with the same sleep. Without the grid rendezvous (an inplace combine input) each block of a world of up to 8 ranks now polls the npes flags itself; wider worlds keep the forwarding.

UT bench, C1+C5 EP8 topk 6, graph, combine p50, 3 alternating rounds against 8fa2532 (measured as fb298ed38 with -DMORI_CBARFAST=1, ab_1030_043004_1644390): bf16 T=32 -2.00..-2.26 us, 64 -2.12..-2.22, 128 -2.16..-2.40, 256 -2.54..-2.71, 512 -2.29..-2.59, 1024 -2.48..-3.02, 2048 -2.85..-3.03; T=1 and 16 (LL128 combine) within +-0.25. CHECK passed at T=1..8192 for bf16, and for fp8 dispatch with bf16 combine.
… up to 64 tokens a rank

The EP8 none rows capped LL128 at 16 tokens a rank, so calls of 32 and 64 tokens went through the regular dispatch and pull combine and paid their fixed cost. The cap is now 64 for both dtypes; from 128 tokens a rank the regular path is faster.

UT bench, C1+C5 EP8 topk 6, graph, dispatch+combine p50, 3 alternating rounds on 10-29 against b6e9968, with an LL128 arm capped at 128 (b99ac3105 for fp8, 46ce317b9 for bf16): fp8 dispatch with a staged bf16 combine input T=32 42.74 -> 26.54 us, 64 44.57 -> 35.80, 128 50.15 -> 51.32 (ab_1029_133142_1936386); bf16 staged 42.50 -> 29.31, 45.24 -> 39.15, 52.22 -> 59.27 (ab_1029_133629_1949970); bf16 inplace 38.85 -> 29.86, 41.41 -> 39.79, 47.48 -> 60.61 (ab_1029_133734_1953165). At T=16, where both arms take LL128, the 128 cap cost the bf16 inplace combine 0.13-0.18 us. Since then 36bd1a8 took 2.12-2.22 us off the regular combine at bf16 T=64, so bf16 inplace T=64 is inferred 0.3-0.6 us slower on LL128 with this commit (not measured). Not yet CHECKed on this commit.
…om a count table instead of a remote RMW

The last block of a rank to reserve made one fabric RMW per destination on the slot word of that destination and published the base, and every other block holding tokens waited for it. With 8 ranks or fewer the last block instead stores the total of the rank for each destination into its row of a count table in every higher-numbered rank, and each block sums the totals the lower-numbered ranks stored into its own table, so the rows on a destination run in source rank order. The table sits from byte 256 of tok_off, which the gfx125x dispatch plan now reports as 256 + 4 * ws * ws bytes; wider worlds keep the RMW.

UT bench, C8+C16 EP8 topk 6 bf16, graph, dispatch + combine as the rank 0 median of 20 pairs in one graph, 3 alternating rounds against 132e568 in each of two runs (measured as b9a50866c: ab_1030_100110_2435750 with ab_1030_100219_2438203, and ab_1030_103227_2496322): T=128 +0.07..-1.66 us, 256 -2.53..-2.92, 512 -1.48..-1.97, 1024 -0.32..-1.19, 2048 -0.99..-1.54, 4096 -1.76..-1.96, 8192 -0.11..-2.04; T=1..64 (LL128) within +-0.32.

b9a50866c is this kernel without the region change. Against it the combine and LL128 dispatch code objects disassemble the same; the normal dispatch differs only in the printf hostcall path, and 3 alternating rounds put this commit within -0.94..+1.08 us of it at T=128..8192 (ab_1030_110153_2560922, ab_1030_110250_2563289). CHECK passes for bf16 and fp8 dispatch at T=1..8192 (ab_1030_105933_2556212, ab_1030_110015_2557575) and at hidden 4096, which has no LL128 plan, at T=1..1024 (ab_1030_110112_2559232).
…pelined pass takes the fewest chunks that fit
…s a rank

The none row moves EP8 dispatch to 128x16 past 2048 tokens a rank. bf16 now takes 64x16 at every token count, leaving the rest of the CUs to the co-resident GEMM; fp8 keeps the none row and fp4 its own.

UT bench, C8+C16 EP8 topk 6, bf16, graph, dispatch+combine pair period (rank 0 median of 20 pairs), 3 alternating rounds on 10-30 against abfb783: T=2048 233.98 -> 233.69 us, 4096 424.15 -> 431.01, 8192 812.26 -> 826.65 (ab_1030_141817_3043682). Dispatch pinned to 64x16 on abfb783 gave 234.61 / 430.75 / 827.37 (ab_1030_131558_2855691). CHECK passes at T=32, 128, 2048, 4096 and 8192 (ab_1030_141740_3041806).
…it stores any, and the LL128 dispatch loads a row's units past the first 16 before it takes the slot
…() that aiter's mega_moe still passes

aiter's MegaMoE calls TokOffExt.wanted(world) when it builds the dispatch stage and puts tok_off_ext in every dispatch request. Both went away with the tok_off count table, so aiter's default construction raised AttributeError, then TypeError from the request binding. Neither does anything now: wanted() returns False, and EpRequest takes tokOffExt but MakeEpCfg does not read it, so EpCfg and the kernels are unchanged.
@zhangfei829
zhangfei829 merged commit bd92eb9 into main Oct 31, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant