[CUDA] Add build option for TensorRT fused attention cubins - #31632
Merged
Tianlei Wu (tianleiwu) merged 3 commits intoAug 5, 2026
Conversation
Copilot started reviewing on behalf of
Hariharan Seshadri (hariharans29)
August 4, 2026 17:40
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a CUDA build-time opt-out for embedding TensorRT fused multi-head attention prebuilt cubins, reducing binary size when disabled while preserving current defaults and ensuring the plugin build remains package-friendly across platforms.
Changes:
- Introduce
onnxruntime_USE_TRT_FUSED_ATTENTION(CUDA-dependent, default ON) and propagate it asUSE_TRT_FUSED_ATTENTIONto the provider build. - Guard TensorRT fused-attention cubin declarations/metadata/lookup helpers and filter the corresponding
.cubin.cc/_kernel.sm*.ccsources when the option is OFF. - Update CUDA plugin packaging behavior (Windows DLL version resource; Linux skip build RPATH) and add CI coverage for the opt-out configuration.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| onnxruntime/contrib_ops/cuda/bert/tensorrt_fused_multihead_attention/mha_runner.cu | Stubs TRT fused runner support when the build option is disabled. |
| onnxruntime/contrib_ops/cuda/bert/tensorrt_fused_multihead_attention/fused_multihead_attention_v2.h | Guards TRT fused cubin metadata/lookup and provides null-return stubs when disabled. |
| onnxruntime/contrib_ops/cuda/bert/tensorrt_fused_multihead_attention/flash_attention/fmha_flash_attention.h | Guards flash-attention cubin metadata/lookup behind the build option. |
| onnxruntime/contrib_ops/cuda/bert/tensorrt_fused_multihead_attention/cross_attention/fmha_cross_attention.h | Guards cross-attention cubin metadata/lookup behind the build option. |
| cmake/onnxruntime_providers_cuda.cmake | Filters out TRT fused cubin blob sources when the option is OFF. |
| cmake/onnxruntime_providers_cuda_plugin.cmake | Applies the same filtering for plugin builds; adds Windows version resource and Linux RPATH suppression. |
| cmake/CMakeLists.txt | Defines the new onnxruntime_USE_TRT_FUSED_ATTENTION option and emits the provider compile define when enabled. |
| .github/workflows/windows_cuda_no_cudnn.yml | Exercises onnxruntime_USE_TRT_FUSED_ATTENTION=OFF in Windows CUDA plugin CI. |
Hariharan Seshadri (hariharans29)
approved these changes
Aug 4, 2026
Tianlei Wu (tianleiwu)
enabled auto-merge (squash)
August 4, 2026 19:45
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.
This change adds a build option for excluding the prebuilt TensorRT fused multi-head attention cubins from the CUDA Execution Provider. The option is enabled by default to preserve existing behavior; disabling it removes approximately 14 MB of embedded cubin data and leaves attention selection to the other available kernels and unfused fallback paths.
Key Changes
onnxruntime_USE_TRT_FUSED_ATTENTION, dependent on CUDA and enabled by default.onnxruntime_USE_TRT_FUSED_ATTENTION=OFFin the Windows CUDA no-cuDNN plugin build.Testing Notes
git diff --check origin/main...HEADpasses.