Skip to content

Allow grouped GEMM quant without probability tensor - #458

Merged
sraman-rgb merged 2 commits into
NVIDIA:developfrom
sraman-rgb:optional-prob-grouped-gemm-quant
Aug 1, 2026
Merged

Allow grouped GEMM quant without probability tensor#458
sraman-rgb merged 2 commits into
NVIDIA:developfrom
sraman-rgb:optional-prob-grouped-gemm-quant

Conversation

@sraman-rgb

@sraman-rgb sraman-rgb commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Before submitting

  • I agree to license this contribution under the terms of LICENSE.txt.
  • I ran pre-commit run and committed any formatting changes.

Affected area

Summary

Why

Related issues

API and compatibility impact

Testing

Summary by CodeRabbit

  • New Features

    • Grouped GEMM quantization now supports calls without routing probabilities.
    • Probability scaling is automatically skipped when no probability tensor is provided.
    • Existing behavior remains unchanged when probabilities are supplied.
  • Tests

    • Added coverage for optional probabilities across supported grouped GEMM quantization kernels.
    • Updated validation to confirm omitted probabilities match execution with probabilities set to one.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Grouped GEMM quant APIs and kernels now accept omitted probability tensors. Probability loading and scaling are conditionally compiled and executed. Tests cover equivalence with unit probabilities and Blackwell/Rubin kernel branching.

Changes

Optional probability execution

Layer / File(s) Summary
Optional probability API
python/cudnn/gemm/cutedsl/grouped/quant/api.py
API validation, discrete compilation, execution, and wrapper documentation now support omitted prob_tensor values.
Default kernel optional probability
python/cudnn/gemm/cutedsl/grouped/quant/grouped_gemm_quant.py, test/python/fe_api/grouped_gemm/test_grouped_gemm_quant.py
The kernel tracks probability availability, skips probability loads and scaling when absent, and tests output equality against a unit-probability tensor.
Rubin kernel optional probability
python/cudnn/gemm/cutedsl/grouped/quant/moe_blockscaled_grouped_gemm_quant_rubin.py, test/python/fe_api/test_rubin_kernel_dispatch.py
The Rubin kernel handles optional probabilities for breuse, bias, and bias-free epilogues. Dispatch tests verify compile-time branching for Blackwell and Rubin kernels.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant grouped_gemm_quant_api
  participant grouped_gemm_quant_kernel
  participant d_tensor
  Caller->>grouped_gemm_quant_api: execute with prob_tensor=None
  grouped_gemm_quant_api->>grouped_gemm_quant_kernel: compile optional probability path
  grouped_gemm_quant_kernel->>d_tensor: compute and store unscaled output
  d_tensor-->>Caller: return output
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes the template headings but provides no summary, rationale, compatibility impact, related issues, or testing results. Complete the required sections with the change summary, rationale, API and compatibility impact, related issues, and exact testing commands and results.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: allowing grouped GEMM quant without a probability tensor.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@python/cudnn/grouped_gemm/grouped_gemm_quant/api.py`:
- Around line 1112-1113: Update execute() to validate that runtime probability
presence matches self.prob_desc: reject a provided probability tensor when the
kernel was compiled without one, and reject None when compiled with one. Raise a
clear error before invocation for either mismatch, while preserving execution
for matching forms.

In `@test/python/fe_api/grouped_gemm/test_grouped_gemm_quant.py`:
- Around line 523-524: Add an L0–L4 pytest level marker to
test_grouped_gemm_quant_wrapper_without_prob_tensor, choosing the level that
matches its GPU compilation cost and existing test-suite conventions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3fd83076-5819-4f74-a9b5-5431949807d8

📥 Commits

Reviewing files that changed from the base of the PR and between 708ff87 and 78f3aa3.

📒 Files selected for processing (5)
  • python/cudnn/grouped_gemm/grouped_gemm_quant/api.py
  • python/cudnn/grouped_gemm/grouped_gemm_quant/grouped_gemm_quant.py
  • python/cudnn/grouped_gemm/grouped_gemm_quant/moe_blockscaled_grouped_gemm_quant_rubin.py
  • test/python/fe_api/grouped_gemm/test_grouped_gemm_quant.py
  • test/python/fe_api/test_rubin_kernel_dispatch.py

Comment on lines +1112 to +1113
:param prob_tensor: Optional probability tensor for per-row gating. When
omitted, the kernel compiles out the probability load and multiply.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Keep the execute-time probability ABI consistent with compilation.

prob_desc selects a compile-time kernel variant, but execute() now accepts either runtime form. Direct API users can compile with sample_prob=None then pass a tensor, or compile with a sample then pass None, causing a mismatched compiled invocation rather than a clear error. Require runtime presence to match self.prob_desc.

Proposed fix
+        if self.prob_desc is None:
+            self._value_error_if(
+                prob_tensor is not None,
+                "prob_tensor must be omitted when the API was compiled without sample_prob",
+            )
+        else:
+            self._value_error_if(
+                prob_tensor is None,
+                "prob_tensor must be provided when the API was compiled with sample_prob",
+            )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
:param prob_tensor: Optional probability tensor for per-row gating. When
omitted, the kernel compiles out the probability load and multiply.
if self.prob_desc is None:
self._value_error_if(
prob_tensor is not None,
"prob_tensor must be omitted when the API was compiled without sample_prob",
)
else:
self._value_error_if(
prob_tensor is None,
"prob_tensor must be provided when the API was compiled with sample_prob",
)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/cudnn/grouped_gemm/grouped_gemm_quant/api.py` around lines 1112 -
1113, Update execute() to validate that runtime probability presence matches
self.prob_desc: reject a provided probability tensor when the kernel was
compiled without one, and reject None when compiled with one. Raise a clear
error before invocation for either mismatch, while preserving execution for
matching forms.

Comment on lines +523 to +524
def test_grouped_gemm_quant_wrapper_without_prob_tensor(request):
"""The block-scaled wrapper supports a compile-time unit probability."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add a test-level marker.

This test has no L0L4 marker, so level-based test selection will omit its classification. Add the level appropriate for its GPU compilation cost.

As per coding guidelines, “Mark every new Python test with a level from L0 through L4.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/python/fe_api/grouped_gemm/test_grouped_gemm_quant.py` around lines 523
- 524, Add an L0–L4 pytest level marker to
test_grouped_gemm_quant_wrapper_without_prob_tensor, choosing the level that
matches its GPU compilation cost and existing test-suite conventions.

Source: Coding guidelines

@coderabbitai coderabbitai Bot mentioned this pull request Jul 30, 2026

@saltyminty saltyminty left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking but grouped_gemm_quant docs should also be updated to mark prob_tensor as optional

@saltyminty

Copy link
Copy Markdown
Collaborator

@cudnn-ci-bot run

@cudnn-ci-bot

Copy link
Copy Markdown

🚀 Running mirror pipeline

Branch: cudnn-gh/pr-458-78f3aa3
Pipeline: 60404012

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
python/cudnn/gemm/cutedsl/grouped/quant/api.py (1)

269-270: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Add dtype and stride validation for optional probability descriptors.

When self.prob_desc is present, this path checks only shape. Add conditional _check_dtype and _check_tensor_stride checks for self.prob_desc before compilation. Keep the checks disabled when self.prob_desc is None.

As per coding guidelines: python/cudnn/**/api.py requires check_support() to validate dtype, shape, stride, architecture, and configuration using the provided _check_tensor_* and _value_error_if helpers.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/cudnn/gemm/cutedsl/grouped/quant/api.py` around lines 269 - 270,
Update the validation path around the probability descriptor to conditionally
call _check_dtype and _check_tensor_stride for self.prob_desc when it is
present, using the existing descriptor and validation conventions. Keep these
checks disabled when self.prob_desc is None, and ensure check_support()
validates the optional descriptor’s dtype, shape, and stride before compilation.

Source: Coding guidelines

♻️ Duplicate comments (1)
python/cudnn/gemm/cutedsl/grouped/quant/api.py (1)

1112-1113: ⚠️ Potential issue | 🟠 Major

Re-raise the unresolved execute-time probability ABI check.

prob_tensor selects a compile-time variant through self.prob_desc, but the removed guard allows either runtime form. A tensor is ignored when the kernel was compiled without probability. None reaches a variant compiled to load probability data when probability was provided at compilation. Reject both mismatches before kernel invocation. This is the same unresolved issue from the previous review.

Also applies to: 1136-1137

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/cudnn/gemm/cutedsl/grouped/quant/api.py` around lines 1112 - 1113,
Restore the execute-time ABI validation in the API method handling prob_tensor:
compare whether prob_tensor is provided with the compile-time probability
variant represented by self.prob_desc, and reject both mismatches before kernel
invocation. Preserve valid tensor/probability-enabled and
None/probability-disabled combinations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@python/cudnn/gemm/cutedsl/grouped/quant/api.py`:
- Around line 269-270: Update the validation path around the probability
descriptor to conditionally call _check_dtype and _check_tensor_stride for
self.prob_desc when it is present, using the existing descriptor and validation
conventions. Keep these checks disabled when self.prob_desc is None, and ensure
check_support() validates the optional descriptor’s dtype, shape, and stride
before compilation.

---

Duplicate comments:
In `@python/cudnn/gemm/cutedsl/grouped/quant/api.py`:
- Around line 1112-1113: Restore the execute-time ABI validation in the API
method handling prob_tensor: compare whether prob_tensor is provided with the
compile-time probability variant represented by self.prob_desc, and reject both
mismatches before kernel invocation. Preserve valid tensor/probability-enabled
and None/probability-disabled combinations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ce65e7fd-641e-408b-b8bc-205998cca07f

📥 Commits

Reviewing files that changed from the base of the PR and between 78f3aa3 and b7bb213.

📒 Files selected for processing (5)
  • python/cudnn/gemm/cutedsl/grouped/quant/api.py
  • python/cudnn/gemm/cutedsl/grouped/quant/grouped_gemm_quant.py
  • python/cudnn/gemm/cutedsl/grouped/quant/moe_blockscaled_grouped_gemm_quant_rubin.py
  • test/python/fe_api/grouped_gemm/test_grouped_gemm_quant.py
  • test/python/fe_api/test_rubin_kernel_dispatch.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/python/fe_api/grouped_gemm/test_grouped_gemm_quant.py
  • test/python/fe_api/test_rubin_kernel_dispatch.py

@sraman-rgb
sraman-rgb merged commit 073ce27 into NVIDIA:develop Aug 1, 2026
1 check passed
@Anerudhan Anerudhan added mod-frontend cuDNN frontend APIs, operation graph construction, plans, and user-facing wrappers. orig-nv-eng Reported or requested by NVIDIA engineering. cat-enhancements labels Aug 3, 2026
@Anerudhan Anerudhan added this to the Frontend 1.27.0 milestone Aug 3, 2026
@Anerudhan Anerudhan mentioned this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cat-enhancements mod-frontend cuDNN frontend APIs, operation graph construction, plans, and user-facing wrappers. orig-nv-eng Reported or requested by NVIDIA engineering.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants