Repository navigation
Add CUDA BitwiseXor integer kernels - #33645
Open
Justin Chu (justinchuby) wants to merge 1 commit into
Open
Justin Chu (justinchuby) wants to merge 1 commit into
Justin Chu (justinchuby) wants to merge 1 commit into
Conversation
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The scoped implementation, registrations, documentation, and fallback-disabled regression coverage are consistent, with no unresolved blocking issues.
No open issues 🎉
What changed in this PR
Adds CUDA support for standard ONNX BitwiseXor at opset 18+, allowing integer XOR workloads to stay on the GPU without changing boolean Xor.
Changes:
- Registers kernels for all eight signed and unsigned integer types using existing binary elementwise infrastructure.
- Adds CPU-fallback-disabled CUDA regressions for boundaries, broadcasting, scalars, empty outputs, and INT64 RNG-state XOR values at opsets 18 and 24.
- Updates the CUDA operator support table.
No actionable findings remain.
| File | Description |
|---|---|
| onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc | Adds CUDA-only integer XOR regression coverage. |
| onnxruntime/core/providers/cuda/math/binary_elementwise_ops.h | Declares the typed BitwiseXor kernel. |
| onnxruntime/core/providers/cuda/math/binary_elementwise_ops.cc | Defines registrations for eight integer types. |
| onnxruntime/core/providers/cuda/math/binary_elementwise_ops_impl.h | Adds the integer XOR expression. |
| onnxruntime/core/providers/cuda/math/binary_elementwise_ops_impl.cu | Instantiates typed CUDA implementations. |
| onnxruntime/core/providers/cuda/cuda_execution_provider.cc | Includes the kernels in CUDA provider registration. |
| docs/OperatorKernels.md | Documents CUDA BitwiseXor support. |
Review effort: Balanced
This was referenced Oct 27, 2026
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 CUDA execution for standard ONNX
BitwiseXor(opset 18+) forint8,uint8,int16,uint16,int32,uint32,int64, anduint64. Reuse the existing binary elementwise implementation for multidirectional broadcasting and empty tensors. BooleanXoris unchanged; this does not add other bitwise operators.Add CUDA-only regressions with CPU fallback explicitly disabled, covering all eight integer types at opsets 18 and 24, signed/unsigned boundaries, scalar operands, multidirectional broadcasting in both operand orders, empty outputs, and the INT64
state XOR (state / 2048)RNG pattern. Update the CUDA operator support table.Validation on Azure Linux 3 / NVIDIA H200 (physical GPU4), CUDA 13.3, cuDNN 9.10.2, Python 3.12, Release/sm90; source based on main
997d2d1b26plus this patch:python tools/ci_build/build.py --config Release --build_dir /tmp/ort-cuda-bitwise-xor-8d05709c/build --build --build_wheel --skip_tests --skip_submodule_sync --use_cuda --cuda_home /usr/local/cuda --cudnn_home /usr/lib/python3.12/site-packages/nvidia/cudnn --parallel 16 --disable_contrib_ops --disable_ml_ops --targets onnxruntime_provider_test onnxruntime_pybind11_state— passed, producing an ORT 1.32.0 GPU wheel. The build was configured with Ninja,CMAKE_CUDA_ARCHITECTURES=90,onnxruntime_QUICK_BUILD=ON, and Flash/MEA/TRT-fused-attention/XQA disabled.CUDA_VISIBLE_DEVICES=4 LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/lib/python3.12/site-packages/nvidia/cudnn/lib ./onnxruntime_provider_test --gtest_filter=*Xor*— 45 tests passed, no skips, including existing boolean XOR tests.BitwiseXorexecutions usedCUDAExecutionProvider, with CPU fallback disabled. This covers all integer types, opsets 18/24, full-width random values (including upper 64-bit lanes), scalar/multidirectional/empty cases, and integratedDiv → BitwiseXorgraphs over 4,103 INT64 RNG states. Before installing the patched wheel, the same probes on ORT 1.28.0 (0368187f84) produced 146 CPU XOR executions; GPU-only initialization failed as expected.clang-format --dry-run --Werroron all six changed C++/CUDA files — passed;git diff --check— passed.The initial untargeted contrib-disabled build encountered a pre-existing
-Werror=unused-functioninonnxruntime/test/optimizer/nhwc_transformer_test.cc:71; the relevant provider-test and wheel targets above built successfully without changing unrelated code. Full-suite, non-sm90, full-model fidelity, and performance validation were not performed.Motivation and Context
Current main has CPU and DirectML
BitwiseXorkernels but no CUDA registration. Integer RNG hashing therefore falls back to CPU, even for INT32/UINT32, introducing repeated device transfers in GPU inference. This was observed while adding fishaudio/drama-3 support in onnxruntime/mobius#793 (2,862 CPU XOR executions in one sampled profile). Supporting the standard operator preserves the model's RNG algorithm and exact integer outputs without a custom operator or graph rewrite.