feat: fuse shared experts for MiniMax2 trtllm-gen MoE routing#2
Open
zyongye wants to merge 1 commit into
Open
Conversation
Extend the trtllm-gen fused-MoE shared-expert support to the routingCustom path (MiniMax2 / sigmoid+bias routing), so shared experts can be appended as always-routed experts inside the routing kernel for models like MiniMax-M3, in addition to the DeepSeekV3 path. - routing_custom.cu / RoutingCustomPolicy.cuh: emit fused shared-expert slots (id = num_experts + k, weight 1.0) and widen the expert/topK totals in the block-scores + permutation pipeline. - runner.cu: thread num_fused_shared_experts through the MiniMax2 and DeepSeekV3 (no-groups) routing branches. - core.py / api.py: expose num_fused_shared_experts on the FP8 block-scale entry points. - kernel_launcher.cu: size per-expert gemm1 activation params (alpha/beta/clamp) to local_num_experts + num_fused_shared_experts so SwiGLU-OAI experts work alongside fused shared experts. - tests: cover fused shared experts for the custom routing path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
zyongye
marked this pull request as ready for review
July 13, 2026 20:33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
1.0while preservingrouted_scaling_factorfor routed expertsMotivation
MiniMax M2/M3 uses sigmoid routing with routing bias, while the existing shared-expert fusion path only covered DeepSeekV3 routing. As a result, MiniMax models could not place their shared expert in the fused trtllm-gen MoE weight tensors and route it in the same kernel.
Impact
Callers can pass
num_fused_shared_experts=1withRoutingMethodType.MiniMax2. Routed expert weights continue to use the configuredrouted_scaling_factor; each shared expert is appended after the routed experts and receives weight1.0.Validation
pytest -x -q tests/moe/test_trtllm_gen_fused_moe.py -k MiniMaxM3: 4 passed, 10007 deselectedrouted_scaling_factor=2.5on NVIDIA GB300 / SM103