Repository navigation
Support gemma_norm flag for rmsnorm path - #3981
Conversation
Signed-off-by: Phi-C <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
Signed-off-by: Phi-C <[email protected]>
| @@ -4340,55 +4341,102 @@ void dispatchFusedAllReduceRMSNormQuant(hipStream_t stream, | |||
| #define DISPATCH_AR_FUSION_KERNEL(NGPUS) \ | |||
There was a problem hiding this comment.
The DISPATCH_AR_FUSION_KERNEL macro grew from ~59 to ~106 lines (+80%) to support the gemma_norm template branch. Each of the three launcher paths (1-stage, 2-stage, split) now duplicates its full 13-argument call site inside an if (gemma_norm) / else block.
The non-quant dispatchFusedAllReduceRMSNorm in this same file already handles the same dispatch with a cleaner double-pointer pattern — launch_fused_allreduce_rmsnorm(kernel, gemma_kernel) — where the if/else lives once in an 18-line macro and each call site is a single line. Adopting the same pattern here would keep the macro body flat and make adding future boolean template parameters much cheaper (currently a second bool would double the macro again to ~200 lines across 9 instantiation sites).
| emit_bf16: bool = False, | ||
| gemma_norm: bool = False, | ||
| ): | ||
| if quant_type == "per_token" and group_size == 128 and not emit_bf16: |
There was a problem hiding this comment.
This fast-path condition compares quant_type against the raw string "per_token" before any normalization. communicator_cuda._normalize_fused_ar_rms_quant_type maps several aliases ("fp8", "fp8_per_token", "per-token", QuantType.per_Token, etc.) to "per_token", but that normalization only happens deeper in the stack. Callers using those aliases will silently miss this torch-compile-guarded fast path and fall through to the slower device_communicator route.
Suggest calling _normalize_fused_ar_rms_quant_type at the top of this method before the fast-path branch (it's already imported via the communicator layer; alternatively expose it from a shared utils module).
| eps: float, | ||
| group_name: str, | ||
| prefill_support: bool = False, | ||
| gemma_norm: bool = False, |
There was a problem hiding this comment.
No test covers the new gemma_norm=True path. The repo already has op_tests/multigpu_tests/test_custom_allreduce_fp8.py exercising the fused AR+RMSNorm+quant pipeline, so there is a ready template to extend.
Per the ROCm contributing guidelines: "New functionality is only merged with new unit tests." A minimal test could call tensor_model_parallel_fused_allreduce_rmsnorm_quant with gemma_norm=True and compare the output against a reference x / rms(x) * (1 + weight) computation, covering at least the per-token FP8 path across all three dispatch variants (1-stage, 2-stage, split).
Signed-off-by: Phi-C <[email protected]>
Signed-off-by: Phi-C <[email protected]>
Signed-off-by: Phi-C <[email protected]>
…ion on total bytes Signed-off-by: Phi-C <[email protected]>
zufayu
left a comment
There was a problem hiding this comment.
LGTM. All three review points addressed: macro refactored to eliminate duplication, quant_type normalization moved before fast-path check, and gemma_norm=True dispatch paths covered by new tests.
…orm_quant (#4066) * fix(dist): remove in-function import from traced fused_allreduce_rmsnorm_quant The in-function import of _normalize_fused_ar_rms_quant_type inside GroupCoordinator.fused_allreduce_rmsnorm_quant (added in #3981) causes a TorchDynamo graph break for every input when the method is traced under @support_torch_compile (surfaces as 'VllmBackend can only be called once' on the ATOM-native DeepSeek path). quant_type already arrives canonicalized to a string from the public API (_canonical_fused_ar_rms_quant_type) and from the mxfp4 helper, so the inline normalization is redundant; the device path re-normalizes anyway. Removing it eliminates the graph break (0 breaks, server startup completes). Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(dist): remove inline import from traced CudaCommunicator.fused_allreduce_rmsnorm_quant Same latent graph break as the parallel_state.py fix: the in-function import of _normalize_fused_ar_rms_quant_type inside CudaCommunicator.fused_allreduce_rmsnorm_quant graph-breaks TorchDynamo when the method is traced (reachable via the mxfp4 / emit_bf16 / non-128 per-token paths from GroupCoordinator). quant_type already arrives canonicalized to a string from the public API, and both in-tree callers pass a canonical string (parallel_state.py:641 forwards it; _fused_allreduce_rmsnorm_quant_out_place uses the per_token default), so the normalization here is redundant. Co-Authored-By: Claude Opus 4.8 <[email protected]> * update comment --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
Motivation
add
gemma_normflag support for rmsnorm pathTechnical Details
Test Plan
Test Result
Submission Checklist