Repository navigation
[CUDA] Honor deterministic compute for MatMulNBits tactic selection - #32898
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The selected deterministic GEMM tactic is invalid on SM89 and causes execution failure.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds deterministic CUDA MatMulNBits tactic selection independent of profiling state.
Changes:
- Selects stable GEMV or non-split-K GEMM tactics.
- Adds cache-independence and exact reconstruction tests.
- Honors deterministic session configuration during execution.
| File | Description |
|---|---|
fpA_intB_gemm_profiler.h |
Declares deterministic tactic selection. |
fpA_intB_gemm_profiler.cc |
Implements fixed tactic selection. |
matmul_nbits.cc |
Uses deterministic tactics when requested. |
matmul_nbits_workspace_test.cc |
Tests profile-cache independence. |
matmul_nbits_fpa_intb_layout_test.cc |
Tests deterministic weight reconstruction. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Route the Qwen 248320 by 2560 symmetric INT4 projection through the M=1 CUDA GEMV specialization. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Synced with latest main (79d3fcf) in merge commit 40c1f97; the merge was conflict-free. Review/CI fixes are in 5b73613, and all five open threads have individual replies and are resolved. Changes:
CI diagnosis:
Local validation:
No full ORT runtime was rebuilt or installed, and no SM89 hardware execution or fresh-provider gtest execution is claimed. New-head CI is pending with no failures reported at this check; stale-head workflows were not rerun. The user checkout and installed runtime were preserved. |
Preserve deterministic tactic selection while retaining target-branch decode profiling and geometry validation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Native SM90 tactics intentionally leave legacy split-K and stage fields unused. Assert their native tile metadata instead, while checking architecture-valid legacy stages in regular and quick builds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Synced this PR with main through 327d11a in merge 7c915d3, preserving deterministic selection and the newer shape-aware INT4 decode profiling logic. Fixed the shared Linux CUDA / Windows CUDA / TensorRT test failure in 39ff12d. Native SM90 tactics intentionally leave the legacy split-K factor and pipeline-stage fields at -1; the regression now checks native tile metadata and those unused-field values, while legacy tactics retain architecture-valid stage and non-split-K assertions (also valid in quick builds). No tactic metadata was changed just to satisfy the test. The WASM Debug failures were the external-data tests repaired upstream in 2297e77 (#33226), which is now included by the target merge. All five existing review threads already had individual fix replies and were resolved. Those fixes remain intact; no unresolved threads were present at the final pre-push check. Validation:
Full ORT provider, Windows, and WASM suites were not run locally. The push starts fresh CI; no stale old-head jobs were rerun. |
Tianlei Wu (tianleiwu)
left a comment
There was a problem hiding this comment.
LGTM — deterministic tactic selection across SM75–SM90 and the single-row INT4 GEMV shape gate and tests look clean.



Description
When deterministic compute is enabled, CUDA MatMulNBits now selects a stable fpA-intB tactic instead of using the timing-profiled choice. For small row counts it selects the available CUDA GEMV tactic; otherwise it selects a fixed non-split-K GEMM tactic. This path bypasses the profiled tactic cache. With deterministic compute disabled, the existing profiling behavior is unchanged.
The PR adds tests for cache independence and exact 2-, 4-, and 8-bit weight reconstruction in deterministic mode.
Motivation and Context
Fresh processes running the same quantized model with greedy decoding sometimes selected different MatMulNBits tile and split-K tactics. Those tactics produced slightly different FP16 outputs from identical inputs, eventually changing the ninth generated token from
680to264. ORT’s existing deterministic-compute flag did not previously govern this tactic selection.On SM80, the isolated MatMul output matched bitwise in 12/12 fresh processes after the change. In a downstream full-model validation, 36/36 deterministic runs produced the same token stream and tactic fingerprint; with the flag disabled, both original branches still appeared. Deterministic selection may be slower than a profiled tactic. Validation does not establish identical results across hardware or batch shapes.
Qwen INT4 decode specialization
This PR now also routes the Qwen Flash-Next language-model projection through the existing M=1 symmetric INT4 CUDA GEMV specialization for the exact shape:
M = 1N = 248320K = 256032The dispatch remains shape- and format-gated, so other
MatMulNBitsworkloads retain their existing selection behavior. The specialization reduces single-token draft-head projection overhead used by Qwen speculative decoding.