Skip to content

feat: fuse shared experts for MiniMax2 trtllm-gen MoE routing#2

Open
zyongye wants to merge 1 commit into
liuzijing2014:build-main-pr3737from
zyongye:feat/fuse-shared-experts-trtllm-moe
Open

feat: fuse shared experts for MiniMax2 trtllm-gen MoE routing#2
zyongye wants to merge 1 commit into
liuzijing2014:build-main-pr3737from
zyongye:feat/fuse-shared-experts-trtllm-moe

Conversation

@zyongye

@zyongye zyongye commented Jul 13, 2026

Copy link
Copy Markdown

Summary

  • extend trtllm-gen fused shared-expert routing to the MiniMax2 sigmoid-plus-bias path
  • append shared experts as always-routed experts with weight 1.0 while preserving routed_scaling_factor for routed experts
  • size routing, permutation, and per-expert activation metadata for routed plus shared experts
  • add MiniMax M3 coverage with 128 routed experts, top-k 4, and one fused shared expert

Motivation

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=1 with RoutingMethodType.MiniMax2. Routed expert weights continue to use the configured routed_scaling_factor; each shared expert is appended after the routed experts and receives weight 1.0.

Validation

  • pytest -x -q tests/moe/test_trtllm_gen_fused_moe.py -k MiniMaxM3: 4 passed, 10007 deselected
  • tested routed_scaling_factor=2.5 on NVIDIA GB300 / SM103
  • pre-commit checks for affected files passed

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
zyongye marked this pull request as ready for review July 13, 2026 20:33
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.

1 participant