Repository navigation
Add BF16 grouped sReLU fusion with explicit numerical modes - #3937
Draft
ZeYang1025 wants to merge 2 commits into
Draft
ZeYang1025 wants to merge 2 commits into
ZeYang1025 wants to merge 2 commits into
Conversation
Signed-off-by: Ze Yang <142831877+ZeYang1025@users.noreply.github.com>
4 of 7 tasks
Signed-off-by: Ze Yang <142831877+ZeYang1025@users.noreply.github.com>
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
Add the BF16 grouped MLP path for weighted squared ReLU and tanh-clamped squared ReLU on SM100/SM103, using the cuDNN Frontend sReLU forward/backward wrappers.
The default is
bf16_act_input="acc",bf16_tanh_mode="approx", andactivation_recompute_in_mlp=False: FC2 wgrad consumes the actual forward FC2 input. Both activation-input modes, both tanh implementations, and save/recompute are supported. Withsavedplus recomputation, FC2 input is bitwise identical to forward under the same tanh configuration. Withaccplus recomputation, backward reconstructs from the saved BF16 pre-activation and may change FC2 wgrad; the implementation does not change the selected input mode. This guarantee concerns FC2 input only, not whole-MLP or training equivalence to unfused BF16.Changes
NVTE_ALLOW_NONDETERMINISTIC_ALGO=0or PyTorch deterministic algorithms are enabled; atomic otherwise.Depends on NVIDIA/cudnn-frontend#2884, NVIDIA/cudnn-frontend#2885 and NVIDIA/cudnn-frontend#2886, CuTe DSL >=4.8.0, and the existing canonical BF16 grouped GEMM/wgrad APIs. Capability detection checks the new wrapper options as well as the existing GEMM markers.
Downstream integration: NVIDIA/Megatron-LM#9756.
Validation
GB300 (SM103) validation on 2026-11-24 used TE
7522c2eb7ea94491c1b2da6f4163beebae5f0e50, MCoree57410176cb54de70071745f443f0d7c441d8bc3, and cuDNN Frontendf73ade8a8f33300687d38d80823f8ea676515efe. Python/native import provenance was checked after fresh cuDNN/TE builds. Environment: PyTorch 2.12.0a0 (NGC 26.04), CUDA 13.2, cuDNN 9.25, CuTe DSL 4.8.1, TVM FFI 0.1.12.Passed, with zero skips:
TestGroupedMLPBf16SReLU: 89 tests, including the full numerical matrix, saved/recomputed FC2-input semantics, dProb policy, delayed/main-grad wgrad, empty experts and CUDA graphs.TestGroupedMLPBf16FusedOpplusTestGroupedMLPDeterminism: 59 tests.Outstanding validation:
CUDA Error: unspecified launch failurein nativelaunch_grouped_gemm_setup, first atTestGroupedLinearOp::test_wgrad_storage_and_hooks[False-False-1]. The next 5,281 cases errored during RNG/CUDA setup. This is not a passing regression run; an isolated PR/base comparison is pending.use-dict-literalfindings, fixed in follow-up commit26cdc7807df304e0b91985ab81d425d89a011ebe, plus an unused-argument warning in an unchanged activation method. The follow-up passes the pinned Black check and AST equivalence check; its GPU/lint rerun and baseline lint comparison are pending.NVTE_ALLOW_NONDETERMINISTIC_ALGO=1. The launcher now sets0specifically for replay; no replay pass is claimed yet.The PR remains a draft pending the remaining validation and human review.
Type of change
Checklist