Repository navigation
[CUDA] Enable tanh-GEGLU for MoE and integer QMoE - #33633
Draft
Ti-Tai Wang (titaiwangms) wants to merge 1 commit into
Draft
Ti-Tai Wang (titaiwangms) wants to merge 1 commit into
Ti-Tai Wang (titaiwangms) wants to merge 1 commit into
Conversation
Expose the existing gated activation through the public operator parser and validate fused gate/up layouts without enabling SwiGLU-only fast paths. Use tanh-GELU and preserve chunked gate/up ordering for GEGLU, while retaining the existing GELU and SwiGLU behavior. Add independent numerical/layout regression tests and document the CUDA contract, precision limits, and unsupported quantization families. Preserve the current-main INT3 schema and shape inference during the port. Validation: scoped lintrunner and whitespace checks pass. Earlier SM80 build executed 12 selected CUDA provider tests with no failures or skips. The current-main port still requires a fresh build/runtime qualification; full-model numerical and performance attribution remain unestablished. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9a2a5b82-7cd3-4a76-bb94-0998527ea723 Signed-off-by: copilot-swe-agent[bot] <198982749+Copilot@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.
Summary
Expose the existing internal GEGLU activation through the public CUDA
MoEand integerQMoEoperators, with explicit tanh-GELU semantics and fused gate/up layouts.The current upstream main has an internal
ActivationType::Geglu, butMoEBaserejectsactivation_type="geglu"and restricts nonzeroswiglu_fusionto SwiGLU. This prevents an ONNX caller from using the existing gated implementation for this activation.Changes
activation_type="geglu"with explicit fused FC1 layouts: mode 1 is interleaved[gate0, up0, ...], mode 2 is chunked[gate | up]. Reject separate FC3 inputs and unfused mode 0.GELU_taylorforGELU(gate, approximate="tanh") * upin both gated activation dispatch paths. Keep ordinary GELU and existing SwiGLU behavior unchanged.The port is based on
3b4a0fff56c9b89f644acfc6613ae4dad3aeb5ff. It preserves the newer QMoE INT3 schema factory and its type/shape inference implementation; schema edits are documentation-only.Validation
git diff --checkpassed.942356fce6bdc78c016e4b902e49492fdf695453: 12 selected CUDA provider tests executed, 12 passed, 0 skipped on A100/SM80.std::tanh, with inputs that distinguish it from erf-GELU. FP32 uses absolute tolerance3e-5, relative tolerance zero, and asserts erf/tanh reference separation greater than ten times that tolerance. FP16/BF16 have explicit dtype-specific tolerances.This is a Draft: the clean current-main port has not been rebuilt or executed locally. The earlier test result is not presented as execution of this PR head. SM90/TMA, additional GPU architectures, and a fresh full-model qualification remain unverified.
Accuracy and performance limitations
These changes enable a previously unreachable public operator path; they are not a claim that the complete Gemma4 model is numerically qualified or faster.
This PR does not change CPU or other execution providers, rebuild llama.cpp/GenAI, or change model weights/quantization recipes.