Repository navigation
[Common] Dispatch non-FP8 gated activation forward to vectorized pointwise kernel - #4038
Open
wanglei875 wants to merge 1 commit into
Open
wanglei875 wants to merge 1 commit into
wanglei875 wants to merge 1 commit into
Conversation
…twise kernel Signed-off-by: wanglei875 <[email protected]>
Contributor
Confidence Score: 5/5
[Medium impact] This PR appears safe to merge. SummaryRestricts the gated forward TMA kernel to FP8 outputs.
Reviews (1) · Last reviewed commit: "[Common] Dispatch non-FP8 gated activati..." · Reviewed by Greptile |
This branch has not been deployed
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.
Description
In
quantize_gated_fwd_helper(transformer_engine/common/cast/dispatch/gated.cuh), theNVTE_DELAYED_TENSOR_SCALINGcase currently dispatches SM 10.0+ gated forward calls withcols % 32 == 0to the FP8 TMA kernel (cast_fp8_gated_kernel) regardless of output dtype—even when the output is unquantized BF16/FP16/FP32.As reported in #3968, routing unquantized BF16 gated SwiGLU forward through the FP8 TMA kernel incurs TMA descriptor creation, 65.7 KB dynamic shared memory per block, and lower effective memory bandwidth (~4.0–4.3 TB/s on GB200 vs ~5.6–5.8 TB/s for a plain vectorized pointwise kernel).
This PR restricts
use_tma_kernelsinquantize_gated_fwd_helpertois_fp8_dtype(output->dtype())so that unquantized BF16/FP16/FP32 gated forward calls dispatch directly to the existing vectorized pointwise kernel (fp8::cast_gated_fwd/GatedActivationKernelLauncher), which uses wide vectorized loads/stores with zero dynamic shared memory and compiles out FP8 scaling viaif constexpr (is_fp8<OutputType>::value).Backward (
quantize_gated_bwd_helper) is left unchanged since #3968 notes dSwiGLU backward is unaffected.Addresses #3968
Type of change
Changes
use_tma_kernelsinquantize_gated_fwd_helper(transformer_engine/common/cast/dispatch/gated.cuh) withis_fp8_dtype(output->dtype())so non-FP8 outputs use the vectorized pointwisecast_gated_fwdpath on SM 10.0+.Checklist: