You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[CUDA] Add BFloat16 ArgMax/ArgMin support and extend GatedAdd with projected gate - #33470
Adds BFloat16 support to standard ai.onnx::ArgMax and ai.onnx::ArgMin (opset 13+) on the CUDA Execution Provider and extends com.microsoft::GatedAdd with an optional projected-gate weight (gate_weight) and sigmoid_in_fp32 attribute, eliminating the need for any new standalone contrib operators (ArgMaxLastAxis, SigmoidGateMul, HyperConnectionPostMix) in Qwen3.8-Flash-Next RC2.
Registers BFloat16 for ArgMax and ArgMin (opset 13+) and instantiates reduce_lastdim_max_min<BFloat16> for fast last-axis vocabulary argmax without requiring com.microsoft::ArgMaxLastAxis.
Adds optional 4th input gate_weight ([K, 1]) and sigmoid_in_fp32 attribute to GatedAdd (output = X + Y * sigmoid(gate @ gate_weight)), plus GatedAddVec8Kernel (uint4 8-element vectorized loads/stores) and ProjectedSigmoidGateMulKernel.
Pushed e587c56 addressing all eight outstanding review threads: checked narrowing of packed gate attributes, precise padded-stride projection bounds, WebGPU-to-CPU packed EngramGate fallback with real session regressions, safe no-exception regression guards, and generated schema ordering/type-constraint corrections.
Validation: full-PR lintrunner -a and check-only lint passed in qwen-flash; official renderer/source-metadata checks verify complete schema ordering and exact CPU/CUDA type sets; projection extent arithmetic was checked across 2,304 layouts. Source whitespace checks pass. Renderer-produced blank-line indentation was preserved in the moved generated documentation.
No local builds, compilation, native tests, or model execution were performed. New C++ regressions are added but unexecuted locally. At inspection, no head checks were failed; several were still running. Fresh post-push CI, including native --gen_doc validate, is pending and is not claimed green.
For last-axis widths up to 4096, LaunchTypedArgmax writes directly to the output and never uses either scratch buffer. These allocations still reserve 12 bytes per row: 12 MiB of unused scratch for a [1048576, 1] input. Set the scratch count to zero for a single partition; GetScratchBuffer returns nullptr for zero counts, avoiding both allocations.
This rank filter is compiled out under ORT_USE_EP_API_ADAPTERS (the enclosing condition starts at line 706). Adapter builds instead use Ep::GetCapabilityImpl in core/providers/webgpu/ep/ep.cc:59–168, which accepts registered EngramGate nodes without checking rank. Packed FP32/FP16 inputs therefore still reach the WebGPU kernel's rank-4 check and fail instead of falling back to CPU. Add the equivalent filter to the plugin capability path and run the new fallback regressions with adapters enabled.
Pushed b679f3b: optional projected SigmoidGateMul, explicit prefill arithmetic control, and shared-expert activation/row-gate preparation. Existing layout/overflow validation and unrelated reviewer changes are preserved. Scoped CUDA host/device and schema translation units compile. Shared-expert tests in companion #33473 compare against these unfused operators; the combined local runtime passed its 38 focused shared-expert native tests. This does not establish independent PR-branch build/link qualification. Companion #33473 depends on these new helper declarations and implementations.
Retain both the PR tensor-op registrations and main's ConvStateReplay
declaration and schema registration.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolved conflicts against main (1f4b965) and pushed through dbd8b83. Both schema-registration conflicts retain the PR tensor operators and main’s ConvStateReplay declaration/registration.
Validation before pushing:
Ran lintrunner -a, reviewed/applied formatting-only changes, then reran lintrunner -a and lintrunner: no lint issues.
git diff --check against main passes; removed trailing whitespace in the PR operator documentation.
Compiled merged environment.cc, bert_defs.cc, contrib_defs.cc, fused_tensor_ops.cc and fused_tensor_ops.cu using the exact isolated PR headers and main-compatible ONNX protobuf headers. All five compilation checks passed.
This is targeted merged-source compilation, not a full clean standalone build, link, or runtime-test qualification. Existing integration worktree, active model package, and LiveCodeBench snapshot were untouched.
Tianlei Wu (tianleiwu)
changed the title
Add fused hyper-connection and tensor CUDA operators
[CUDA] Add SigmoidGateMul and ArgMaxLastAxis contrib operators
Oct 24, 2026
…2 QMoE, and PR cleanups
- Extend FoldMid2/FoldTail to head_rows<=8 and pack tokens[4..7] into ring record words 1, 2, 3, and 5.
- Add state_update_capacity (0..8) support to CausalConvWithState and enable state_update_capacity > 0 in QwenS2 GatedDeltaNetDecodeWarpKernel.
- Raise kMaxProfiledExpandedRows to 80 in moe_gemv.h and kFusedRouteMaxRows to 8 in qmoe_fused_route.cuh; add fast INT3 and offline SM80 INT2/INT4 prepack QMoE support.
- Eliminate pq[8][ROWS] local register array in HcUpPreKernel and sync PR cleanups (#33469, #33470, #33471, #33472, #33474, #33548, #33569).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…d with projected gate
- Remove com.microsoft::ArgMaxLastAxis and instead register BFloat16 (opset 13+)
on standard ai.onnx::ArgMax and ai.onnx::ArgMin in CUDA (reduction_ops.cc,
reduction_functions.cu, cuda_execution_provider.cc).
- Extend com.microsoft::GatedAdd with optional gate_weight [K, 1] projection,
sigmoid_in_fp32 attribute, and 16-byte uint4 vectorization (GatedAddVec8Kernel),
and vectorize ScaledSiLUKernel with uint4 (ScaledSiLUVec8Kernel).
- Update fused_tensor_ops_test.cc, ContribOperators.md, and OperatorKernels.md.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tianlei Wu (tianleiwu)
changed the title
[CUDA] Add SigmoidGateMul and ArgMaxLastAxis contrib operators
[CUDA] Add BFloat16 ArgMax/ArgMin support, extend GatedAdd, and add SigmoidGateMul
Oct 25, 2026
Remove the three leftover explicit template instantiations of
ArgMaxLastAxis in fused_tensor_ops.cc after ArgMaxLastAxis was replaced
with BFloat16 support on ai.onnx::ArgMax and ai.onnx::ArgMin.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…l into GatedAdd
- Move LaunchProjectedSigmoidGateMul directly into gated_add_impl.{h,cu} for GatedAdd's optional gate_weight input.
- Remove unused com.microsoft::SigmoidGateMul schema, kernel registration, fused_tensor_ops.{h,cc,cu}, and docs.
- Add BFloat16 projected-gate GatedAdd and ArgMax unit tests to gated_add_op_test.cc.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tianlei Wu (tianleiwu)
changed the title
[CUDA] Add BFloat16 ArgMax/ArgMin support, extend GatedAdd, and add SigmoidGateMul
[CUDA] Add BFloat16 ArgMax/ArgMin support and extend GatedAdd with projected gate
Oct 25, 2026
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
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.
Adds
BFloat16support to standardai.onnx::ArgMaxandai.onnx::ArgMin(opset 13+) on the CUDA Execution Provider and extendscom.microsoft::GatedAddwith an optional projected-gate weight (gate_weight) andsigmoid_in_fp32attribute, eliminating the need for any new standalone contrib operators (ArgMaxLastAxis,SigmoidGateMul,HyperConnectionPostMix) in Qwen3.8-Flash-Next RC2.Key Changes
ArgMax/ArgMinBFloat16(CUDA)onnxruntime/core/providers/cuda/reduction/reduction_ops.cc,reduction_functions.cu,cuda_execution_provider.ccBFloat16forArgMaxandArgMin(opset 13+) and instantiatesreduce_lastdim_max_min<BFloat16>for fast last-axis vocabulary argmax without requiringcom.microsoft::ArgMaxLastAxis.com.microsoft::GatedAddProjected Gate & Vectorized Kernelonnxruntime/core/graph/contrib_ops/bert_defs.cc,onnxruntime/contrib_ops/cuda/bert/gated_add.{h,cc},gated_add_impl.{h,cu}gate_weight([K, 1]) andsigmoid_in_fp32attribute toGatedAdd(output = X + Y * sigmoid(gate @ gate_weight)), plusGatedAddVec8Kernel(uint48-element vectorized loads/stores) andProjectedSigmoidGateMulKernel.onnxruntime/test/contrib_ops/gated_add_op_test.cc,docs/ContribOperators.md,docs/OperatorKernels.mdBFloat16ArgMax(keepdims=0/1) andGatedAddprojected gate (sigmoid_in_fp32=0/1), and syncs operator schema/kernel tables.Testing Notes
onnxruntime_provider_test --gtest_filter="ContribOpGatedAddTest.*"qwen_flash_next_int4_int8_rc2_contrib_dflash2(27/27engine_behaviours.pypass,15.54–15.88 ms/cycleat2K–32Kcontext, and673 / 800 (84.125%)on MMLU-Pro (391.26 tok/smedian,444.08 tok/sP90,474.01 tok/smax).