Repository navigation
Add fused AR + RMSNorm + per-group FP8 quant: optional bf16 side-output - #2823
Merged
TennyWang1223 merged 6 commits intoApr 29, 2026
Merged
Conversation
ar_fusion_epilogue_per_group had the bf16_output parameter declared but
not plumbed through: the per-group kernels were passing 11 positional
args with `active` landing in the `bf16_output` slot, so the file did
not compile when bf16_output was enabled, and no caller could request
the unquantized bf16 view.
Swap (active, bf16_output) in the epilogue so the existing 11-arg
callers bind correctly, and thread an optional `bf16_output` pointer
through the 1-stage, 2-stage, and split per-group kernels, their
launchers, dispatchFusedAllReduceRMSNormQuantPerGroup, the host
fused_allreduce_rmsnorm_quant_per_group op, and the pybind signature
(new `bf16_out_ptr` kwarg defaulting to 0).
Python wrappers (CustomAllreduce, CudaCommunicator, GroupCoordinator,
tensor_model_parallel_fused_allreduce_rmsnorm_quant_per_group) take a
new `emit_bf16` flag that defaults to False. When True, allocate a
bf16 buffer, pass its data pointer to the op, and return
`(fp8, residual_out, scale, bf16)` instead of the 3-tuple. The 2-kernel
fallback inside CudaCommunicator reuses the bf16 output from
fused_allreduce_rmsnorm so the caller gets the same 4-tuple shape.
Unit test op_tests/multigpu_tests/test_fused_ar_rms_per_group_quant.py
now iterates over emit_bf16 in {False, True} and asserts the bf16
side-output agrees with the fp8+scale dequant to within one FP8
rounding step. Backward-compatible: all new args default to disabled,
no caller needs to change.
hubertlu-tw
requested review from
a team,
HaiShaw,
TennyWang1223,
kkHuang-amd and
valarLip
April 20, 2026 23:50
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
The fused ar_fusion_epilogue_per_group uses a packed-16B load plus an
intra-group butterfly __shfl_xor abs-max reduction, which imposes four
implicit constraints on group_size in addition to the n % group_size
check. A violation previously produced silently wrong scales rather
than a clean failure -- especially hard to debug under CUDA-graph
capture/replay where launch errors surface asynchronously.
Now both the C++ host dispatcher and the Python entry point enforce:
(a) group_size > 0
(b) group_size % PACK_SIZE == 0 (PACK_SIZE = 16 / sizeof(T))
(c) threads_per_group = group_size / PACK_SIZE is a power of two
(d) threads_per_group <= 64 (wavefront size on CDNA gfx94x/gfx950)
(e) n % group_size == 0
The Python validator (_validate_per_group_size) runs at the top of
CustomAllreduce.fused_ar_rms_per_group_quant and raises a synchronous
ValueError, giving an actionable call-site error instead of a
post-launch asynchronous RuntimeError.
Tests: - Non-distributed test_group_size_validation_python_check covering
(a)-(e) with both passing and failing inputs; also bad element_size
and non-int group_size. Runs first in __main__.
- --sweep-group-size flag sweeps {32, 64, 128, 256, 512} x
{(128,4096), (512,4096), (1024,4096)} x {emit_bf16=F,T} at the
given TP to validate every admitted group_size end-to-end against
the unfused reference.
- --skip-python-check escape hatch and group_size summary column.
Made-with: Cursor
valarLip
approved these changes
Apr 28, 2026
This was referenced May 1, 2026
Liang-jianhao97
pushed a commit
that referenced
this pull request
May 7, 2026
…ut (#2823) * Add fused_ar_rms_per_group_quant * Fused AR+RMSNorm+per-group FP8 quant: optional bf16 side-output ar_fusion_epilogue_per_group had the bf16_output parameter declared but not plumbed through: the per-group kernels were passing 11 positional args with `active` landing in the `bf16_output` slot, so the file did not compile when bf16_output was enabled, and no caller could request the unquantized bf16 view. Swap (active, bf16_output) in the epilogue so the existing 11-arg callers bind correctly, and thread an optional `bf16_output` pointer through the 1-stage, 2-stage, and split per-group kernels, their launchers, dispatchFusedAllReduceRMSNormQuantPerGroup, the host fused_allreduce_rmsnorm_quant_per_group op, and the pybind signature (new `bf16_out_ptr` kwarg defaulting to 0). Python wrappers (CustomAllreduce, CudaCommunicator, GroupCoordinator, tensor_model_parallel_fused_allreduce_rmsnorm_quant_per_group) take a new `emit_bf16` flag that defaults to False. When True, allocate a bf16 buffer, pass its data pointer to the op, and return `(fp8, residual_out, scale, bf16)` instead of the 3-tuple. The 2-kernel fallback inside CudaCommunicator reuses the bf16 output from fused_allreduce_rmsnorm so the caller gets the same 4-tuple shape. Unit test op_tests/multigpu_tests/test_fused_ar_rms_per_group_quant.py now iterates over emit_bf16 in {False, True} and asserts the bf16 side-output agrees with the fp8+scale dequant to within one FP8 rounding step. Backward-compatible: all new args default to disabled, no caller needs to change. * Fix linter errrors * Strengthen group_size validation for per-group FP8 AR+RMSNorm quant The fused ar_fusion_epilogue_per_group uses a packed-16B load plus an intra-group butterfly __shfl_xor abs-max reduction, which imposes four implicit constraints on group_size in addition to the n % group_size check. A violation previously produced silently wrong scales rather than a clean failure -- especially hard to debug under CUDA-graph capture/replay where launch errors surface asynchronously. Now both the C++ host dispatcher and the Python entry point enforce: (a) group_size > 0 (b) group_size % PACK_SIZE == 0 (PACK_SIZE = 16 / sizeof(T)) (c) threads_per_group = group_size / PACK_SIZE is a power of two (d) threads_per_group <= 64 (wavefront size on CDNA gfx94x/gfx950) (e) n % group_size == 0 The Python validator (_validate_per_group_size) runs at the top of CustomAllreduce.fused_ar_rms_per_group_quant and raises a synchronous ValueError, giving an actionable call-site error instead of a post-launch asynchronous RuntimeError. Tests: - Non-distributed test_group_size_validation_python_check covering (a)-(e) with both passing and failing inputs; also bad element_size and non-int group_size. Runs first in __main__. - --sweep-group-size flag sweeps {32, 64, 128, 256, 512} x {(128,4096), (512,4096), (1024,4096)} x {emit_bf16=F,T} at the given TP to validate every admitted group_size end-to-end against the unfused reference. - --skip-python-check escape hatch and group_size summary column. Made-with: Cursor --------- Co-authored-by: kk <[email protected]> Co-authored-by: TennyWang1223 <[email protected]>
This was referenced May 8, 2026
3 tasks
maeehart
added a commit
to maeehart/vllm
that referenced
this pull request
May 25, 2026
…erns Adds ``test_rocm_aiter_all_reduce_rmsnorm_group_quant_fp8_fusion_pass_replace`` plus a ``TestAiterAllReduceRMSNormGroupQuantFP8Model`` to validate the three new ``VllmPatternReplacement`` classes this PR registers on ``RocmAiterAllReduceFusionPass``: * ``AiterAllreduceFusedRMSNormGroupQuantFP8Pattern`` (no-residual) * ``AiterAllreduceFusedAddRMSNormGroupQuantFP8Pattern`` (with-residual, single ``rms`` consumer) * ``AiterAllreduceFusedAddRMSNormGroupQuantWithIndexerPattern`` (with- residual, DSv3.2 indexer fan-out -- parametrized over both ``triton_per_token_group_quant_fp8`` and ``rocm_aiter_group_fp8_quant`` producers, matching the two registrations added in commit 4) The model uses four ``rms_norm`` sites that together exercise all three patterns (matched_count == 4), and chains the FP8 quant output back into the next AllReduce by manually dequantizing through the per-group scale so we do not depend on a real FP8 block-scaled GEMM kernel. Mirrors the structure and assertions of the sibling ``TestAllReduceRMSNormStaticQuantFP8Model`` test as Rohan138 requested in review. Validated on 2-GPU MI355X (TP=2, ``smci355-1b112-b13-19``) with the PR 42864 docker image (aiter v0.1.14-rc0 + ROCm/aiter#2823 wrapper patches via aiterPR3075): all 4 (``enable_rms_norm_custom_op`` x ``use_triton_quant``) combos PASS in ~32s. Signed-off-by: Markus Hartikainen <[email protected]> Co-authored-by: Cursor <[email protected]>
frida-andersson
added a commit
to maeehart/vllm
that referenced
this pull request
Jun 2, 2026
… probe Per Rohan138 on vllm-project#42864: mark the feature probe for removal once vLLM bumps its pinned AITER past v0.1.13.post1 (ROCm/aiter#2823 is expected to ship in v0.1.14). Signed-off-by: Frida Andersson <[email protected]>
2 of 3 tasks
3 of 4 tasks
a-sidorova
added a commit
to a-sidorova/vllm
that referenced
this pull request
Sep 23, 2026
vLLM's ROCm base image (docker/Dockerfile.rocm_base) pins AITER v0.1.22.post1, which already ships both fused AllReduce+RMSNorm+FP8-quant launchers: the per-token kernel landed in v0.1.12 (ROCm/aiter#1990) and the per-group kernel in v0.1.14 (ROCm/aiter#2823). The runtime hasattr probes that gated pattern registration for graceful degradation on older builds are therefore always true and can be removed. - aiter_custom_all_reduce: drop build_supports_per_group_quant / supports_per_group_quant and the per-token equivalents. - allreduce_rms_fusion: register the per-group and per-token quant patterns unconditionally; drop the now-dead warning_once branches. - tests: drop the skip guards (and the unused AiterCustomAllreduce import) that keyed off the probes. Co-Authored-By: Claude <[email protected]> Signed-off-by: Alexandra Sidorova <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
ar_fusion_epilogue_per_grouparg order — Declared(…, output, scale_out, bf16_output, active)but callers passed 11 args ending in(…, scale_out, active), bindingbooltoT*(invalid). The bf16 path never compiled; this PR fixes parameter order and threads optionalbf16_outputthrough 1-stage / 2-stage / split per-group kernels, dispatch, host op, pybind, and Python.per_1x128quant. Withemit_bf16=True, one kernel writes fp8+scale from the same fp32 accumulators as an optional bf16 side-output.Modifications
custom_all_reduce.cuh(..., output, scale_out, active = true, bf16_output = nullptr); per-group kernels + launchers +dispatchFusedAllReduceRMSNormQuantPerGrouppassbf16_outputcustom_all_reduce.cu/.h/rocm_ops.hppbf16_out_ptr(0 = off); pybind default0emit_bf16=Falseonfused_ar_rms_per_group_quant,custom_*, communicator / coordinator / TMP helpers;True→ allocate bf16, return 4-tupletest_fused_ar_rms_per_group_quant.py:emit_bf16in matrix; asserts bf16 vs fp8 dequant within one FP8 stepBackward-compatible:
bf16_out_ptr=0,emit_bf16=False, C++bf16_output=nullptr— existing 3-tuple / no-bf16 behavior unchanged.Accuracy
Command (e.g. TP=8):
Result: All shape ×
emit_bf16runs pass.per_group_errmatches pre-PR FP8 (~<2e-5, rounding);bf16_vs_fp8 < 1.0whenemit_bf16=True.GSM8K (Qwen3.5-397B-A17B-FP8, TP=8, MI355X, companion SGLang PR): accuracy 0.946→0.955, invalid 0.010→0.008; latency/tok/s in line with expectations (see full logs if needed).
Benchmarking
Paths compared (SGLang script, TP=8, MI355X): Split 3-kernel vs Fused 2-k (AR+RMS + quant) vs Fused 1-k (fp8 only) vs Fused 1-k+bf16 (this PR).
Headline: On decode-scale shapes, Fused 1k+bf16 is ~1.02×–1.13× vs Fused 2k across hidden sizes 4096 / 6144 / 7168 / 8192. Prefill (large tokens) stays within ~±3% of 2-kernel baseline — extra bf16 stores add bandwidth; large-prefill call sites can keep
emit_bf16=Falsefor fp8-only 1-kernel.Kernel profile (Qwen3.5-397B-A17B-FP8, decode sample): fused per-group path replaces separate quant work; net −59 kernel launches per decode pass vs prior wiring (detail: 59/60 layer sites on fused path).
Serving (8192/8192, conc 16): throughput ~+2.5%, median TPOT ~−2.5% (same run configuration as internal A/B).
Full microbenchmark: decode (CUDA-graph, µs — median per rank)
At decode scale, Fused 1k+bf16 is 1.02×–1.13× vs Fused 2k across all four hidden sizes.
Full microbenchmark: prefill (eager, µs — median per rank)
Notes: Small prefill (128 tokens) is still ~1.09×–1.11× at 4096 / 6144 / 7168. The 128 × 8192 row (1.78×) is an outlier from a slow Fused 2k sample — Fused 1k at that shape is ~80.6 µs, consistent with the decode trend. Large prefill (tokens ≥ 1024) is bandwidth-bound; 1k+bf16 stays within ~±3% of Fused 2k; use
emit_bf16=Falseon those paths if only fp8 is needed.Checklist
test_fused_ar_rms_per_group_quant.pypasses foremit_bf16 ∈ {False, True}on covered hidden sizesclang-formaton touchedcsrc/as needed