-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[None][feat] Ungate fused MoE for SM120/SM121 (GB10/DGX Spark) #11997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -250,12 +250,12 @@ def resolve_moe_backend(moe_backend: str, architecture: str) -> str: | |||||||||||||||||||||||||||
| if architecture == "GptOssForCausalLM": | ||||||||||||||||||||||||||||
| sm_version = get_sm_version() | ||||||||||||||||||||||||||||
| # Select the best performing backend based on SM version | ||||||||||||||||||||||||||||
| if 100 <= sm_version < 120: # Blackwell | ||||||||||||||||||||||||||||
| if 100 <= sm_version < 120 or sm_version in (120, 121): # Blackwell | ||||||||||||||||||||||||||||
| return "TRTLLM" | ||||||||||||||||||||||||||||
| elif 90 <= sm_version < 100: # Hopper | ||||||||||||||||||||||||||||
| return "TRITON" | ||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||
| return "CUTLASS" # Fallback to CUTLASS for other SM versions (e.g., SM120) | ||||||||||||||||||||||||||||
| return "CUTLASS" # Fallback for other SM versions | ||||||||||||||||||||||||||||
|
Comment on lines
+253
to
+258
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't auto-route every Line 253 treats any ♻️ Proposed fix- if 100 <= sm_version < 120 or sm_version in (120, 121): # Blackwell
+ if sm_version in (100, 103, 120, 121): # Blackwell
return "TRTLLM"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The proposed fix looks reasonable to me, could you apply the fix?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🧠 Learnings used💡 Use
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead, using
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Here's the updated plan:
🧠 Learnings used💡 Use |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| return "CUTLASS" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ | |
| import torch | ||
| import torch.nn.functional as F | ||
|
|
||
| from tensorrt_llm._utils import get_sm_version, is_sm_100f | ||
| from tensorrt_llm._utils import get_sm_version, is_blackwell, is_sm_100f | ||
| from tensorrt_llm.models.modeling_utils import QuantAlgo | ||
|
|
||
| from ...autotuner import (AutoTuner, ConstraintSpec, DynamicTensorSpec, | ||
|
|
@@ -62,8 +62,8 @@ def cute_dsl_fp8_group_blockwise_gemm_ref( | |
| a_tmp = a.as_strided((m, k, 1), (k, 1, m * k)) | ||
| b_tmp = b.permute(1, 2, 0) | ||
|
|
||
| # Note: we have different output scale shape for fp8_quantize_1x128, so we need to handle it differently for sm100 and other archs. | ||
| if is_sm_100f(): | ||
| # Note: we have different output scale shape for fp8_quantize_1x128, so we need to handle it differently for Blackwell and other archs. | ||
| if is_blackwell(): | ||
| input_scale_tmp = a_sf.permute(1, 0).as_strided((m, w_k, 1), | ||
| (1, m, m * w_k)) | ||
| else: | ||
|
|
@@ -339,7 +339,7 @@ def can_implement( | |
| Check if CuteDslFusedMoE can implement the given quantization algorithm. | ||
|
|
||
| CuteDslFusedMoE supports: | ||
| - NVFP4: SM in {100, 103} | ||
| - NVFP4: SM in {100, 103, 120, 121} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you tested it locally? @syuoni It seems that we don't have the kernel to support SM120, right?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, sm120 is not supported. This PR doesn't add new kernels, so I would expect crash on sm120 GPUs. |
||
|
|
||
| Does NOT support unquantized mode. Output dtype is hardcoded to bfloat16. | ||
| Does NOT support swiglu_gptoss_style (bias/swiglu with custom alpha/beta/limit). | ||
|
|
@@ -381,11 +381,12 @@ def can_implement( | |
| "CuteDslFusedMoE does not support swiglu_gptoss_style (bias/swiglu with custom alpha/beta/limit)" | ||
| ) | ||
|
|
||
| # NVFP4 - SM in {100, 103} | ||
| # NVFP4 - SM in {100, 103, 120, 121} (Blackwell family) | ||
| if quant_algo == QuantAlgo.NVFP4: | ||
| if sm_version not in {100, 103}: | ||
| if sm_version not in {100, 103, 120, 121}: | ||
| return _warn_and_return( | ||
| f"NVFP4 requires SM100 or SM103, got SM{sm_version}") | ||
| f"NVFP4 requires Blackwell (SM100/103/120/121), got SM{sm_version}" | ||
| ) | ||
| return True, None | ||
|
|
||
| return _warn_and_return( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,7 +60,7 @@ class TRTLLMGenFusedMoE(MoE): | |
| aux_stream_dict (Optional[Dict[AuxStreamType, torch.cuda.Stream]]): Auxiliary CUDA streams for overlapping. | ||
|
|
||
| MoE torch custom op: | ||
| Only support min-latency mode now (SM100 Blackwell only). | ||
| Only support min-latency mode now (Blackwell: SM100/103/120/121). | ||
| Quant: fp8 block scales quant and nvfp4 quant and w4a16_mxfp4 quant | ||
| FusedMoE Op: routing(topK, etc.) + scatter + gemm1 + swiglu + gemm2 + finalize MoeRoute | ||
|
|
||
|
|
@@ -105,7 +105,7 @@ def can_implement( | |
| """ | ||
| Check if TRTLLMGenFusedMoE can implement the given quantization algorithm. | ||
|
|
||
| TRTLLMGenFusedMoE only supports SM in {100, 103} and the following quantizations: | ||
| TRTLLMGenFusedMoE only supports SM in {100, 103, 120, 121} and the following quantizations: | ||
| - NVFP4 | ||
| - FP8_BLOCK_SCALES | ||
| - W4A8_NVFP4_FP8 | ||
|
|
@@ -129,10 +129,10 @@ def can_implement( | |
|
|
||
| sm_version = get_sm_version() | ||
|
|
||
| # TRTLLMGenFusedMoE requires SM in {100, 103} | ||
| if sm_version not in {100, 103}: | ||
| # TRTLLMGenFusedMoE requires SM in {100, 103, 120, 121} (Blackwell family) | ||
| if sm_version not in {100, 103, 120, 121}: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TRTLLM-GEN can not support sm120, @nekorobov please help to confirm.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirm |
||
| return _warn_and_return( | ||
| f"TRTLLMGenFusedMoE requires SM100 or SM103, got SM{sm_version}" | ||
| f"TRTLLMGenFusedMoE requires Blackwell (SM100/103/120/121), got SM{sm_version}" | ||
| ) | ||
|
|
||
| # Check dtype_activation: only bfloat16 is supported | ||
|
|
@@ -201,11 +201,6 @@ def __init__( | |
| activation_type=activation_type, | ||
| ) | ||
|
|
||
| sm_version = get_sm_version() | ||
| if sm_version >= 120: | ||
| raise NotImplementedError( | ||
| "TRTLLMGenFusedMoE does not support SM120 and above.") | ||
|
|
||
| assert not self.smart_router, "Smart router is not supported in TRTLLMGenFusedMoE." | ||
|
|
||
| # Note: Load balancer initialization is handled by base class _init_load_balancer() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately TRTLLM MOE backend doesn't support sm120/121.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@syuoni Could you help to confirm whether the cuteDSL supports sm120/121? I don't think we have supported it,