You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HIP] [Dist] Support gemma_norm in fused all-reduce + RMSNorm + per-group FP8 quant - #6472
tensor_model_parallel_fused_allreduce_rmsnorm_quant already accepts gemma_norm, but the per-group branch dropped it without a warning. A caller passing gemma_norm=True, quant_type="per_group" silently got a plain x * w RMSNorm.
This PR wires gemma_norm through to the fused kernels. The kernel reads the raw weight and computes x * (1 + w), with the + 1 in fp32. All three per-group kernel paths support it: 1-stage, 2-stage and split. The fallback used above the fused size limit also passes it through.
Why it is needed: Gemma-style norms (e.g. Qwen3.5's GemmaRMSNorm) used to get this fusion only by precomputing a 1 + w copy of the weight. That copy has two problems:
In-place weight updates such as an RLHF rollout sync do not refresh it, so the model keeps normalizing with the old weight and nothing raises.
It rounds 1 + w to bf16.
With this PR the caller passes the weight itself, and both problems go away.
Changes
Kernels (csrc/include/custom_all_reduce.cuh)
The per-group epilogue ar_fusion_epilogue_per_group already took a GEMMA_NORM template parameter; the per-token path uses the same w += 1.0f in fp32. What was missing:
takes gemma_norm and forwards it to the launcher it picks
A small helper, per_group_launch_flags, turns the two runtime flags (transpose_scale, gemma_norm) into compile-time tags, matching how the launchers already handled transpose_scale.
With gemma_norm=false, every path instantiates the same kernel as before.
C++ entry / bindings (csrc/kernels/custom_all_reduce.cu, csrc/include/custom_all_reduce.h, csrc/include/rocm_ops.hpp, aiter/ops/custom_all_reduce.py)
fused_allreduce_rmsnorm_quant_per_group gets a trailing gemma_norm=false argument. Existing positional callers are unaffected.
Python (aiter/dist/)
custom_all_reduce.py: fused_ar_rms_per_group_quant and custom_fused_ar_rms_per_group_quant, including the CUDA-graph capture path.
communicator_cuda.py:
fused_allreduce_rmsnorm_quant_per_group forwards the flag to the fused kernel and to its fallback (fused_allreduce_rmsnorm(..., gemma_norm=...) + per-group quant).
The generic fused_allreduce_rmsnorm_quant now accepts gemma_norm for per_group; MXFP4 still raises NotImplementedError.
parallel_state.py: both registered ops (fused_allreduce_rmsnorm_quant_per_group_ and its _emit_bf16_ variant), their fake implementations, GroupCoordinator.fused_allreduce_rmsnorm_quant_per_group and _fused_allreduce_rmsnorm_quant_per_group_out_place. The flag does not change output shapes or strides.
communication_op.py: the per-group branch forwards gemma_norm instead of dropping it.
Test (op_tests/multigpu_tests/test_fused_ar_rms_per_group_quant.py)
New gemma_norm axis; the default sweeps both values, and --gemma-norm 0|1 pins one.
The reference is computed in fp32: rms_norm(x) * (w.float() + 1).
Unchanged: with gemma_norm=True the non-quant path still skips the quick-reduce fused RMSNorm branch (communicator_cuda.py, and not gemma_norm), as before.
Correctness: all cases pass checkAllclose(atol=0.05, rtol=0.05), plus the scale-stride and bf16-vs-fp8 checks. Exit code 0.
Latency: the same with and without gemma_norm. Min µs per call, row-major scale, no bf16 output:
tokens
gemma_norm=False
gemma_norm=True
24
11.48
11.57
512
53.92
53.95
16384
1318.29
1318.29
End to end: with this patch applied on top of 72546b3de, Qwen3.5-397B-A17B-FP8 (TP4, MTP3) in ATOM runs allreduce_fusion_kernel_1stage<bf16, bf16, 4, true> and allreduce_fusion_kernel_2stage_per_group<bf16, fp8, 4, GEMMA_NORM=true, TRANSPOSE_SCALE=true> in decode. gsm8k (first 250, InferenceX recipe) scores 246/250, against 248/250 for the previous precomputed-1 + w approach (±0.008 stderr).
Downstream user: ROCm/ATOM#2520 (Qwen3.5 decode fusion). It detects this capability from the gemma_norm parameter of GroupCoordinator.fused_allreduce_rmsnorm_quant_per_group and turns the fusion off on older aiter.
ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm
vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all
All standard extended tests (excludes ci:atom_full)
Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 6472 --add-label <label>
One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.
PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.
github-actionsBot
changed the title
[Dist] Support gemma_norm in fused all-reduce + RMSNorm + per-group FP8 quant
[HIP] [Dist] Support gemma_norm in fused all-reduce + RMSNorm + per-group FP8 quant
Oct 13, 2026
This test calls the public communicator path, but that path catches every exception from custom_fused_ar_rms_per_group_quant and silently runs the unfused RMSNorm-plus-quant fallback. Consequently, all Gemma comparisons can pass even if the new 1-stage, 2-stage, or split kernel instantiations fail to launch or are never selected. Add a forced/direct fused-kernel check (or an observable assertion that no fallback occurred) for shapes in each dispatch range.
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
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.
Summary
tensor_model_parallel_fused_allreduce_rmsnorm_quantalready acceptsgemma_norm, but the per-group branch dropped it without a warning. A caller passinggemma_norm=True, quant_type="per_group"silently got a plainx * wRMSNorm.This PR wires
gemma_normthrough to the fused kernels. The kernel reads the raw weight and computesx * (1 + w), with the+ 1in fp32. All three per-group kernel paths support it: 1-stage, 2-stage and split. The fallback used above the fused size limit also passes it through.Why it is needed: Gemma-style norms (e.g. Qwen3.5's
GemmaRMSNorm) used to get this fusion only by precomputing a1 + wcopy of the weight. That copy has two problems:1 + wto bf16.With this PR the caller passes the weight itself, and both problems go away.
Changes
Kernels (
csrc/include/custom_all_reduce.cuh)The per-group epilogue
ar_fusion_epilogue_per_groupalready took aGEMMA_NORMtemplate parameter; the per-token path uses the samew += 1.0fin fp32. What was missing:allreduce_fusion_kernel_1stage_per_group(launcher)GEMMA_NORMhard-coded tofalsegemma_normargumentallreduce_fusion_kernel_2stage_per_groupGEMMA_NORMparameterGEMMA_NORMtemplate parameterlocal_device_load_rmsnorm_quant_per_group_naive(split)GEMMA_NORMparameterGEMMA_NORMtemplate parameterdispatchFusedAllReduceRMSNormQuantPerGroupgemma_normand forwards it to the launcher it picksper_group_launch_flags, turns the two runtime flags (transpose_scale,gemma_norm) into compile-time tags, matching how the launchers already handledtranspose_scale.gemma_norm=false, every path instantiates the same kernel as before.C++ entry / bindings (
csrc/kernels/custom_all_reduce.cu,csrc/include/custom_all_reduce.h,csrc/include/rocm_ops.hpp,aiter/ops/custom_all_reduce.py)fused_allreduce_rmsnorm_quant_per_groupgets a trailinggemma_norm=falseargument. Existing positional callers are unaffected.Python (
aiter/dist/)custom_all_reduce.py:fused_ar_rms_per_group_quantandcustom_fused_ar_rms_per_group_quant, including the CUDA-graph capture path.communicator_cuda.py:fused_allreduce_rmsnorm_quant_per_groupforwards the flag to the fused kernel and to its fallback (fused_allreduce_rmsnorm(..., gemma_norm=...)+ per-group quant).fused_allreduce_rmsnorm_quantnow acceptsgemma_normforper_group; MXFP4 still raisesNotImplementedError.parallel_state.py: both registered ops (fused_allreduce_rmsnorm_quant_per_group_and its_emit_bf16_variant), their fake implementations,GroupCoordinator.fused_allreduce_rmsnorm_quant_per_groupand_fused_allreduce_rmsnorm_quant_per_group_out_place. The flag does not change output shapes or strides.communication_op.py: the per-group branch forwardsgemma_norminstead of dropping it.Test (
op_tests/multigpu_tests/test_fused_ar_rms_per_group_quant.py)gemma_normaxis; the default sweeps both values, and--gemma-norm 0|1pins one.rms_norm(x) * (w.float() + 1).Unchanged: with
gemma_norm=Truethe non-quant path still skips the quick-reduce fused RMSNorm branch (communicator_cuda.py,and not gemma_norm), as before.Testing
python3 test_fused_ar_rms_per_group_quant.py -t 4 -d bf16 -s 1,4096 13,4096 16,4096 24,4096 32,4096 64,4096 128,4096 512,4096 2048,4096 8192,4096 16384,4096, on MI355X (gfx950), TP4:Coverage: 88 cases (11 shapes ×
emit_bf16×transpose_scale×gemma_norm). They span the 1-stage (≤ 16 tokens), 2-stage (≤ 64), split, and ≥ 64 MB fallback (8192 / 16384 tokens) paths.Correctness: all cases pass
checkAllclose(atol=0.05, rtol=0.05), plus the scale-stride and bf16-vs-fp8 checks. Exit code 0.Latency: the same with and without
gemma_norm. Min µs per call, row-major scale, no bf16 output:gemma_norm=Falsegemma_norm=TrueEnd to end: with this patch applied on top of
72546b3de, Qwen3.5-397B-A17B-FP8 (TP4, MTP3) in ATOM runsallreduce_fusion_kernel_1stage<bf16, bf16, 4, true>andallreduce_fusion_kernel_2stage_per_group<bf16, fp8, 4, GEMMA_NORM=true, TRANSPOSE_SCALE=true>in decode. gsm8k (first 250, InferenceX recipe) scores 246/250, against 248/250 for the previous precomputed-1 + wapproach (±0.008 stderr).Downstream user: ROCm/ATOM#2520 (Qwen3.5 decode fusion). It detects this capability from the
gemma_normparameter ofGroupCoordinator.fused_allreduce_rmsnorm_quant_per_groupand turns the fusion off on older aiter.