[CUDA] Add GatedAdd contrib operator - #31835
Open
Tianlei Wu (tianleiwu) wants to merge 1 commit into
Open
Conversation
Tianlei Wu (tianleiwu)
force-pushed
the
tlwu/20260810/gated_add
branch
from
August 10, 2026 04:24
cae980d to
5bdb3a0
Compare
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
com.microsoft::GatedAdd, a CUDA contrib operator that computesX + round_to_T(Y * gate)with a per-row gate broadcast across the hidden dimension. The FP16 and BF16 implementations use separate PTX multiply and add instructions to preserve the rounding behavior of separate ONNXMulandAddnodes rather than contracting to FMA semantics.The operator is intended to remove one launch per gated residual/add pair in MoE shared-expert paths. On Qwen3.6-35B-A3B-NVFP4 with N=3 MTP, fusing 40 main-model pairs plus one MTP pair reduced median decode latency from 7.311 to 7.225 ms/round (-1.18%). A graph-off Nsight capture measured 40.35 fewer launches/round and 1.30% lower GPU kernel time.
Changes
GatedAddschema for float, float16, and bfloat16.Validation
Mul+Addfor float, FP16, and BF16.onnxruntimeandonnxruntime_providers_cudatargets build successfully.clang-format --dry-run --Werrorpasses for all touched C++/CUDA files.Mul+Addpairs; all other nodes, initializers, inputs, and outputs remained unchanged after normalizing fused edge names.