Skip to content

Fix/3170 dense blockscaled sm12x - #3180

Merged
kahyunnam merged 3 commits into
flashinfer-ai:mainfrom
leonardHONG:fix/3170-dense-blockscaled-sm12x
May 18, 2026
Merged

kahyunnam merged 3 commits into
flashinfer-ai:mainfrom
leonardHONG:fix/3170-dense-blockscaled-sm12x

Conversation

@leonardHONG

@leonardHONG leonardHONG commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

📌 Description

After #3113 extended the b12x decorator to SM121, calling mm_fp4(..., backend="b12x") on sm_121 still trips the dispatch-side check in
dense_blockscaled_gemm_sm120_b12x.py:1591:

ValueError: dense_gemm launch only supports sm_120, got sm_121

SM120 and SM121 share the same 12.x spec (MMA atoms, SMEM), so the same kernel applies. Allow sm_121 through the check. The error message is updated to match.

Other call sites in this file (sm_version="sm_120" at line 1875,
get_smem_capacity_in_bytes("sm_120") at lines 122/1461) are left alone — they work for both arches.

🔍 Related Issues

Refs #3170 (Action Item 4). Follows up on #3113.

🚀 Pull Request Checklist

✅ Pre-commit Checks

  • I have installed pre-commit by running pip install pre-commit (or used your preferred method).
  • I have installed the hooks with pre-commit install.
  • I have run the hooks manually with pre-commit run --all-files and fixed any reported issues.

🧪 Tests

  • Tests have been added or updated as needed.
  • All tests are passing (unittest, etc.).

No new tests; no SM121 hardware locally. Existing sm_120 path unchanged.

Reviewer Notes

Same audit cleanup batch as #3173 / #3174 / #3175.

Summary by CodeRabbit

  • Improvements
    • Expanded GPU architecture support to include additional SM12x devices (sm_120 and sm_121).

@coderabbitai

coderabbitai Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The launch-time architecture validation in the dense blockscaled GEMM kernel is expanded to accept both SM120 and SM121 GPU architectures instead of only SM120. The corresponding error message is updated to reflect the expanded supported architecture set.

Changes

Cohort / File(s) Summary
Architecture Validation Expansion
flashinfer/gemm/kernels/dense_blockscaled_gemm_sm120_b12x.py
Extended SM version check to accept both sm_120 and sm_121 in launch-time validation; updated error message to reference SM12x (sm_120/sm_121) support.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • flashinfer#3113: Adds SM121 support for the b12x GEMM backend capability decorator, complementing this launch-time validation change.
  • flashinfer#2261: Implements padding and kernel-selection changes to enable correct CUTLASS FP8 GEMM execution on SM120/SM121 architectures.

Suggested labels

op: gemm, run-ci

Suggested reviewers

  • dhiraj113
  • aleozlx
  • yzh119
  • bkryu

Poem

🐰 A kernel now spreads its wings so wide,
SM121 joins the SM120 ride,
No longer confined to one GPU's grace,
Both siblings now run the GEMM race! 🚀

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the fix: extending SM12x dense blockscaled GEMM support. It directly relates to the main change in the PR, which is allowing sm_121 alongside sm_120.
Description check ✅ Passed The description covers all required template sections: the 📌 Description explains the problem and solution clearly, 🔍 Related Issues links to #3170 and #3113, and 🚀 Pre-commit Checks are marked complete with testing rationale provided.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@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 (1)
flashinfer/gemm/kernels/dense_blockscaled_gemm_sm120_b12x.py (1)

1875-1875: Optional: consider plumbing the actual device SM version instead of hardcoding "sm_120".

dense_gemm() always passes sm_version="sm_120" regardless of the running device, so on sm_121 the validation at line 1591 only succeeds because of the hardcoded literal — not because the actual device capability is propagated. Since SM120 and SM121 share the same 12.x spec this is functionally fine today (and the PR description explicitly calls this out as intentional), but it does mean the new "sm_121" branch in the validator is unreachable through this entry point. If dense_gemm() is ever called on a non-SM12x device, the hardcoded literal would also silently pass the check. Consider deriving sm_version from a_torch.device (e.g. via torch.cuda.get_device_capability) for symmetry with the b12x decorator's gating; alternatively, leave a brief comment here noting the intentional hardcoding and SM120/SM121 equivalence.

No action required for this PR — flagging as a potential follow-up.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@flashinfer/gemm/kernels/dense_blockscaled_gemm_sm120_b12x.py` at line 1875,
dense_gemm currently hardcodes sm_version="sm_120", which prevents propagating
the actual device SM and makes the sm_121 validator branch unreachable; change
dense_gemm to derive sm_version from the runtime device (e.g., read
a_torch.device and call torch.cuda.get_device_capability to form
"sm_{major}{minor}" or similar) so the validator sees the real SM, or if you
intentionally want the hardcode leave a short comment next to
sm_version="sm_120" explaining the deliberate choice and SM120/SM121
equivalence; reference dense_gemm, the sm_version literal, and the b12x
decorator gating when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@flashinfer/gemm/kernels/dense_blockscaled_gemm_sm120_b12x.py`:
- Line 1875: dense_gemm currently hardcodes sm_version="sm_120", which prevents
propagating the actual device SM and makes the sm_121 validator branch
unreachable; change dense_gemm to derive sm_version from the runtime device
(e.g., read a_torch.device and call torch.cuda.get_device_capability to form
"sm_{major}{minor}" or similar) so the validator sees the real SM, or if you
intentionally want the hardcode leave a short comment next to
sm_version="sm_120" explaining the deliberate choice and SM120/SM121
equivalence; reference dense_gemm, the sm_version literal, and the b12x
decorator gating when making the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: da3b31b1-95e2-4da7-b04a-c322205ec4ae

📥 Commits

Reviewing files that changed from the base of the PR and between 5e1318c and c136d4c.

📒 Files selected for processing (1)
  • flashinfer/gemm/kernels/dense_blockscaled_gemm_sm120_b12x.py

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request updates the DenseGemmKernel initialization to support both sm_120 and sm_121 architectures. Feedback suggests that while the check is updated, a hardcoded sm_version in the dense_gemm function call later in the file should be reviewed for consistency to ensure full compatibility with SM121.

Comment thread flashinfer/gemm/kernels/dense_blockscaled_gemm_sm120_b12x.py
@kahyunnam

Copy link
Copy Markdown
Member

/bot run

@flashinfer-bot

Copy link
Copy Markdown
Collaborator

GitLab MR !607 has been created, and the CI pipeline #49610128 is currently running. I'll report back once the pipeline job completes.

@flashinfer-bot

Copy link
Copy Markdown
Collaborator

[FAILED] Pipeline #49610128: 11/20 passed

@kahyunnam
kahyunnam enabled auto-merge (squash) May 4, 2026 22:33
@kahyunnam
kahyunnam merged commit 9a463df into flashinfer-ai:main May 18, 2026
30 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants