Skip to content

Fix: Extend b12x FP4 GEMM support to SM121 (GB10/DGX Spark) - #3113

Merged
bkryu merged 1 commit into
flashinfer-ai:mainfrom
meena-at-work:meenakshiv/sm121-b12x-gemm-fp4
Apr 20, 2026
Merged

bkryu merged 1 commit into
flashinfer-ai:mainfrom
meena-at-work:meenakshiv/sm121-b12x-gemm-fp4

Conversation

@meena-at-work

@meena-at-work meena-at-work commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

SM121 (GB10, used in DGX Spark and RTX Pro 6000) supports the same b12x CuTe DSL warp-level MMA FP4 GEMM kernels as SM120, but was excluded from _b12x_gemm_fp4_requirement's supported_compute_capability list. On SM121, calling mm_fp4(..., backend="b12x") raised:
BackendSupportedError: mm_fp4 does not support backend 'b12x' with capability 121

Add 121 to the supported compute capability list so that mm_fp4(..., backend="b12x") works correctly on SM121.

📌 Description

🔍 Related Issues

🚀 Pull Request Checklist

Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete.

✅ 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.

If you are unsure about how to set up pre-commit, see the pre-commit documentation.

🧪 Tests

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

Reviewer Notes

Summary by CodeRabbit

Release Notes

  • New Features
    • Extended FP4 GEMM support to NVIDIA Hopper GPU architecture (SM121), in addition to Ada GPUs (SM120), enabling optimized performance on a broader range of NVIDIA GPUs.

SM121 (GB10, used in DGX Spark and RTX Pro 6000) supports the same
b12x CuTe DSL warp-level MMA FP4 GEMM kernels as SM120, but was
excluded from _b12x_gemm_fp4_requirement's supported_compute_capability
list. On SM121, calling mm_fp4(..., backend="b12x") raised:
  BackendSupportedError: mm_fp4 does not support backend 'b12x' with capability 121

Add 121 to the supported compute capability list so that
mm_fp4(..., backend="b12x") works correctly on SM121.

Signed-off-by: Meenakshi Venkataraman <meenakshiv@nvidia.com>
@coderabbitai

coderabbitai Bot commented Apr 18, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Updated FP4 b12x GEMM compute-capability gating to include SM121 devices in addition to SM120. The decorator change enables backend selection for newer hardware during runtime device compatibility filtering.

Changes

Cohort / File(s) Summary
Compute-Capability Support
flashinfer/gemm/gemm_base.py
Expanded _b12x_gemm_fp4_requirement decorator supported compute capabilities from [120] to [120, 121], enabling SM121 device support for FP4 b12x GEMM operations.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • #2751: Coordinated SM121 enablement across GEMM backends and runtime CUDA version checks.
  • #3051: Directly modifies the same FP4 _b12x_gemm_fp4_requirement compute-capability gating.
  • #2012: Expands SM121 support for multiple FP4 GEMM backend requirement decorators.

Suggested labels

run-ci, op: gemm

Suggested reviewers

  • dhiraj113
  • aleozlx
  • yzh119
  • bkryu

Poem

🐰 A whisker twitch, a list so small,
One-twenty, one-twenty-one—that's all!
SM121 joins the FP4 dance,
Compute power blooms with just one glance! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: extending b12x FP4 GEMM support to SM121, which aligns with the decorator update from [120] to [120, 121].
Description check ✅ Passed The description clearly explains the problem, solution, and affected devices (SM121/GB10/DGX Spark), but the PR checklist items (pre-commit, tests) remain unchecked and incomplete.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

@meena-at-work meena-at-work changed the title Fix: extend b12x FP4 GEMM support to SM121 (GB10/DGX Spark) Fix: Extend b12x FP4 GEMM support to SM121 (GB10/DGX Spark) Apr 18, 2026

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

4541-4569: ⚠️ Potential issue | 🟡 Minor

Extend the auto-selection heuristic to SM121 as well.

Line 4541 enables explicit backend="b12x" on SM121, but _heuristic_func_mm_fp4 still only prefers b12x when major == 12 and minor == 0. On SM121, backend="auto" will continue falling through to cudnn/cutlass even though b12x is now marked suitable.

Suggested follow-up
-    is_sm120 = major == 12 and minor == 0
+    is_sm12x = major == 12 and minor in (0, 1)

-    # SM120 + CUDA 13: prefer b12x (warp-level MMA, underfill tile selection)
-    if is_sm120 and use_nvfp4 and cuda_major >= 13:
+    # SM120/121 + CUDA 13: prefer b12x (warp-level MMA, underfill tile selection)
+    if is_sm12x and use_nvfp4 and cuda_major >= 13:
         return [c for c in ("b12x", "cutlass", "cudnn") if c in suitable_backends]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@flashinfer/gemm/gemm_base.py` around lines 4541 - 4569, The auto-selection
heuristic in _heuristic_func_mm_fp4 must be updated to treat SM121 the same as
SM120 so backend="auto" prefers b12x when _b12x_gemm_fp4_requirement is valid;
locate the conditional that currently checks for major == 12 and minor == 0 and
expand it to include minor == 1 (or check minor in {0,1} / minor <= 1) so SM121
is considered eligible for the b12x backend selection.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@flashinfer/gemm/gemm_base.py`:
- Around line 4541-4569: The auto-selection heuristic in _heuristic_func_mm_fp4
must be updated to treat SM121 the same as SM120 so backend="auto" prefers b12x
when _b12x_gemm_fp4_requirement is valid; locate the conditional that currently
checks for major == 12 and minor == 0 and expand it to include minor == 1 (or
check minor in {0,1} / minor <= 1) so SM121 is considered eligible for the b12x
backend selection.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 25b11123-e78f-40f7-9583-db1c35fd71b3

📥 Commits

Reviewing files that changed from the base of the PR and between 168bab5 and 70de56f.

📒 Files selected for processing (1)
  • flashinfer/gemm/gemm_base.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 expands FP4 GEMM support to include compute capability 121 (Blackwell) within the _b12x_gemm_fp4_requirement function. A review comment identifies that the heuristic selection logic in _heuristic_func_mm_fp4 needs a corresponding update to ensure SM 121 devices are correctly handled when the backend is set to "auto".



@supported_compute_capability([120])
@supported_compute_capability([120, 121])

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.

medium

While adding 121 to the supported compute capability list enables the b12x backend when explicitly requested, the heuristic function _heuristic_func_mm_fp4 (around line 5070) also needs to be updated to include SM121. Currently, it only checks for is_sm120 (major 12, minor 0), which means backend="auto" will not select b12x on SM121 devices even if CUDA 13+ is present. Consider updating the heuristic logic to use major == 12 or _match_sm_version(a.device, ["120", "121"]) to ensure consistent behavior across Blackwell variants.

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.

Auto not selecting b12x on SM121 devices is intentional at this point.

@bkryu bkryu added the run-ci label Apr 18, 2026
@bkryu

bkryu commented Apr 18, 2026

Copy link
Copy Markdown
Collaborator

/bot run

@flashinfer-bot

Copy link
Copy Markdown
Collaborator

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

@flashinfer-bot

Copy link
Copy Markdown
Collaborator

[FAILED] Pipeline #48833682: 13/20 passed

@bkryu
bkryu merged commit 06cb1b7 into flashinfer-ai:main Apr 20, 2026
65 of 93 checks passed
kahyunnam pushed a commit that referenced this pull request May 18, 2026
## 📌 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

- [x] I have installed `pre-commit` by running `pip install pre-commit`
(or used your preferred method).
  - [x] I have installed the hooks with `pre-commit install`.
- [x] 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.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

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

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

3 participants