Skip to content

Add version-adaptive nvvm.atomicrmw wrapper for cutlass-dsl 4.5.x compat#411

Open
Anerudhan wants to merge 1 commit into
NVIDIA:developfrom
Anerudhan:fix/atomicrmw_45_compat
Open

Add version-adaptive nvvm.atomicrmw wrapper for cutlass-dsl 4.5.x compat#411
Anerudhan wants to merge 1 commit into
NVIDIA:developfrom
Anerudhan:fix/atomicrmw_45_compat

Conversation

@Anerudhan

@Anerudhan Anerudhan commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

nvidia-cutlass-dsl 4.5.x generates atomicrmw(res, op, ptr, a, ...) with a required explicit result type; 4.6.0+ infers the result and removed the parameter, so the same call site cannot work across the >=4.5.0 range the pyproject now allows.

Introduce cudnn/nvvm_compat.py with an atomicrmw wrapper that detects the installed builder signature once at import and forwards accordingly, and route all 13 raw nvvm.atomicrmw call sites (grouped_gemm, discrete grouped_gemm, gemm_amax, gemm_dsrelu, gemm_swiglu, sdpa) through it.

This is the cudnn-frontend equivalent of the atomicrmw fix on rachitg/cute_dsl_kernel_library@fix/support_dsl_47.

Validated on sm_100:

Before submitting

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

Affected area

Summary

Why

Related issues

API and compatibility impact

Testing

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility of GPU atomic operations across supported NVIDIA CUTLASS DSL versions.
    • Preserved existing FP32 and integer atomic add/max behavior while reducing version-specific failures.
    • Applied the compatibility improvements across grouped GEMM, MoE scheduling, block-scaled GEMM, and attention operations.

nvidia-cutlass-dsl 4.5.x generates atomicrmw(res, op, ptr, a, ...) with a
required explicit result type; 4.6.0+ infers the result and removed the
parameter, so the same call site cannot work across the >=4.5.0 range the
pyproject now allows.

Introduce cudnn/nvvm_compat.py with an atomicrmw wrapper that detects the
installed builder signature once at import and forwards accordingly, and
route all 13 raw nvvm.atomicrmw call sites (grouped_gemm, discrete
grouped_gemm, gemm_amax, gemm_dsrelu, gemm_swiglu, sdpa) through it.

This is the cudnn-frontend equivalent of the atomicrmw fix on
rachitg/cute_dsl_kernel_library@fix/support_dsl_47.

Validated on sm_100:
- 4.5.0 (res branch): dglu fp8 + glu pass (dglu fp8 also proves the
  issue NVIDIA#397 NVVM failure is absent on 4.5's libNVVM)
- 4.6.1 (no-res branch): glu / dsrelu fp8 / gemm_amax fp8 pass;
  dglu fp8 still blocked by the 4.6.x libNVVM regression (NVIDIA#397)
- 4.7.0a0 internal nightly: full dglu suite incl. all fp8 variants
  passes - 4.7's libNVVM resolves NVIDIA#397 with no kernel changes needed

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds a version-adaptive NVVM atomicrmw wrapper and replaces direct atomic intrinsic calls across grouped GEMM, discrete grouped GEMM, GEMM epilogues, and SDPA helpers without changing public signatures or atomic operation semantics.

Changes

NVVM atomic compatibility

Layer / File(s) Summary
Add version-adaptive atomic wrapper
python/cudnn/nvvm_compat.py
Adds an atomicrmw wrapper that detects whether the installed NVVM API accepts an explicit res parameter and forwards arguments accordingly.
Migrate grouped and discrete atomic helpers
python/cudnn/discrete_grouped_gemm/..., python/cudnn/grouped_gemm/...
Updates integer, FP32 atomic-add, and FP32 atomic-max helpers to call the compatibility wrapper while preserving operation kinds and conversions.
Migrate GEMM and SDPA kernel atomics
python/cudnn/gemm_amax/..., python/cudnn/gemm_dsrelu/..., python/cudnn/gemm_swiglu/..., python/cudnn/sdpa/utils.py
Routes GEMM epilogue and SDPA atomic operations through the compatibility wrapper without changing operand flow or return handling.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The required template sections for Affected area, Summary, Why, Related issues, API impact, and Testing are left blank. Fill in the required sections with the affected area, concise summary, rationale, related issue references, compatibility impact, and concrete testing results.
Linked Issues check ⚠️ Warning The PR fixes atomicrmw API compatibility, but issue #397 requires resolving fp8 grouped_gemm_dglu compilation failures on sm_100a, which this change does not directly address. Add evidence or code changes showing fp8 grouped_gemm_dglu compiles on sm_100a across supported cutlass-dsl versions, or narrow the linked issue scope.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: a version-adaptive nvvm.atomicrmw compatibility wrapper.
Out of Scope Changes check ✅ Passed All code changes are limited to the atomicrmw compatibility shim and its in-scope call-site updates.
Docstring Coverage ✅ Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%.
✨ 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.

🧹 Nitpick comments (2)
python/cudnn/nvvm_compat.py (2)

13-13: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Handle non-introspectable builders explicitly.

inspect.signature() can raise TypeError or ValueError; because this runs during module import, an unsupported binding currently produces an opaque import failure. Catch these exceptions and raise a targeted compatibility error, or verify that every supported Cutlass DSL build guarantees an inspectable signature. (docs.python.org)

🤖 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/nvvm_compat.py` at line 13, Update the _ATOMICRMW_TAKES_RES
initialization to handle TypeError and ValueError from
inspect.signature(nvvm.atomicrmw) during module import, and raise a targeted
compatibility error that clearly identifies the unsupported or
non-introspectable NVVM binding.

13-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add regression tests for both atomicrmw signatures.

Mock builders with and without the res parameter, then verify argument forwarding, especially loc/ip, and confirm that the wrapper returns the builder result unchanged.

🤖 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/nvvm_compat.py` around lines 13 - 20, Add regression tests for
the atomicrmw wrapper covering builders whose signatures include and omit res.
Mock each builder, invoke atomicrmw with representative res, op, ptr, a, loc,
and ip values, and assert the correct forwarded arguments and that the wrapper
returns each builder’s result unchanged.
🤖 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.

Nitpick comments:
In `@python/cudnn/nvvm_compat.py`:
- Line 13: Update the _ATOMICRMW_TAKES_RES initialization to handle TypeError
and ValueError from inspect.signature(nvvm.atomicrmw) during module import, and
raise a targeted compatibility error that clearly identifies the unsupported or
non-introspectable NVVM binding.
- Around line 13-20: Add regression tests for the atomicrmw wrapper covering
builders whose signatures include and omit res. Mock each builder, invoke
atomicrmw with representative res, op, ptr, a, loc, and ip values, and assert
the correct forwarded arguments and that the wrapper returns each builder’s
result unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 47286d40-3d08-4e1b-90a2-f1a073f67cdf

📥 Commits

Reviewing files that changed from the base of the PR and between 6c577ac and 202263e.

📒 Files selected for processing (10)
  • python/cudnn/discrete_grouped_gemm/discrete_kernel_utils.py
  • python/cudnn/discrete_grouped_gemm/moe_persistent_scheduler.py
  • python/cudnn/gemm_amax/dense_blockscaled_gemm_persistent_amax.py
  • python/cudnn/gemm_dsrelu/dense_blockscaled_gemm_persistent_dsrelu_quant.py
  • python/cudnn/gemm_swiglu/dense_blockscaled_gemm_persistent_swiglu_interleaved_quant.py
  • python/cudnn/grouped_gemm/moe_kernel_helpers.py
  • python/cudnn/grouped_gemm/moe_persistent_scheduler.py
  • python/cudnn/grouped_gemm/utils.py
  • python/cudnn/nvvm_compat.py
  • python/cudnn/sdpa/utils.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: cutedsl kernel fails on upgrade to 4.6.0

1 participant