[CUDA] Build compact fpA intB kernels by default - #32324
Merged
Tianlei Wu (tianleiwu) merged 3 commits intoAug 31, 2026
Merged
Conversation
Rename the compact build define to describe its FP16-only kernel set and restore non-Hopper dispatch support for SM75 and newer devices. Keep runtime eligibility, profiling, tests, diagnostics, and documentation aligned with the compact contract.
Contributor
There was a problem hiding this comment.
Pull request overview
Makes compact FP16 INT4/INT8 CUDA fpA_intB kernels the default while retaining the full kernel matrix behind an option.
Changes:
- Adds compact/full build configuration and source filtering.
- Aligns runtime eligibility, dispatch, profiling, validation, and workspace estimation.
- Updates tests and documentation for the compact contract.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
cmake/CMakeLists.txt |
Adds compact and full build modes. |
cmake/onnxruntime_cuda_source_filters.cmake |
Filters unused compact-mode kernels. |
docs/contrib_ops/cuda/matmul_nbits.md |
Documents both kernel modes. |
onnxruntime/contrib_ops/cuda/llm/fpA_intB_gemm/fpA_intB_gemm_template.h |
Adds compact architecture dispatch. |
onnxruntime/contrib_ops/cuda/llm/fpA_intB_gemv/dispatcher.h |
Restricts compact GEMV variants. |
onnxruntime/contrib_ops/cuda/llm/fpA_intB_gemv/fpA_intB_gemv.cu |
Adds compact launch and support logic. |
onnxruntime/contrib_ops/cuda/quantization/matmul_nbits.cc |
Implements compact eligibility and profiling. |
onnxruntime/contrib_ops/cuda/quantization/matmul_nbits.h |
Aligns construction and validation. |
onnxruntime/test/contrib_ops/cuda_kernels/fpA_intB_gemm_kernel_test.cc |
Exercises compact kernel shapes. |
onnxruntime/test/contrib_ops/matmul_4bits_test.cc |
Updates build-specific diagnostics. |
onnxruntime/test/providers/cuda/test_cases/matmul_nbits_workspace_test.cc |
Tests compact eligibility and architecture selection. |
onnxruntime/test/python/quantization/test_op_matmulnbits_prepacked_cuda.py |
Expands prepacked-weight parity coverage. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
David Fan (jiafatom)
approved these changes
Aug 31, 2026
Tianlei Wu (tianleiwu)
enabled auto-merge (squash)
August 31, 2026 03:21
3 tasks
Tianlei Wu (tianleiwu)
added a commit
that referenced
this pull request
Aug 31, 2026
## Description Refine fpA-intB GEMV support checks and test coverage for the compact kernel configuration introduced by PR #32324. The support query now evaluates the physical device architecture separately from the selected kernel/layout architecture, while compact mode remains limited to FP16 groupwise kernels using the non-SM90 layout. ## Summary of Changes ### GEMV support and dispatch | File | Change | |------|--------| | `onnxruntime/contrib_ops/cuda/llm/fpA_intB_gemv/fpA_intB_gemv.h` | Update the support-query declaration to accept both device and kernel architectures. | | `onnxruntime/contrib_ops/cuda/llm/fpA_intB_gemv/fpA_intB_gemv.cu` | Apply compact/full build checks using separate device and kernel architecture inputs, including SM90-layout and BF16 constraints. | | `onnxruntime/contrib_ops/cuda/quantization/matmul_nbits.h` | Pass the physical device architecture and selected packing architecture to the support query. | ### Tests | File | Change | |------|--------| | `onnxruntime/test/contrib_ops/cuda_kernels/fpA_intB_gemm_kernel_test.cc` | Add support-matrix coverage for combinations of device architecture, kernel/layout architecture, and kernel type. | | `onnxruntime/test/python/quantization/test_op_matmulnbits_prepacked_cuda.py` | Use compact-compatible `block_size=32` in the configuration-key fixture so the test exercises fpA-intB instead of falling back. | ## Testing - CUDA internal tests passed: 123 tests, including `FpAIntBGemvTest.SupportUsesDeviceAndKernelArchitectures`. - Four Python configuration-key tests passed against a fresh native build. - Both modified translation units compiled successfully with compact mode disabled/full-mode settings. - `git show --check` passed with no whitespace errors. - `lintrunner -a` was attempted; the Ruff, Ruff-format, and ClangFormat adapters failed without reporting violations in the changed files. ## Motivation and Context A Hopper device can use either the SM80-compatible packing/layout or the native SM90 layout. Treating the selected layout architecture as the device architecture incorrectly rejected valid compatibility-layout dispatch, while ignoring the layout allowed compact mode to select unsupported kernels. Keeping these inputs separate makes the support matrix reflect both hardware capability and the compiled kernel path. ## Checklist - [x] Tests added/updated - [x] No breaking changes - [x] Documentation updated (not applicable)
This was referenced Sep 10, 2026
Open
This was referenced Sep 14, 2026
Open
Closed
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
block_size=32.onnxruntime_USE_FPA_INTB_GEMM_FULLto retain the complete BF16, zero-point, bias, larger-block-size, and native Hopper kernel matrix when required.USE_COMPACT_FPA_INTB_GEMMand exclude native Hopper kernels from it.Motivation and Context
The default fpA_intB build compiled many kernel variants that are not required by the FP16 INT4/INT8 RC model contract. A compact default reduces the generated CUDA kernel set while preserving the full matrix behind an explicit build option.
The compact kernels are non-Hopper kernels rather than SM80-only kernels: they support compute capability 7.5 and newer. Native Hopper TMA/WGMMA kernels remain restricted to SM90 and the full build.
Testing
onnxruntime_provider_testbuild.onnxruntime_providers_cuda_llmbuild.MatMulNBitsWorkspace.*: 14 tests passed.Fp16Int8GroupwiseTest.*andFp16Int4GroupwiseTest.*: 2 tests passed on SM90 through the non-Hopper compatibility path.lintrunner, Python syntax validation, andgit diff --checkpassed.