Skip to content

[https://nvbugs/6212252][fix] Lift the SM list onto DeepGemmFusedMoE._SUPPORTED_SM_VERSIONS = {100, 103} and - #14704

Closed
tensorrt-cicd wants to merge 2 commits into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6212252
Closed

[https://nvbugs/6212252][fix] Lift the SM list onto DeepGemmFusedMoE._SUPPORTED_SM_VERSIONS = {100, 103} and#14704
tensorrt-cicd wants to merge 2 commits into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6212252

Conversation

@tensorrt-cicd

@tensorrt-cicd tensorrt-cicd commented May 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: get_moe_cls() unconditionally returns DeepGemmFusedMoE for backend='DEEPGEMM'; on H20 (SM90) the Blackwell-only DeepGEMM kernel runs anyway and asserts sfa_dtype == kFloat.
  • Fix: Lift the SM list onto DeepGemmFusedMoE._SUPPORTED_SM_VERSIONS = {100, 103} and add an SM check in create_moe.py's DEEPGEMM branch with fallback to CutlassFusedMoE (which supports FP8_BLOCK_SCALES on SM90), mirroring DENSEGEMM/CUTEDSL.
  • Automated fix generated by repair-bot

Test plan

  • Verify fix on the same GPU type as the original failure
  • Check for regressions in related tests

Links

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced Mixture of Experts (MoE) backend compatibility by validating GPU architecture versions during initialization.
    • Implemented automatic fallback to compatible alternatives when the optimized backend is unsupported on detected hardware.
    • Added warning notifications to inform users when hardware is incompatible with specialized implementations.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR centralizes SM version compatibility checking for the DeepGEMM MoE backend. It extracts the supported SM versions into a class constant and uses that constant both in backend-selection fallback logic and in the existing can_implement validation method.

Changes

DeepGEMM SM Compatibility Gating

Layer / File(s) Summary
SM support constant and validation
tensorrt_llm/_torch/modules/fused_moe/fused_moe_deepgemm.py
DeepGemmFusedMoE._SUPPORTED_SM_VERSIONS is declared as {100, 103}. The can_implement method is refactored to check the detected SM version against this constant and emit an updated warning message.
Backend selection with SM fallback
tensorrt_llm/_torch/modules/fused_moe/create_moe.py
get_moe_cls now queries the current SM version when selecting the DEEPGEMM backend; if unsupported, it logs a warning and falls back to CutlassFusedMoE.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • NVIDIA/TensorRT-LLM#14362: Both PRs update DeepGEMM Python-side SM compatibility gating to treat SM103 as supported in DeepGEMM-based MoE backend selection and validation.

Suggested reviewers

  • xxi-nv
  • yuxianq
  • mikeiovine
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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 describes the main change: lifting the SM list onto a class constant and adding SM compatibility checking in the DEEPGEMM backend, matching the actual code modifications.
Description check ✅ Passed The PR description includes root cause, solution details, test plan with checkmarks, and bug link, satisfying the template requirements despite missing some optional PR checklist items.
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

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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
tensorrt_llm/_torch/modules/fused_moe/fused_moe_deepgemm.py (1)

380-380: ⚡ Quick win

Use frozenset instead of set for immutable class constant.

_SUPPORTED_SM_VERSIONS is named as a constant but uses a mutable set. Replace with frozenset to enforce immutability and align with the constant naming convention.

🔒 Proposed fix
-    _SUPPORTED_SM_VERSIONS = {100, 103}
+    _SUPPORTED_SM_VERSIONS = frozenset({100, 103})

As per coding guidelines, Python constants should be immutable. The static analysis tool flagged this as RUF012 (mutable default value for class attribute).

🤖 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 `@tensorrt_llm/_torch/modules/fused_moe/fused_moe_deepgemm.py` at line 380,
Replace the mutable set assigned to the class constant _SUPPORTED_SM_VERSIONS
with an immutable frozenset to enforce immutability and follow constant naming
conventions; locate the declaration of _SUPPORTED_SM_VERSIONS in
fused_moe_deepgemm.py and change the RHS from {100, 103} to use frozenset({100,
103}) (or frozenset((100, 103))) so the constant cannot be mutated at runtime.
🤖 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 `@tensorrt_llm/_torch/modules/fused_moe/fused_moe_deepgemm.py`:
- Line 380: Replace the mutable set assigned to the class constant
_SUPPORTED_SM_VERSIONS with an immutable frozenset to enforce immutability and
follow constant naming conventions; locate the declaration of
_SUPPORTED_SM_VERSIONS in fused_moe_deepgemm.py and change the RHS from {100,
103} to use frozenset({100, 103}) (or frozenset((100, 103))) so the constant
cannot be mutated at runtime.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 04f18277-6509-4e14-ac9a-914fdb23b535

📥 Commits

Reviewing files that changed from the base of the PR and between da9db3a and 5ab45fe.

📒 Files selected for processing (2)
  • tensorrt_llm/_torch/modules/fused_moe/create_moe.py
  • tensorrt_llm/_torch/modules/fused_moe/fused_moe_deepgemm.py

@tensorrt-cicd
tensorrt-cicd force-pushed the repair-bot-bug6212252 branch 2 times, most recently from 9a2c217 to 149d1a3 Compare June 1, 2026 07:35
# kernel runs and trips a C++ scale-factor dtype assertion at warmup.
from tensorrt_llm._utils import get_sm_version
sm_version = get_sm_version()
if sm_version not in DeepGemmFusedMoE._SUPPORTED_SM_VERSIONS:

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.

Please add another constraint: only FP8_BLOCK QUANT on HOPPER is supported on CUTLASS.

@xxi-nv

xxi-nv commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Or a suggested way to fix is to specify the CUTLASS MOE backend in the test case instead of the fallback.

@tensorrt-cicd
tensorrt-cicd force-pushed the repair-bot-bug6212252 branch from 149d1a3 to 649aee8 Compare June 3, 2026 11:33
…nsupported on current SM

DeepGemmFusedMoE kernels only support SM100/SM103 (Blackwell), but when
explicitly requested via MoeConfig(backend='DEEPGEMM'), get_moe_cls()
returned it without checking SM compatibility. On Hopper (SM90) this caused
DeepGEMM to run anyway and trip a C++ assertion at autotuner warmup
(`sfa_dtype == torch::kFloat`).

Add an SM version check in the DEEPGEMM dispatch branch with graceful
fallback to CutlassFusedMoE (which supports FP8_BLOCK_SCALES on SM90),
matching the existing DENSEGEMM/CUTEDSL patterns. Lift the supported SM
list onto DeepGemmFusedMoE._SUPPORTED_SM_VERSIONS for reuse.

Signed-off-by: tensorrt-cicd <90828364+tensorrt-cicd@users.noreply.github.com>
@tensorrt-cicd
tensorrt-cicd force-pushed the repair-bot-bug6212252 branch from 649aee8 to 7a9d344 Compare June 5, 2026 22:57
@xxi-nv xxi-nv closed this Jun 8, 2026
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.

3 participants