Skip to content

[NVIDIA] Enable CuTe DSL BF16 GEMM on SM107 - #33617

Merged
Fridge003 merged 3 commits into
sgl-project:mainfrom
YAMY1234:yangmin/sm107-cutedsl-bf16-gemm
Aug 6, 2026
Merged

Fridge003 merged 3 commits into
sgl-project:mainfrom
YAMY1234:yangmin/sm107-cutedsl-bf16-gemm

Conversation

@YAMY1234

@YAMY1234 YAMY1234 commented Aug 4, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

The CuTe DSL BF16 GEMM backend is selected on SM10x GPUs, but both runtime entry points reject SM107. Enabling the architecture gate also exposes a bias conversion issue: DLPack rejects a bias view that retains requires_grad=True, even during inference under torch.no_grad().

Modifications

  • Allow SM107 in both CuTe DSL BF16 GEMM runtime entry points.
  • Detach the read-only bias view before exporting it through DLPack. This does not add a copy or synchronization.
  • Update backend diagnostics and CLI help to describe SM10x support.
  • Extend the existing kernel test with an SM107 workload shape and a requires_grad=True bias under torch.no_grad().

The GEMM kernel math, tactic selection, and launch behavior are unchanged.

Accuracy Tests

The existing numerical comparison test now covers the added shape and gradient-bearing bias case. Controlled SM107 validation passed for eager execution, CUDA Graph execution, and an end-to-end accuracy workload on the pinned development base.

Current upstream-main GPU CI is pending while this PR remains a draft.

Speed Tests and Profiling

Controlled end-to-end SM107 testing confirmed that enabling this backend removes the fallback to torch.nn.functional.linear. No kernel implementation or tactic was changed.

Current upstream-main performance confirmation is pending while this PR remains a draft.

Checklist

  • Format the code with pre-commit.
  • Extend the existing unit test.
  • Update user-facing backend documentation.
  • Complete GPU CI on current upstream main.
  • Add current-main performance confirmation.

Local Validation

  • pre-commit run --files passed for all four modified files.
  • git diff --check passed.
  • Python compilation passed for all four modified files.

CI States

Latest PR Test (Base): ❌ Run #31033970223
Latest PR Test (Extra): ❌ Run #31033969425

@github-actions github-actions Bot added quant LLM Quantization jit-kernel labels Aug 4, 2026
@YAMY1234
YAMY1234 force-pushed the yangmin/sm107-cutedsl-bf16-gemm branch from 6e431c6 to 6aa5e76 Compare August 5, 2026 00:49
weight: torch.Tensor,
bias: Optional[torch.Tensor],
) -> torch.Tensor:
if get_device_sm() not in (100, 103):

@b8zhong b8zhong Aug 5, 2026 •

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.

Can we just change is to is_sm100_supported?

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.

maybe is_sm10x_supported ? what is Supports 110 exactly?

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.

is_sm10x_supported would’ve been nice if there were no need to check different cuda versions, but since sm107 needs >= 13.4 while is_sm100_supported currently checks >= 12.8 (actually, sm103 needs >= 12.9), maybe for clarity rename it to is_sm100_or_sm103_supported and add is_sm107_supported

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.

@leejnau You can ignore the other part of my comment. Was typing something else on another tab or something..

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.

@mmangkad I don't think we really need to check the CUDA version. It should be correct already (@leejnau What do you think?)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks! I updated the PR to use is_sm100_supported() instead of explicitly checking for SM100/103/107.

BTW, Lee and I talked about it, and we don’t think we need a separate is_sm107_supported() for now. If we add features that are only SM107-specific later, we can add it then as a follow up

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.

Yeah maybe not for now, but at some point we'll probably have to distinguish them

@leejnau

leejnau commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

I tested Kimi K3 on sm107 and the cutedsl bf16 gemm works ✅

@YAMY1234

YAMY1234 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Aug 5, 2026
@b8zhong
b8zhong enabled auto-merge (squash) August 5, 2026 19:17
@Fridge003
Fridge003 disabled auto-merge August 6, 2026 09:06
@Fridge003
Fridge003 merged commit 8b29c90 into sgl-project:main Aug 6, 2026
249 of 281 checks passed
saturn-acc pushed a commit to saturn-acc/sglang that referenced this pull request Aug 16, 2026
@YAMY1234
YAMY1234 deleted the yangmin/sm107-cutedsl-bf16-gemm branch August 25, 2026 16:17
Atituiset pushed a commit to Atituiset/sglang that referenced this pull request Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jit-kernel quant LLM Quantization run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants