Repository navigation
[HIP] [Perf] gfx1250 ar2s: MXFP8 output and sequence-parallel residual ops - #8428
XiaobingSuper wants to merge 7 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
…t one-shot takes over fused_allreduce_rmsnorm_mxfp8_quant sent every input up to the plain Gluon all-reduce's 4 MiB to the Gluon AR + RMSNorm + MXFP8 one-shot. Where the Lamport one-shot AR + RMSNorm can take the call, that one-shot only wins up to _GLUON_AR_NORM_MAX_TOKENS (128) rows: above, the Lamport fused AR + RMSNorm followed by the separate MXFP8 quant is faster. Use the same eligibility rule as the bf16 / per-token paths (lamport=...). Hidden 6144 bf16, TP4, Gemma norm, CUDA graphs (10 calls a graph), 4x MI455X, us per call: 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 Unchanged where the Lamport one-shot does not apply. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fused_allreduce_rmsnorm_mxfp8_quant_ was registered with the default mutates_args="unknown", so torch.compile wrapped it in auto_functionalized_v2. Inductor does not decompose one that returns E8M0, and a MiniMax-M3.1 server with ATOM_MINIMAX_M3_GLUON_AR_MXFP8=1 failed its warmup compile with "auto_functionalized_v2 was not removed". The op returns new tensors only. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…8 MiB fused_allreduce_rmsnorm on gfx1250 used to fall back to RCCL + a separate add + RMSNorm above the Lamport kernels' range. Add a pushed two-shot all-reduce + residual add + (Gemma) RMSNorm kernel (ar_2shot_rms_gfx1250) and route bf16 inputs of 32-288 MiB to it: - phase 1 pushes each row chunk to its owner's RS inbox (remote stores, the faster direction on MI455X), 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 from the AG inbox; - block b only waits for block b of its peers (a flag per phase, sender and block, epoch counters), so no barrier is needed at either end, eager or in a CUDA graph; - out / residual_out follow the Lamport fused kernel step by step. TP4, hidden 6144 bf16, Gemma norm, 4x MI455X, eager, us per call: 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). On by default for TP4 only, the measured configuration; TP2 / TP6 / TP8 opt in by setting AITER_AR2S_RMS_MAX_SIZE (bytes a launch; TP4 default 160 MiB, 0 = off). AITER_AR2S_RMS_MIN_SIZE and AITER_AR2S_RMS_MAX_TOTAL tune the range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l residual modes
Extend the pushed two-shot AR + RMSNorm (ar2s_rms_gfx1250) with
ar2s_rms_ex and three modes, and expose them 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(fp8, e8m0) gives for the bf16 out, from
the kernel's epilogue; the bf16 out is not written.
- SP: each rank keeps the residual stream of its own row chunk only (reads
res_inp and writes residual_out on those rows); the owner normalizes (and
quantizes) its rows and pushes the result instead of the bf16 sum, so the
all-gather moves MXFP8 rather than bf16 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, returns the whole all_reduce(x) + residual on every
rank from a sequence-parallel residual (e.g. for taps of a drafter).
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 (>= 32 MiB) and are the replicated ops below it, so every call of a
forward takes the same branch. They are registered with mutates_args=[].
AITER_AR2S_MXFP8=1 also lets the replicated
fused_allreduce_rmsnorm_mxfp8_quant use the FP8 mode (off by default: level
with ar2s + a separate quant, 318.7 vs 317.7 us at 14336 rows). ar2s_rms_ex
takes an optional grid cap (0 = unchanged).
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).
op_tests/multigpu_tests/test_ar2s_rms_gfx1250.py checks fp8 / sp / sp_fp8 /
aux and the public ops bit for bit against ar2s + per_1x32_mx_quant_hip at
4-32768 rows (non-owned residual rows poisoned with NaN), and that every
rank holds the same output.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
…mx_quant_hip mxfp8_quant8 started the group max at 0, so an all-zero 32-element group got E8M0 scale byte 0, where per_1x32_mx_quant_hip writes 85 (2^-42, from its 1e-10 floor on the group max). Seed the max at aiter::kAmaxFloor, as the HIP quantizer does. The E4M3 values were already identical; now the scale bytes are too, for the replicated and the sequence-parallel FP8 modes. op_tests/multigpu_tests/test_ar2s_mxfp8_zero_group.py (TP4, hidden 6144) puts an all-zero row next to random rows and checks the E4M3 and E8M0 bytes against per_1x32_mx_quant_hip of the bf16 output, including scale 85 on the zero row, with and without sp_residual. Passes on 4x MI455X. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… LDS prefetch A second ar2s kernel with kernel 1's data layout, flags and arithmetic (bit-identical outputs) and its serializations removed: - row-local barriers are LDS-only (__syncthreads() drained every row's remote all-gather stores before the next row); the only store drains are the ones before a flag; - straight-line loads instead of a per-chunk `if` around each; - optional pipelining of the reduce-scatter and the all-gather in steps (AITER_AR2S_STEP; default one step, the measured best); - bounded flag polls (AITER_AR2S_MAXIT); a poll that gives up is counted (ar2s_rms_errors) instead of hanging; - <= 64 VGPRs so two 768-thread blocks fit a CU; - PF (default on, AITER_AR2S_PF=0 turns it off): phase 2 reads its rows through a double-buffered LDS slot loaded asynchronously one row ahead (global_load_async_to_lds_b128). Kernel 2 is the default up to TP4 (it spills at 6 / 8 ranks); AITER_AR2S_KERNEL=1 / 2 overrides. ar2s_rms_set_kernel / ar2s_rms_errors are for tests and profiling. 4x MI455X, TP4, 14336 / 32768 rows, PF on vs off: sp_fp8 213.1 -> 189.0 / 453.5 -> 401.2 us, sp 248.6 -> 224.1 / 538.7 -> 485.4 us, aux 229.3 -> 222.0 / 506.1 -> 483.2 us, bit-exact. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Update: pushed 63b9540, ar2s kernel 2, on top of this branch. It is the base for the MoE-front mode PR that stacks on this one.
|
What
This PR extends the gfx1250 pushed two-shot AR + RMSNorm (
ar2s_rms_gfx1250, #8427) with anar2s_rms_exentry point that has three modes. It also exposes them as sequence-parallel all-reduce ops for prefill.per_1x32_mx_quant_hip(fp8, e8m0)gives for the bf16 output. The bf16 output itself is not written.rankof each launch, given byCustomAllreduce.ar2s_sp_own_rows. The owner normalizes (and quantizes) its rows and pushes the result instead of the bf16 sum. The all-gather therefore moves MXFP8 instead of bf16, and phase 3 becomes a copy. The normed output is whole on every rank and bit-identical to the replicated path's.all_reduce(x) + residual, computed from a sequence-parallel residual. This is how the taps of a speculative drafter gather the residual stream.New public ops in
aiter.dist.communication_op:tensor_model_parallel_sp_fused_allreduce_rmsnormtensor_model_parallel_sp_fused_allreduce_rmsnorm_mxfp8_quanttensor_model_parallel_sp_allreduce_add_residualThey are registered through
torch_compile_guardwithmutates_args=[]. At ar2s sizes (32 MiB and up) they take the SP path. Below that they call the replicated ops, so every call in one forward takes the same branch. A residual returned at prefill size is only valid on the rows this rank owns, so it must only be passed back into these ops.Other knobs:
AITER_AR2S_MXFP8=1lets the replicatedfused_allreduce_rmsnorm_mxfp8_quantuse the FP8 mode as well. It is off by default: at 14336 rows it measured level with ar2s + a separate quant (318.7 vs 317.7 us).ar2s_rms_extakes an optionalgridcap. The default, 0, leaves the grid unchanged.Why
In MiniMax-M3.1 TP4 prefill, the two all-reduce + RMSNorm (+ MXFP8 quant) calls of each layer were about 31% of a 14K-token prefill forward on top of a 100K-token cached prefix. With a sequence-parallel residual, each rank only needs its own rows of the residual. The all-gather can then carry the 8-bit normed activations that the next GEMM consumes.
Performance
TP4, hidden 6144, Gemma norm, 4x MI455X.
That measurement used
AITER_AR2S_RMS_MAX_SIZE=201326592, so a 14K-token all-reduce is one launch.Correctness
op_tests/multigpu_tests/test_ar2s_rms_gfx1250.py(4 GPUs) compares every mode bit for bit against ar2s +per_1x32_mx_quant_hip. It runs at 4, 100, 2752, 6144, 14336, 16384, 24576 and 32768 rows.All checks pass on the validation stack. In the model, our serving gate passes with real speculative acceptance, and greedy outputs are identical on 16K-token prompts.
All-zero groups (fixed). The first version wrote E8M0 scale byte 0 for an all-zero 32-element group, where
per_1x32_mx_quant_hipwrites 85 (2^-42, from its 1e-10 floor on the group max); the E4M3 values were already identical. Commit 43918cb (the top commit) seeds the group max ataiter::kAmaxFloor, as the HIP quantizer does. The replicated and SP FP8 outputs now equalper_1x32_mx_quant_hipbyte for byte, including scale 85 on all-zero rows.op_tests/multigpu_tests/test_ar2s_mxfp8_zero_group.pychecks this and passes on 4x MI455X.End-to-end (combined stack, not this PR alone)
MiniMax-M3.1 on 4x MI455X, TP4: agentic multi-turn trace replay (AgentX) at concurrency 64, 900 s per run, same node, same afternoon.
The stack is our 1120 integration image plus all the changes in this series, with every flag on. That covers ROCm/aiter PRs 8273, 8310 and 8427-8432 and ROCm/ATOM PRs 3680-3683. It also includes pieces not yet in a PR: the ATOM wiring for the fused QKV chain, the fast o_proj and the FlyDSL indexer CP scorer, and the paged-attention split-KV fused reduce. Speculative acceptance length was forced to 4.04 for this A/B; the same configuration passed our serving gate with real acceptance.
Baseline P90 interactivity varied from 164.6 to 181.8 across three baseline runs that day (mean 173.4; mean median 253.7). Our best estimate is therefore about +11% P90 and +14% median interactivity against the mean baseline. That is for the whole stack; this PR's own share is not separated out.
Dependencies
Depends on #8310 (fused native MXFP8 AR RMSNorm, with its two follow-up commits: the one-shot cap and
mutates_args=[]) and #8427 (the base ar2s kernel); please review only the top 2 commits (the SP modes and the all-zero-group scale fix).The four commits below the top two are those PRs, unmodified, rebased onto main. The SP MXFP8 op falls back to #8310's
fused_allreduce_rmsnorm_mxfp8_quantbelow the ar2s range. Once both land, this rebases to the top two commits.Limitations
AITER_AR2S_RMS_MAX_SIZE. Without it the ops are the replicated ones.Validation status: validated on the 1120 integration stack (aiter 576d3f0 / ATOM 6c20f00); not yet re-validated on main after rebase. The rebase needed no code changes.
🤖 Generated with Claude Code