Repository navigation
[https://nvbugs/6812424][fix] Enable CUTLASS MXFP8 MoE on SM107 - #19953
Conversation
|
/bot run --disable-fail-fast |
|
PR_Github #76677 [ run ] triggered by Bot. Commit: |
|
PR_Github #76677 [ run ] completed with state
|
|
Automatically added "ci: full pre-merge approved" because this PR has satisfied the required GitHub review approvals. Unresolved review conversations and other required checks remain independent merge requirements. |
412b368 to
dc03905
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #77230 [ run ] triggered by Bot. Commit: |
|
PR_Github #77230 [ run ] completed with state
|
dc03905 to
7d6e747
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #77381 [ run ] triggered by Bot. Commit: |
|
PR_Github #77381 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #77632 [ run ] triggered by Bot. Commit: |
|
PR_Github #77632 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #77956 [ run ] triggered by Bot. Commit: |
|
PR_Github #77956 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #78032 [ run ] triggered by Bot. Commit: |
|
PR_Github #78032 [ run ] completed with state
|
7d6e747 to
afcccd5
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #78340 [ run ] triggered by Bot. Commit: |
|
PR_Github #78340 [ run ] completed with state
|
Admit SM107 in the CUTLASS MXFP8 capability table. The existing SM100-family block-scaled kernels already cover SM107, but the Python SM allowlist rejected MiniMax-M3 before its weights could load. Update the MoE support matrix to include SM107. Validated on VR200 with eight existing MXFP8 backend numerical cases, a clean SM100/SM103/SM107 wheel build, and pre-commit checks. Signed-off-by: peaceh <[email protected]>
afcccd5 to
6505d9c
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #78862 [ run ] triggered by Bot. Commit: |
|
PR_Github #78862 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #79093 [ run ] triggered by Bot. Commit: |
|
PR_Github #79093 [ run ] completed with state |
…al identities CutlassFusedMoE was one 1161-line class serving eleven quantization formats, with a _QUANT_SUPPORT_TABLE interpreter deciding at runtime which of them the current problem was. Nothing in the type system said which format a given call would run, and the class was simultaneously three unrelated things: a technique identity, the CUTLASS family literal users write in YAML, and the resolver fallback that absorbed every format nobody else claimed. Replace it with a cutlass/ subpackage: an abstract CutlassFusedMoEBase plus one leaf per format, each declaring its own descriptor, SM support, dtypes, can_implement and quant method. The base takes the scheduler kind, capabilities and input requirement off the descriptor, so each has one source, and keeps the defaults most leaves run with: a pass-through quantize_input and a run_moe that issues torch.ops.trtllm.fused_moe with the leaf's FusedMoeOpFlags. A format whose kernel differs only in those flags declares them and nothing else; the leaves that differ further override the two methods. The table interpreter and the has_* branching in the base have no callers left and are gone. The one fused_moe call is the base's _run_fused_moe_op, kept apart from run_moe because it also takes what the run_moe contract does not carry: dequantized weights, a dynamic FC2 scale and LoRA operands. It and the activation quantizers more than one format uses sit in cutlass/base.py beside those defaults, and the eligibility predicates that replace the table live in cutlass/eligibility.py, which uses the identity gate shared with the other families. fused_moe_cutlass.py shrinks to an alias module, so CutlassFusedMoE keeps naming the family for every issubclass gate outside the package. fp8_block_scales becomes two leaves, because the one name covered two different kernels: SM90 runs a Hopper grouped GEMM and SM120 an internal Triton grouped GEMM, and neither is a CUTLASS kernel. They are named for what they run -- deepgemm.cuda.hopper_grouped_gemm.fp8_block_scales and trtllm.triton.grouped_gemm.fp8_block_scales -- but both stay in BACKEND_FAMILY[CUTLASS]. That is deliberate: the family literal is what users write in checked-in configs (31 H200 configs pin moe_backend: CUTLASS for fp8_block_scales), and AUTO reaches the same code path, so moving them out would break both. Migrating the SM90 leaf to the DEEPGEMM family is a follow-up. FALLBACK_IMPL likewise had to be redefined: it named the widest- coverage class, which after the split is only an abstract base, so it becomes FALLBACK_IMPLS over the leaves. With that many fallbacks, MoEResolutionReport.degraded_from reports the requested implementations' rejection -- the highest-priority one that declined for a reason other than the format or the SM -- rather than whichever fallback leaf declined last. On SM100 the SM120-only b12x leaves lead the CUTEDSL family, and their SM rejection would otherwise stand in for CuteDslFusedMoE's. The SM120 Triton leaf declares only what its kernel runs, SwiGLU and GeGLU without activation constants, and does not take the alltoall output workspace, because its run_moe returns the kernel's own tensor. The open-source-kernel checks (NVIDIA#19753) and SM107 MXFP8 (NVIDIA#19953), which landed on the old class, move into the same declarations. One family gate, eligibility.check_oss_cutlass_build, runs in every leaf after its support gates, so a format or SM mismatch is never blamed on the build. A leaf sets requires_oss_cutlass_build when the bundled internal kernel archive has no kernel for its format (MXFP8, W4A8_MXFP4_MXFP8, W4A16_MXFP4, W4A8_AWQ), and uses_dynamic_fc2_scale when its run_moe hands the op a dynamic FC2 scale (NVFP4). Because the latter is the leaf's declaration rather than a QuantAlgo.NVFP4 comparison, it also covers the NVFP4_AWQ and NVFP4_ARC checkpoints that leaf serves. supports_alltoall and validate_configurable_moe sit on CutlassFusedMoEBase. The B12x NVFP4 leaf, the only one that routes prefill through CUTLASS, declares _prefill_uses_cutlass and runs the same gate, so _route_to_cutlass stays a shape predicate. A leaf is fixed when the layer is built, so the model must pass the layer's final quantization -- its quant_config_dict entry and any exclude_modules match -- to create_moe as override_quant_config. modeling_utils.moe_experts_quant_config does that lookup with the same match apply_layerwise_quant_config uses, so the two agree whenever the model passes the experts' name as __post_init__ sees it; Qwen3MoE and NemotronHMOE call it, so a MIXED_PRECISION checkpoint such as Qwen3-30B-A3B W4A8 builds on the W4A8_AWQ leaf. This is a behavior change for CUTLASS: the old class re-derived its quant method from whatever quant_config the layer ended up with after __post_init__, while a leaf cannot. The leaves now refuse a layer whose format moved, in create_weights, through impl_contract.require_layer_quant_format, which is the check TRTLLM-Gen already ran, hoisted so both families share one definition. ConfigurableMoE now copies the model config shallowly for an override, because Qwen3MoE passes one for every layer and a deep copy cloned the whole per-weight quant_config_dict each time. The B12x backend is split the same way, because it reached MoEImplBase through CutlassFusedMoE and called its methods unbound -- calls that stop existing once run_moe sinks. Its two formats do not share an execution path: NVFP4 routes prefill chunks to the CUTLASS NVFP4 grouped GEMM and decode to b12x, while W4A16_NVFP4 never leaves the b12x kernel. So CuteDslB12xNvfp4FusedMoE inherits the CUTLASS NVFP4 leaf on purpose and CuteDslB12xW4a16Nvfp4FusedMoE deliberately does not; it keeps CutlassFusedMoEBase only for construction, while its weight lifecycle comes from MoEWeightOwnerMixin as for every implementation. What they share -- the gates, the format check, the quant method and the decode call -- sits in CuteDslB12xFusedMoEBase, a mixin because the leaves differ in exactly which CUTLASS ancestor they carry; the old name aliases it so external issubclass gates still match both. Both leaves consume the FC1 buffer the CUTLASS NVFP4 weight pipeline padded, so the shared gate runs the FC1 row-alignment check for both formats. Giving the pair its own identity belongs to the CuteDSL item; until then neither leaf publishes a descriptor, so the NVFP4 one cannot read as its CUTLASS parent. Routed-expert MoE LoRA moves to CutlassMoELoraMixin. It is fused into torch.ops.trtllm.fused_moe for unquantized and per-tensor-FP8 weights only, yet its ~320 lines sat in the base where the other ten leaves inherited machinery they can never reach. _run_fused_moe_op takes the LoRA operands as an explicit lora_kwargs argument, which only the mixin's run_moe passes, so no other leaf depends on the mixin. The leaves that never set the LoRA state are already handled by the readers outside the package, which probe with getattr rather than assume. The CUDA-graph workspace reservation builds its FusedMoeRunner key from the leaf's FusedMoeOpFlags and a leaf-declared input dtype, the same inputs _run_fused_moe_op hands the op. Four existing bugs surfaced once each format had one leaf, and are fixed: - The SM120 Triton leaf compared global slot ids against the local expert count under alltoall, so every rank but the first computed no expert output and -1 padding counted as local. It now localizes by slot_start on every path. - The b12x NVFP4 decode path dropped an NVFP4_AWQ checkpoint's pre-quant scale, which the CUTLASS prefill path applies. Decode now applies it too. - ConfigurableMoE did not expose the backend's _moe_lora_enabled, so the torch.compile MoE LoRA guard in MoE.forward never fired for a wrapped backend. It now forwards the backend's state. - The FC1 row-alignment gate covered NVFP4 only, but W4A16_NVFP4 weights go through the same loader, which pads the fused gate/up buffer at the bottom; an unaligned shard (intermediate_size 768 at moe_tp_size 8) split gate/up on the wrong row. The CUTLASS and B12x W4A16_NVFP4 leaves now decline it. Step3p7MoE no longer asks the backend for its routed SwiGLU clamp when its Python experts own the layer: the backend never runs those experts, and the clamp kept the SM120 FP8 block-scale leaf, which takes no clamp, from holding the weights the Python path dequantizes. Callers that pinned the class follow the same rule: modeling_llama_min_latency picks its leaf by format via cutlass_leaf, which names the registered formats when none serves, and the bench_moe backend lookup returns leaves the way moe_test_utils does. bench_moe_comm only calls quantize_input, which the two fp8_block_scales leaves share, so it takes the first leaf of the format in resolution order; its deepseek_v3 profile keeps running on every SM. The Nemotron-H VL EPLB test likewise pins the W4A16_NVFP4 leaf. Tests: moe_test_utils maps CUTLASS to the leaf find_cutlass_leaf returns, and test_moe_impl.py checks that every family member, the twelve CUTLASS leaves included, is what the registry returns for the identity it publishes, that the CUTLASS literal picks a leaf by format and, for fp8_block_scales, by SM, that a TRTLLM-Gen leaf, a CUTLASS leaf and both B12x leaves refuse a layer whose format moved, and that a CUTEDSL request degraded on SM100 reports CuteDslFusedMoE's rejection. The build-mode tests keep their names and check the leaf that serves each format, and test_cutlass_leaf_declarations also pins each leaf's build declarations. test_moe_backend.py drives run_moe on CPU, with the op replaced, for every leaf that calls torch.ops.trtllm.fused_moe, the W4A16 NVFP4 leaf's dequantized path included; it and the b12x backend test cover the fixes above. test_qwen3_next_moe_quant.py expects the leaf a CUTLASS resolution returns rather than the family name. Pure-CPU tests that no CI list ran are marked cpu_only. MOE_DEVELOPER_GUIDE.md follows the new layout: a file map for the cutlass/ leaves and a section on why a layer's format is fixed when it is built. The trtllm-moe-develop skill stops restating the guide, which it already requires reading, and keeps what the guide does not carry: the workflow (required context, guide-update checklist, design gate, review template, test selection), an owner-boundary table, which selection rules a test or import-time check enforces and which only review catches, the imported-kernel ABI checklist, and the EPLB CPU staging and communication checkpointing details. Its reference keeps only code pointers, and the one fact only the skill stated -- an impl_id pin is a resolve_moe_impl argument alone -- moves into the guide. Not in this change, and recorded for the follow-ups: resolve_moe_backend preference rules, the 31 H200 configs, and the family migration of the SM90 leaf. Signed-off-by: xxi <[email protected]>
Admit SM107 in the CUTLASS MXFP8 capability table. The existing SM100-family block-scaled kernels already cover SM107, but the Python SM allowlist rejected MiniMax-M3 before its weights could load.
Update the MoE support matrix to include SM107.
Validated on VR200 with eight existing MXFP8 backend numerical cases, a clean SM100/SM103/SM107 wheel build, and pre-commit checks.
Dev Engineer Review
CutlassFusedMoEnow includes SM107 in theQuantAlgo.MXFP8architecture allowlist. The developer guide now documents the same support. This permits MXFP8 MoE construction and weight loading on SM107; the change relies on existing SM100-family kernels. The commit reports validation with eight existing numerical cases, wheel builds for SM100/SM103/SM107, and pre-commit checks. Test results were not independently verified.QA Engineer Review
No test changes.
Per-File QA Perspective
tensorrt_llm/_torch/moe/fused_moe/MOE_DEVELOPER_GUIDE.md: The CUTLASS W8A8 MXFP8 support matrix now includes SM107. Verify the documented architecture support matches runtime behavior.tensorrt_llm/_torch/moe/fused_moe/fused_moe_cutlass.py: The MXFP8 architecture constraint now includes SM107. Verify MXFP8 MoE construction, weight loading, and execution on SM107.Description
Test Coverage
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.