Repository navigation
Conversation
…counts are signaled - every block waits for its own stores (s_waitcnt) before it arrives at the dispatch grid barrier; the signal fence only covered warp 0, and __syncthreads does not wait for vector-memory stores - the drain assumes the uncached cco window (the default); MI300X/MI355X EP8 dispatch latency unchanged (within 0.6 us at 32-4096 tokens a rank) - test_op FRESH=1 copies the received rows and the reverse map in-stream right behind dispatch and compares them with the post-barrier views; the intranode suite runs it on both backends Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…/gfx950 - dispatch drops a slot past the recv cap: null in the dest map, no payload, not counted, so total_recv = min(demand, cap) with dense rows; behind if constexpr, uncapped kernels are unchanged - the C++ validator accepts a capped maxRecv; MakeEpCfg and the backend gate refuse it on gfx125x only; the HIP intranode op advertises recv_cap - test_op checks delivery against the routing (OP-RECV) and, under a cap, the drop invariants (recv count, kept slots vs reverse maps, combine, weight fold and LEC over kept PEs) on both backends Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- dispatch(routing=handle) sends to the slots the handle's dest map names, claims none, and recounts total_recv, as FlyDSL does - replay is a Cfg bit with its own dispatch_replay binary sharing EpPublishSlot with the routing pass; refused on gfx125x; plans built with the op so a first replay under capture compiles nothing - OP-REPLAY zeroes the received rows, weights, ids and scales first, so a replay that writes nothing fails; HIP replay cases with scales, topk 9 + ragged + no-self, and a cap Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… codec template - combine_mode="scatter" without a quant type copies bf16/fp32 rows into the landing row and sums them locally in f32, as FlyDSL serves it - EpCombineScatterBody<kCfg, T> takes its wire from EpScatterCodec<kCfg, T> (quantized and unquantized specializations); quantized latency unchanged (MI300X fp8 1x128 T4096 691.0 us) - a scatter combine, quantized or not, takes the scatter tuning rows: bf16 scatter T4096 MI300X 1510 -> 1092 us, MI355X 970 -> 774 us; bench_ep COMB_MODE=scatter Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gfx950) - a local-kernel family (EpLocalCfg / EpLocalArgs, no arena regions) with the ep_local_expert_count plan: one thread per (row, k) into a per-block LDS histogram - the base op owns local_expert_count(); backends hand back a callable in KernelSet and the capability follows it; FlyDSL moves onto the same seam with its kernel unchanged - EP8 H7168 kernel time: 2.0 us at 128 tokens a rank and 2.7 us at 4096 (FlyDSL 3.2-3.5 / 54-65 us); OP-LEC checks an exact per-expert reference read straight after dispatch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- ep_convert_dispatch packs each local (row, k) into its expert's bucket; ep_convert_combine folds the bucket rows back with the forwarded weights (WarpAccum over LDS source pointers); bf16, gather combine - the base op owns convert_dispatch_output / convert_combine_input and the packed buffers; gfx125x, non-bf16 and scatter stay refused - EP8 H7168 at 4096 tokens a rank: convert_dispatch 229-267 us (FlyDSL 3495-4473), convert_combine 312-315 us (FlyDSL 731-1052) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
GPU CI for
Test groups (the steps that run in those jobs): epv2. Lanes follow the changed files. Adding |
- Routing replay refuses a token count other than its handle's; StdMoE dispatch without weights is refused on both backends - Past the local kernels' limits, local_expert_count is not served and StdMoE is refused at construction - The intranode suite requires every check a case turns on, and adds StdMoE under a recv cap, scatter replay and a cached-window FRESH run - The dispatch drain stays a drain: rows are complete on a cached cco window too, and a per-block release costs 6-40% of dispatch - Docs: gfx125x replay, the HIP feature list, test_op knobs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Black 25.1.0 reformats three test files; no change in behaviour Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kawhil-amd
left a comment
There was a problem hiding this comment.
Thanks for the PR. I read the diff and spot-checked a few points against the code. Five comments below: two questions about behavior changes (the waitcnt cost, StdMoE on FlyDSL), one gap in the replay token-count check, and two on JIT build time and duplicated limits. I did not run it on gfx942 / gfx950.
| // Drain this block's peer stores before it arrives, as FlyDSL does: the signal fence | ||
| // below covers warp 0's stores only. No release: a cached window passes FRESH without | ||
| // one, and a per-block release costs 6-40% of dispatch. | ||
| __builtin_amdgcn_s_waitcnt(0); |
There was a problem hiding this comment.
The PR text gives the reason for dropping the release (6-40% of dispatch) and says FlyDSL drains the same way, so this matches FlyDSL. What it does not give is the cost of the drain itself. This is in the dispatch body, so every dispatch built from it on gfx942/gfx950 pays it, not only the new replay and capped paths. Could you add a before/after dispatch latency for one small and one large token count?
There was a problem hiding this comment.
The PR text gives the reason for dropping the release (6-40% of dispatch) and says FlyDSL drains the same way, so this matches FlyDSL. What it does not give is the cost of the drain itself. This is in the dispatch body, so every dispatch built from it on gfx942/gfx950 pays it, not only the new replay and capped paths. Could you add a before/after dispatch latency for one small and one large token count?
The before/after numbers are in the PR description under Dispatch drains every block's peer stores → Cost: EP8, hidden 7168, top-k 8, bf16, HIP, graph mode, every count from 32 to 4096 tokens a rank.
| 32 tokens/rank | 4096 tokens/rank | |
|---|---|---|
| MI300X, before → this PR | 24.1 → 24.0 µs | 1063.7 → 1063.6 µs |
| MI355X, before → this PR | 23.8 → 23.8 µs | 917.2 → 916.6 µs |
At the counts in between, the two are within 1.3 µs (1.2%) of each other. So the drain costs nothing measurable. What costs 6–40% is a per-block release (__threadfence_system), which is measured in the same section and not used.
| "dispatch with the next combine (its recv counts and slot map are " | ||
| "per round), so a routing handle is only ever used by that combine" | ||
| ) | ||
| if self.cfg.enable_std_moe and weights is None: |
There was a problem hiding this comment.
_dispatch_impl is shared, and this condition does not look at the backend. A FlyDSL StdMoE caller that dispatches without weights worked before and now gets this ValueError. Does FlyDSL need the weights here? If not, the check could move to where the HIP convert_combine_input reads the forwarded weights, or be limited to the HIP backend.
There was a problem hiding this comment.
_dispatch_implis shared, and this condition does not look at the backend. A FlyDSL StdMoE caller that dispatches without weights worked before and now gets thisValueError. Does FlyDSL need the weights here? If not, the check could move to where the HIPconvert_combine_inputreads the forwarded weights, or be limited to the HIP backend.
FlyDSL needs them too, as does any MoE caller. With per-PE dedup, a rank's expert outputs are summed before combine, so the top-k weights are applied on the expert side: aiter's fused_moe takes the dispatched weights as its topk_weight, and StdMoE's convert folds them itself. On HIP (and in v1), weights=None is accepted and forwards nothing. FlyDSL never supported it: on main, a FlyDSL dispatch with weights=None already faulted on the GPU, with or without StdMoE, because ep_dispatch reads the weights through a null pointer. So no FlyDSL call that worked before gets this error now. For StdMoE, the check turns that fault into a ValueError on both backends.
| # Replay reads n * topk entries of the handle's dest map, and only the handle's | ||
| # own tokens were written. 0 = not recorded (from_tensors without a count). | ||
| ct = 0 if routing is None else routing.cur_rank_num_token | ||
| if ct and n != ct: |
There was a problem hiding this comment.
When the handle has no recorded count (from_tensors without cur_rank_num_token) ct is 0, so this check is skipped and replay reads n * topk entries of a dest map the handle never wrote. The comment says so, but it leaves a gap: a from_tensors handle replayed with a larger n gets stale slot ids with no error. Could from_tensors require the count when it builds a handle for replay, or could replay refuse a handle with no count?
There was a problem hiding this comment.
When the handle has no recorded count (
from_tensorswithoutcur_rank_num_token)ctis 0, so this check is skipped and replay readsn * topkentries of a dest map the handle never wrote. The comment says so, but it leaves a gap: afrom_tensorshandle replayed with a largerngets stale slot ids with no error. Couldfrom_tensorsrequire the count when it builds a handle for replay, or could replay refuse a handle with no count?
Fixed in 75530f5: replay now refuses a handle with no count. from_tensors() keeps cur_rank_num_token optional, because combine does not need it, but the default is now None ("not recorded") rather than 0. dispatch(routing=h) raises a ValueError for such a handle, and the message says to rebuild it with cur_rank_num_token=n. A handle that records 0 is now held to 0 tokens like any other count. test_routing_snapshot.py checks on both backends that a rebuilt handle without the count is refused, and replays a handle rebuilt with it.
| self._plans.append(plan) | ||
| sized.append((cap, plan, self._card is not None and not blocks)) | ||
| # Built eagerly, so a first replay inside a graph capture compiles nothing. | ||
| if not self._is1250: |
There was a problem hiding this comment.
This builds a replay plan for every dispatch spec and cap on every gfx942/gfx950 op, including ops that never replay, so op construction compiles about twice the dispatch kernels on a cold JIT cache. The comment gives graph capture as the reason. Could the plans be built on the first replay, or warmed by an explicit call before capture? If the startup cost is small, a number in the PR would settle it.
There was a problem hiding this comment.
This builds a replay plan for every dispatch spec and cap on every gfx942/gfx950 op, including ops that never replay, so op construction compiles about twice the dispatch kernels on a cold JIT cache. The comment gives graph capture as the reason. Could the plans be built on the first replay, or warmed by an explicit call before capture? If the startup cost is small, a number in the PR would settle it.
Measured. Op construction time, EP8, hidden 7168, top-k 8, 32 experts a rank, 4096 tokens a rank max, HIP, two runs each, every rank sharing one JIT cache:
| dispatch plans | cold cache | warm cache | |
|---|---|---|---|
| MI300X, replay plans built (this PR) | 8 | 12.8 s | 0.24 s |
| MI300X, replay plans not built | 4 | 8.1–8.6 s | 0.24 s |
| MI355X, replay plans built (this PR) | 4 | 5.1–5.2 s | 0.12–0.13 s |
| MI355X, replay plans not built | 2 | 3.9 s | 0.13 s |
So it is about 4.5 s on MI300X and 1.2 s on MI355X, once per shape per machine. The disk cache keeps the result, and a warm start is unchanged. I'd keep the eager build: it is there so that a first replay made inside a graph capture compiles nothing. A warm-up call would give the same only to callers who know to make it. I added the numbers to the PR description.
| ) | ||
|
|
||
| @staticmethod | ||
| def _local_shape_ok(cfg, rows=False): |
There was a problem hiding this comment.
Non-blocking. The limits here (topk <= 64, 8192 experts, hidden % 8 for bf16) repeat EpLocalCfgIsValid in C++, so the two have to be edited together. A config that this gate accepts and the plan constructor rejects shows up as a RuntimeError at build time, and the reverse silently drops the capability. If the plan can report its own validity, the gate could ask it.
There was a problem hiding this comment.
Non-blocking. The limits here (topk <= 64, 8192 experts, hidden % 8 for bf16) repeat
EpLocalCfgIsValidin C++, so the two have to be edited together. A config that this gate accepts and the plan constructor rejects shows up as aRuntimeErrorat build time, and the reverse silently drops the capability. If the plan can report its own validity, the gate could ask it.
Done in 75530f5. The gate now asks the plans: _local_refusal() calls describe() on each local plan with the op's shape. That runs MakeEpLocalCfg / EpLocalCfgIsValid and compiles nothing. The refusal carries the C++ message, for example enable_std_moe: mori v2 ep local: inconsistent config (...), and the Python copy of the limits is gone. test_jit_binding.py checks that the gate accepts a valid shape and gives the plans' reason for a top-k past the wave, more than 8192 experts, and a hidden that is not whole 16 B rows.
…tranode-parity # Conflicts: # tests/python/ops/dispatch_combine_v2/test_op.py
…e local limits from the plans - Replay with a handle rebuilt by from_tensors() without cur_rank_num_token now raises, instead of walking 0 rows. - The HIP gate asks the local plans (describe()) why a shape is refused, so the limits live in C++ only. - The intranode suite resolves the default backend per arch (hip on gfx125x) when it decides which checks a case must print. - test_routing_snapshot covers the refusal and replays a rebuilt handle; test_jit_binding covers the gate's reasons. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@kawhil-amd Thanks for the review. Summary of the five points, with details in each thread:
Retested on 8x MI300X and 8x MI355X: the intranode suite, the CPU and binding tests, CI's EPv2 steps, and |
Summary
Follows #1012. This brings the HIP intranode backend on gfx942/gfx950 to the FlyDSL feature set. It has six feature commits, each covered by a section below; the review fixes that followed are folded into those sections. gfx125x keeps refusing these features.
Dispatch drains every block's peer stores
Fixes how the portable HIP dispatch (gfx942/gfx950) publishes its peer writes before it signals each destination's token count.
Until now, the dispatch body's grid arrival was
__syncthreads()followed by thread 0'satomicAdd. Warp 0 then waits for every block, fences at system scope, and stores the per-destination counts.That system fence orders only warp 0's own stores. The other warps' peer stores could still be in flight when a destination observed its count. Those stores carry the payload rows, weights, expert ids, scale rows and reverse map. In the same situation:
waitcntbefore it arrives.Changes
s_waitcnt 0) before it arrives at the dispatch grid barrier.CCO_UNCACHED_WINDOW=0, or ROCm 7.2.x, whose VMM path ignores the uncached type) a per-block release would be the memory model's choice. The rows are complete there without one (Testing below), and a release costs 6-40% of dispatch (Cost below), so the kernel only drains.test_op.pygainsFRESH=1. Copies of the received rows, weights, expert ids, scales and reverse map are queued on the stream right behind the dispatch kernel, before any host sync or barrier. They must equal what the same views hold after the barrier. The intranode suite runs it on both backends.Cost
Dispatch latency in µs, EP8, hidden 7168, topk 8, bf16, HIP, graph mode, minimum over rounds. The
__threadfence_systemcolumn is the stronger fence, measured for comparison and not used.8x MI300X
__threadfence_systeminstead8x MI355X (a shared node, so minimum over four rounds)
A per-block
__threadfence_systemon a cached window, measured and not used. Dispatch latency in µs withCCO_UNCACHED_WINDOW=0, same setup, median over three rounds; main has no drain:On ROCm 7.2.4, where the window is cached by default, the release costs the same: 19.1 to 26.7 µs at 32 tokens a rank, 879.5 to 933.3 µs at 4096.
Testing
FRESH=1passes on both backends, on 8x MI355X with ROCm 7.14.1 and 7.2.4, on an uncached and a cached window, up to 4096 tokens a rank.FRESH=1on a cached window for both backends (test_dispatch_cached_window).Token dropping under
max_total_recv_tokensWith this PR, the HIP intranode backend on gfx942/gfx950 accepts a
max_total_recv_tokensbelow the worst case and drops the slots past it, as FlyDSL does. Until now it refused the config.Semantics, the same as FlyDSL
effective_max_recvslots are claimed first come, first served.world_size * effective_max_recv, the existing null);total_recv = min(demand, cap), and rows[0, total_recv)are dense.total_recv == effective_max_recvmeans the pool filled.Changes
ep_intranode_kernel.hpp.EpMaxRecv.if constexpr (EpRecvCapped(kCfg)), so uncapped configs compile the same code as before.EpMaxRecv, because every published slot is now below it.ep_cfg.hpp.EpRecvCapped()is new.EpCfgIsValidno longer rejects a cappedmaxRecv.MakeEpCfg. A capped config on gfx125x is refused, because the gfx125x body does not guard its slot encodes.hip_backend.py.recv_cap.max_recvdocstring no longer callsworld_size * Mthe sentinel.Tests
test_op.py.OP-CAPused to check onlytotal_recv <= cap. It now checks the drop invariants, on both backends:total_recv == min(demand, cap), with the demand counted from every rank's expert ids;total_recv, whose reverse-map entry names this token;total_recv.local_expert_countexpectation count the PEs each token kept, from the dest map. Capped runs used to skip the combine check.OP-RECVline requirestotal_recvto equal the demand counted from every rank's routing. A dispatch that wrongly drops a slot therefore fails, rather than lowering its own expectation.test_dispatch_combine_v2_intranode.pyaddsbf16-gather-capandhip-bf16-gather-cap(cap 1024: drops at 512 tokens a rank, none at 128), andhip-bf16-scatter-fp8-1x128-cap.test_jit_core.cppnow expects a cappedmaxRecvto be valid.test_jit_binding.pychecks that a capped plan's regions shrink, or that the cap is refused on gfx125x.Routing replay
The HIP intranode backend on gfx942/gfx950 now serves routing replay,
dispatch(..., routing=handle), and advertises thereplaycapability. Until now the base op raisedNotImplementedErrorfor HIP.The semantics are FlyDSL's:
total_recvthrough the same handshake, so the op's count equals the handle's.combine(routing=handle), with or without the weight fold, reads this round's data.Changes
ep_intranode_kernel.hpp.EpPublishSlot. The routing pass and the new replay pass both call it.EpCfg.replayandEpRequest.replayare new...._dispatch_replay.MakeEpCfgrefuses replay on combine and on gfx125x, whose dispatch body has no replay.hip_backend.py.One replay plan is built per dispatch plan when the op is constructed.
So the first replay inside a graph capture compiles nothing.
It costs one more JIT compile per dispatch geometry, which the disk cache keeps. Op construction, EP8, hidden 7168, top-k 8, 32 experts a rank, 4096 tokens a rank max:
dispatch(routing=handle)refuses a token count other than the handle's, before the launch: the kernel reads only that many dest-map entries, and only those were written.from_tensors()records no count unless givencur_rank_num_token, and replay refuses such a handle.ep_backends.rstlist the cap and replay for HIP on gfx942/gfx950.Tests
test_routing_snapshot.py. It already runs both backends and gates its replay checks on the capability, so it now covers HIP replay: replayed count, replayed combine and replayed weighted combine with an older snapshot handle. It also checks that a replay with another token count is refused, that a handle rebuilt byfrom_tensors()without its count is refused, and replays one rebuilt with it.test_op.py.REPLAY=1now zeroes the received rows, weights, expert ids and scales before the replay. It then requires all of them, and the recountedtotal_recv, to equal what the routing pass delivered, so a replay that writes nothing fails. It also runs under a recv cap.test_dispatch_combine_v2_intranode.pyadds HIP replay cases:SCALE_DIM=32;TOPK=9 RAGGED=1 NOSELF=1;MAXRECV=1024;test_jit_binding.py. It checks that a replay plan uses the same arena regions as the routing plan, and that replay is refused for combine and on gfx125x.Unquantized scatter combine, and one scatter body over a codec template
The HIP intranode backend on gfx942/gfx950 now runs
combine_mode="scatter"without a quant type. That is the unquantized bf16/fp32 scatter combine FlyDSL already has. Until now HIP refused it.It reuses the quantized scatter's landing area and barrier, and its kernel.
EpCombineScatterBody<kCfg, T>is now one template over a codec,EpScatterCodec<kCfg, T>, with two specializations:The codec supplies
Put,GetandAdd, so the stage-1 batch loop, the barrier, and the stage-3 row loads and sums are written once. #1012's quantized scatter keeps its precision. Its latency holds on MI300X (fp8 1x128 is 691.0 µs at 4096 tokens a rank before and after), while on MI355X fp8 1x128 is 1-3% slower from 128 to 1024 tokens a rank (see Testing).The plain scatter's flow:
(computing rank, source token)on the token's own rank. The token's weights go in the same row.Both stages issue all of a warp's loads before using any of them.
Changes
EpCfg.combineScatterPlainandEpRequest.combineScatterPlainare new...._combine_scatter.MakeEpCfgrefuses the plain scatter on gfx125x, beside a quant group, and beside the push, LL128 or card combine.hip_backend.py.combine_mode="scatter"with no quant type.bench_ep.py.COMB_MODE=scattertimes it.hip_tuning_configs.lookup(scatter=True). A scatter combine, quantized or not, takes the scatter rows (_SCATTER_COMBINE_TABLE). A gather keeps the IntraNodeV2 combine rows. The config passesscatter=is_scatter.Performance
Combine latency in µs, EP8, hidden 7168, topk 8, bf16, HIP, graph mode, minimum over rounds:
The unquantized scatter is slower than the gather on one node. It moves the same bf16 bytes and then adds a local reduction pass, so it is there for config parity with FlyDSL, not speed. The scatter column uses the scatter rows. On the gather's rows it was 1510 µs (MI300X) and 970 µs (MI355X) at 4096 tokens.
Tests
test_dispatch_combine_v2_intranode.pyadds:hip-bf16-scatter;hip-f32-scatter;hip-bf16-scatter-scales-ragged(scales, ragged ranks, topk 9);hip-bf16-scatter-h2304(a partial last step);hip-bf16-scatter-cap(a recv cap).test_jit_binding.py. It checks the landing row size for bf16 and fp32, and the refusals.test_op.py. The identity-expert combine is checked against U[t] · input[t] at 2% tolerance. Further runs cover hidden 2304 (a partial last step), topk 9 with ragged ranks and no self-routing, and a recv cap with per-token scales.local_expert_countWhat this does
op.local_expert_count()now runs on the HIP backend's intranode path on gfx942 (MI300X) and gfx950 (MI355X). It returns the same thing FlyDSL returns: one persistentint32 [num_experts_per_rank]buffer holding, for each of this rank's experts, how many(row, k)of the last dispatch'srecv_indices()[:total_recv]name it. Other ranks' ids, negative ids and out-of-range ids are skipped, and a repeated id counts twice. The call zeroes the buffer and launches one kernel on the current stream, with no host sync and no allocation, so it can be captured in a graph (SGLang's expert-distribution recorder calls it right after dispatch, under capture).gfx125x, internode and AsyncLL ops still raise
NotImplementedError, and do not advertise the capability.Design
A local-kernel family. Kernels that only read and write this rank's own rows do not need
EpCfg,EpArgsor the arena, so they get their own:include/mori/ops/dispatch_combine_v2/ep_local_cfg.hpp:EpLocalCfg(shape, geometry, wave),EpLocalRequest, andEpLocalArgswith its published schema and the same offset/field-count assertsEpArgshas. No Args field is namedwindoworoff<Region>, so plan_api binds no arena region.src/ops/dispatch_combine_v2/ep_local_kernels.hpp: the device bodies.ep_spec.cpp:MakeEpLocalCfg,EpLocalExpertCountSpec, and theep_local_expert_countplan, registered next toep_dispatch/ep_combine. It does not go throughMakeEpCfg.ep_plans.local_plan(name)makes the Plan class on first use, so alibmori_ops_v2.sowithout it still serves dispatch and combine.local_expert_count, and refusesenable_std_moeat construction. The gate asks the plans:describe()runsEpLocalCfgIsValidwithout compiling, and a refusal carries its message, so the limits live in C++ only.The kernel. One thread per
(row, k), grid-stride overrows * topk, an unsigned compare ofout_idx[i] - rank * epragainstepr, and anatomicAddinto a per-block LDS histogram; each block then adds its non-zero bins to the output once. Every id of a rank lands on itseprcounters, so per-id global atomics serialize (54-65 µs at 4096 tokens a rank); the histogram cuts that to one add per expert and block.rowsistotal_recvclamped to the recv capacity, so a bad count cannot read pastout_idx. The geometry is the op's dispatch(block_num, warp_num_per_block), the same source FlyDSL uses. The plan is built with the op, so nothing compiles at call time.The base op owns the method.
KernelSetgets alocal_expert_countcallable, next todispatch_replay.EpDispatchCombineOp.local_expert_count()owns the buffer, the zero and the return; a backend only hands backcallable(total_recv=, out=). The"local_expert_count"capability is derived from whether the callable is there. FlyDSL moves onto the same seam: its kernel is unchanged, and it now returns the callable instead of defining the method.Tests
test_op.py: OP-LEC now compares every rank's counts per expert against a reference built from all ranks' routing (under a recv cap, from the rows this rank received), plus the global sum over the slots the dest map kept (world * ct * Kwithout a cap). The first read is launched right after dispatch, with no sync and no barrier, the way SGLang calls it.REROUTE=Nadds N rounds of new routing per sweep point, each read straight after dispatch.test_dispatch_combine_v2_intranode.py: HIP caseship-bf16-gather,hip-bf16-gather-scales-ragged(scales, RAGGED, NOSELF),hip-bf16-gather-topk9,hip-bf16-gather-reroute(REROUTE=8). OP-LEC runs in every case of both backends, and the suite requires each case's OP lines (LEC, REPLAY, REROUTE, STDMOE-PACK, CAP, FRESH, SCALES) to appear, so a check gated on a capability cannot drop out silently. The lifecycle test also runs on hip and checks the plans are closed. A hip graph-capture test runslocal_expert_count()inside the captured step.test_graph_capture.py:LEC=1puts the call between dispatch and combine and checks the count after every replay.test_jit_binding.py: the plan'sdescribe()against the built plan, no arena regions, the refusal of a top-k past the wave, launches on synthetic ids (negative and out-of-range ids, a count past the rows, epr=1/topk=1, more experts than block threads, zero rows), and the base raising without a kernel.Results
local_expert_count()time, graph mode, EP8, hidden 7168, top-k 8, 32 experts a rank, uniform routing, mean over ranks in µs. The kernel column launches the kernel alone; the call column isop.local_expert_count()(zero plus kernel).StdMoE
What this does
StdMoE (
enable_std_moe=True,convert_dispatch_output(),convert_combine_input(routing), thencombine()) now runs on the HIP backend's intranode path on gfx942 (MI300X) and gfx950 (MI355X), bf16 with the gather combine. It returns what FlyDSL returns:convert_dispatch_output()packs the last dispatch's recv rows per local expert and returns(packed_x [E_local, world_size * M, hidden], packed_count [E_local] int32, packed_src [E_local * world_size * M] int32), wherepacked_srcissrc_rank * M + src_token. These are op-owned buffers, rewritten by each call; row order inside a bucket comes from atomics.convert_combine_input(routing)writesout_tok[r] = sum over the local k of w[r, k] * packed_x[row of (r, k)]with the forwarded weights, accumulated in fp32.combine()on a StdMoE op takes its input from whatconvert_combine_inputwrote, whateverinputit is passed.gfx125x keeps refusing
enable_std_moe, as do non-bf16 dtypes (as on FlyDSL),combine_mode="scatter", and the internode and AsyncLL paths. A StdMoE dispatch without weights raises on both backends, sinceconvert_combine_inputfolds the forwarded ones.Design
Two more plans on the local-kernel family from the previous PR (
EpLocalCfg/EpLocalArgs, no arena regions):ep_convert_dispatchandep_convert_combine, both bf16 only.(row, k). Lane 0 tests whether the id is local with an unsigned compare, claims a bucket row with anatomicAddonpacked_count, and writesslot_mapandpacked_src; the warp copies the token in 16 B vectors. A non-local(row, k)getsslot_map = -1. A claim past the bucket (only possible with a repeated id in one row) is dropped and taken back off the count.< topkfill a per-warp LDS array of source pointers fromslot_map(null for -1), andcore::WarpAccumfolds them with the row's forwarded weights.The base op now owns
convert_dispatch_output(),convert_combine_input(), the packed buffers and the zero/fill steps. Backends hand backconvert_dispatch/convert_combinecallables inKernelSet, and the"std_moe"capability follows them. FlyDSL moves onto the same callables with its kernels unchanged. On a backend whose combine stages its input in the kernel (stages_in_kernel), a StdMoE combine passescombine_in_view()as the input, so the HIP kernel skips its staging copy instead of overwriting the converted rows.Tests
test_op.py: withSTDMOE=1,convert_dispatch_output()runs right after dispatch with no sync or barrier. After the barrier, OP-STDMOE-PACK checkspacked_countagainst the exact per-expert reference, each bucket'spacked_srcas a multiset against the recv rows' sources, and every packed row against the recv row it came from. The final combine is checked against(sum_k w) * xas before. Under a recv cap both run as well: the references come from the rows each rank kept, and the combine sums only the k whose PE kept the token.REROUTE=Nalso checkspacked_countin each extra round.test_dispatch_combine_v2_intranode.py: HIP caseship-bf16-stdmoe,hip-bf16-stdmoe-epr4-ragged(4 experts a rank, so a token often lands on several of them; RAGGED and NOSELF),hip-bf16-stdmoe-reroute, andbf16-stdmoe-cap/hip-bf16-stdmoe-cap(MAXRECV=1024). The hip graph-capture test also runs dispatch, both converts and combine in one captured step. The lifecycle test alternates StdMoE ops.test_jit_binding.py:describe()against the built plans, the non-bf16 refusals, a single-GPU round trip of both converts against a CPU reference, the hip gate (gfx125x, non-bf16, scatter, and the plans' own reasons for a top-k past the wave, more than 8192 experts and a hidden that is not whole 16 B rows), and the base raising without the kernels.Results
Time per call, graph mode, EP8, hidden 7168, top-k 8, 32 experts a rank, uniform routing, mean over ranks in µs.
convert_dispatch_output()includes its zero and fill of the count and slot map;convert_combine_input()is one kernel.Testing
On main (4f5ebf8) plus this PR, EP8:
8x MI355X (gfx950), ROCm 7.14.1
test_dispatch_combine_v2_intranode.py: 74 passed.test_quant_types.py,test_v2_tuning_tables.py,test_tuning_configs.py,test_tuning_profile.py,test_gfx1250_strict_arch.py,test_asyncll_options.py,test_active_qp_config.py: 235 passed, 2 skipped.test_jit_binding.py: 135 passed, 45 skipped.test_op.pyplain and with scales,test_asym_dtype.py(fp8/fp4 dispatch with the gather and both quantized scatters),test_ep_backend_parity.py,test_routing_snapshot.py,test_graph_capture.pywithLEC=1, and thebench_ep.pysmoke.test_op.pypasses 32 cases on both backends:local_expert_countand StdMoE, and StdMoE on FlyDSL;8x MI300X (gfx942), ROCm 7.14
test_dispatch_combine_v2_intranode.py: 64 passed, 10 skipped (fp4 is gfx950 only).test_op.pypasses the same cases without the fp4 formats, 26 in all.8x MI355X, ROCm 7.2.4, at b36a62d. Everything above passes except
test_ep_backend_parity.pyand onetest_asym_dtype.pycase. Both fail inccoMemAllocon ROCm 7.2.x'shipMemSetAccesssub-buffer bug, which 7.14 fixes.Performance against main (graph mode, median over three rounds, 128 tokens a rank and above):
🤖 Generated with Claude Code