Repository navigation
[HIP] [Perf] gfx1250 TP4 one-shot decode AR + RMSNorm (+ MXFP8) for 1-256 rows - #8456
XiaobingSuper wants to merge 6 commits into
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
c40955b to
aed372b
Compare
tensor_model_parallel_fused_allreduce_rmsnorm_quant(quant_type="mxfp8") (and tensor_model_parallel_fused_allreduce_rmsnorm_mxfp8_quant) returns E4M3 values with row-major group-32 E8M0 scales. On gfx1250 up to 128 rows where the Lamport one-shot applies it runs the Gluon AR + RMSNorm + MXFP8 one-shot; otherwise the Lamport / existing fused AR + RMSNorm followed by per_1x32_mx_quant_hip. The op is registered with mutates_args=[] (it writes no argument; Inductor cannot remove an auto_functionalized_v2 that returns E8M0). Hidden 6144 bf16, TP4, Gemma norm, CUDA graphs, 4x MI455X, us per call (cap at 128 rows vs. one-shot everywhere up to 4 MiB): rows 128 192 256 320 384 512 before 14.6 25.8 26.1 28.5 26.7 29.1 after 14.7 18.3 19.5 25.9 26.3 29.3 Co-authored-by: Cursor <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
aed372b to
127fa32
Compare
…irst, tail in the AR With aiter's moe_defer_tail (ROCm/aiter#8457) and the k5 decode all-reduce (ROCm/aiter#8456), MiniMax-M3's decode MoE (glue epilogue or shared fold, TP > 1, one PP stage, up to 256 rows, nothing but the next all-reduce reading the layer's output) leaves its gather-reduce (+ routed scale + shared add) to the all-reduce + RMSNorm that reads it. With the glue epilogue and the fused router on the dual-stream path, the router launches before the shared MLP's kernels, so the routed chain is not queued behind them. Same kernels and bytes; other configurations keep the existing order and the separate gather-reduce. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…irst, tail in the AR With aiter's moe_defer_tail (ROCm/aiter#8457) and the k5 decode all-reduce (ROCm/aiter#8456), MiniMax-M3's decode MoE (glue epilogue or shared fold, TP > 1, one PP stage, up to 256 rows, nothing but the next all-reduce reading the layer's output) leaves its gather-reduce (+ routed scale + shared add) to the all-reduce + RMSNorm that reads it. With the glue epilogue and the fused router on the dual-stream path, the router launches before the shared MLP's kernels, so the routed chain is not queued behind them. Same kernels and bytes; other configurations keep the existing order and the separate gather-reduce. Co-Authored-By: Claude Opus 5.5 <[email protected]>
fused_allreduce_rmsnorm on gfx1250 fell back to RCCL + a separate add + RMSNorm above the Lamport kernels' range. Add a pushed two-shot all-reduce + residual add + (Gemma) RMSNorm kernel (ar2s_rms_gfx1250) and route bf16 inputs of 32-288 MiB to it at TP4: - phase 1 pushes each row chunk to its owner's RS inbox, phase 2 sums the own chunk in fp32 in rank order, rounds once to bf16, pushes it to every peer's AG inbox and normalizes it, phase 3 normalizes the peers' rows; - block b only waits for block b of its peers (a flag per phase, sender and block, epoch counters), so no barrier is needed, eager or in a CUDA graph; - row-local barriers are LDS-only and only a flag waits for the store drain; the three phases are pipelined per step; phase 2 prefetches the next row's summands into LDS asynchronously; flag polls are bounded (no hang); - out / residual_out follow the Lamport fused kernel step by step. TP4, hidden 6144 bf16, Gemma norm, 4x MI455X, eager, us per call, measured with the first, unpipelined version of this kernel (same layout, flags and arithmetic, so the same outputs): tokens 2752 4096 6144 8192 12288 24576 before 108.1 147.9 258.2 299.7 368.1 537.4 after 85.3 104.9 145.5 182.7 256.1 502.4 residual_out matches an fp32 reference bit for bit, out is within 1 bf16 ulp for < 1e-5 of the values (4 ranks, eager and graph, 13 row counts including non-multiples of 4 and a split launch). Gated on gfx1250, TP4 (the measured world size), bf16, hidden a multiple of 256 up to 8192, 32-288 MiB. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Extend the pushed two-shot AR + RMSNorm (ar2s_rms_gfx1250) with ar2s_rms_ex
and three modes, exposed as sequence-parallel tensor_model_parallel_sp_* ops
for prefill:
- FP8: the norm output is written as MXFP8 (E4M3 + row-major E8M0 per 32),
the bytes per_1x32_mx_quant_hip gives for the bf16 out (the group max is
floored at kAmaxFloor as there, so an all-zero group gets scale 85).
- SP: each rank keeps the residual of its own row chunk only; the owner
normalizes (and quantizes) its rows and pushes the result, so the
all-gather moves MXFP8 and phase 3 is a copy. The normed output is whole
on every rank and bit-identical to the replicated path.
- AUX (with SP): no norm, the whole all_reduce(x) + residual on every rank.
tensor_model_parallel_sp_fused_allreduce_rmsnorm{,_mxfp8_quant} and
tensor_model_parallel_sp_allreduce_add_residual take the SP path at the ar2s
sizes and are the replicated ops below it, so every call of a forward takes
the same branch (mutates_args=[]).
The TP4 per-launch cap is 192 MiB, one launch for a 14336-token chunk of
hidden 6144.
TP4, hidden 6144, Gemma norm, 4x MI455X: AR + RMSNorm + MXFP8 at 14336 rows
347 -> 226 us a call (SP + MXFP8 all-gather vs ar2s + separate quant);
sp_fp8 at 14336 / 32768 rows 189.0 / 401.2 us, bit-exact.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-256 rows A one-shot all-reduce + residual add + Gemma/RMS norm kernel for decode sizes (hidden 6144, up to 256 rows) with an MXFP8 epilogue (E4M3 + row-major E8M0 per 32). On gfx1250 TP4 it takes the calls the Gluon one-shot (<= 128 rows) or the Lamport fused kernel (above) would take, with their bits: lamport_order picks the summation order of the path it replaces, and the MXFP8 epilogue floors the group max at kAmaxFloor as per_1x32_mx_quant_hip does, so it replaces the Lamport kernel + quant pair in one launch. - Its inbox (3 x 4 x rows x hidden) and counters follow the Lamport AR + RMSNorm inbox in the same IPC allocation: no IPC buffer of its own. - Flag polls are bounded; a timeout is counted (k5_ar_errors) instead of hanging. 4x MI455X, TP4, CUDA graph of 10 calls, us per call (production path -> k5): bf16 80 rows 8.29 -> 7.46, 128 rows 9.83 -> 8.64, 192 rows 15.75 -> 11.61; MXFP8 80 rows 8.94 -> 8.16, 128 rows 11.28 -> 9.07, 192 rows 18.14 -> 12.09. Co-Authored-By: Claude Opus 5.5 <[email protected]>
127fa32 to
b44a706
Compare
With a bf16 output the one-shot k5 is slower than the path it replaces above 128 rows (4x MI455X, graphs: 15.06 vs 14.18 us at 160, 18.05 vs 17.06 at 256); with the MXFP8 output it is faster at every size up to 256 rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…irst, tail in the AR With aiter's moe_defer_tail (ROCm/aiter#8457) and the one-shot decode all-reduce (ROCm/aiter#8456), MiniMax-M3's decode MoE with the glue epilogue (TP > 1, one PP stage, up to 256 rows, nothing but the next all-reduce reading the layer's output) leaves its gather-reduce (+ routed scale + shared add) to the all-reduce + RMSNorm that reads it. A forward hook on the layer or a forward pre-hook on the next one (DSpark / Eagle3 taps) keeps the gather-reduce in the MoE. With the glue epilogue and the fused router on the dual-stream path, the shared MLP still forks at the MoE input but launches right after the router (FusedMoE runs moe_after_router_hook there), so the routed chain is not queued behind the shared MLP's kernels. Same kernels and bytes; other configurations keep the existing order and the separate gather-reduce. Co-Authored-By: Claude Opus 5.5 <[email protected]>
No behavior change. - op_tests/multigpu_tests/test_ar2s_rms_gfx1250.py and test_ar2s_mxfp8_zero_group.py (from ROCm#8428's earlier head): no shebang on a non-executable file (EXE001), the timed lambdas bind their loop variables through functools.partial (B023), unused unpacked values are _-prefixed (RUF059), one combined `with` (SIM117), imports sorted with aiter first-party (I001). Co-Authored-By: Claude Opus 5.5 <[email protected]>
What
A one-shot all-reduce + residual add + RMSNorm kernel for gfx1250 TP4 decode sizes (
csrc/kernels/ar_k5_gfx1250.cu,CustomAllreduce.k5_fused_ar_rms) with an MXFP8 epilogue (E4M3 + row-major E8M0 per 32), hidden 6144, up to 256 rows. It takes the calls oftensor_model_parallel_fused_allreduce_rmsnorm{,_mxfp8_quant}that the Gluon one-shot (<= 128 rows) or the Lamport fused kernel (above) would take, with their bits:lamport_orderpicks the summation order of the path it replaces, and for MXFP8 above 128 rows its Lamport-order epilogue replaces the Lamport kernel +per_1x32_mx_quant_hippair in one launch (group max floored atkAmaxFlooras the quant does).k5_ar_errors) instead of hanging.Why
MiniMax-M3.1 decode runs two AR + RMSNorm (+ MXFP8) calls per layer at 1-256 rows; above 128 rows the production path changes kernel and its cost steps up.
Evidence
4x MI455X, TP4, hidden 6144, CUDA graph of 10 calls, max over ranks of the median, us per call (production -> k5):
bf16 bit-identical at every row count 1-256; MXFP8 payloads bit-identical. In the model (MiniMax-M3.1 TP4) the serving gate passes, GSM8K (1319, 5-shot) 0.9545 (k5) and 0.9553 (k5 + fused MXFP8).
Gated on
gfx1250, TP4 (the inbox is set up for world size 4 only), bf16
[rows, 6144], 0 < rows <= 256, and only where the Gluon one-shot or the Lamport fused kernel would have taken the call. No environment variable (the formerAITER_K5_AR,_MAX_ROWS,_MAXITand_FUSED_MXFP8are now the default / constants).Needs GPU check before ready, especially the fused MXFP8 epilogue above 128 rows: the
kAmaxFloorscale-floor change has not been re-run on GPU (test_ar_k5_gfx1250.py --check --diag: scale bytes vs Lamport +per_1x32_mx_quant_hip, including all-zero groups).PR Self-Review
Reviewed revision
b44a706
Behavior and intent
At gfx1250 TP4 hidden 6144, decode-size fused AR + RMSNorm (+ MXFP8) calls take the k5 kernel by default with the bits of the path they replace.
Validation and unverified scope
Measured on an earlier aiter base (
576d3f0), the fused MXFP8 epilogue before the scale floor. This revision:hipcc --offload-arch=gfx1250 -fsyntax-onlyon both kernel files, ruff 0.16.0 clean. Not run on GPU.PR-specific question
Stacked on #8428 (which carries #8427 and #8310); please review only the top commit.
Changed op tests
op_tests/multigpu_tests/test_ar_k5_gfx1250.py(new): out / residual_out / scale against the production path (k5 off) on every rank, eager and CUDA graph,--diagfor the fused-MXFP8 scale bytes, plus timing.🤖 Generated with Claude Code