Fix MiniMax-M3 allreduce fusion correctness#40
Conversation
|
B200 follow-up validation for PR #40 ( Setup:
Correctness, full GSM8K finish-reason tally:
This is close to the target, but not 0-runaway: 3 full-GSM8K requests hit Perf workload:
Perf artifacts:
Averages:
Delta, fusion ON vs native baseline:
So on this B200/MSA setup, PR #40 preserves near-complete stop behavior but does not show a perf win for FlashInfer AR fusion; native allreduce is faster in the measured workload. |
|
Follow-up sparse full-fusion investigation conclusion: keep PR #40 dense-only. The attempt to recover full AR-fusion speed by also deferring the 57 sparse-MoE layers is blocked with the current FlashInfer TRTLLM fused AR+GemmaNorm kernel. The root cause is not another SGLang integration knob: the fused kernel's residual path diverges from the native all-reduce + GemmaRMSNorm path even when fed the identical input tensor. Evidence from the B200 full-forward fused-vs-native trace:
Dense layers tolerate the same class of fused-vs-native bf16 residual differences, which is why PR #40 works. Sparse MoE does not: the residual feeds the sparse MoE/router path, and that path is bf16-residual-sensitive enough that the fused-kernel delta propagates into runaway generation. Also ruled out:
This makes full sparse-MoE fusion an upstream FlashInfer kernel correctness problem, not an SGLang forward-contract fix. The safe ceiling for this PR is the dense-only behavior: defer/fuse the dense MLP layers, keep sparse MoE all-reduced immediately. This also matches vLLM's MiniMax-M3 implementation in vllm-project/vllm#45381: the decoder sets input-allreduce fusion only when the previous layer is not MoE ( Validated PR #40 ceiling:
Conclusion: PR #40 should stay dense-only. Full sparse-MoE AR fusion should be revisited only after FlashInfer TRTLLM fused AR+GemmaNorm can match native residual math for these MiniMax-M3 sparse-MoE tensors. |
Summary
Enable FlashInfer TRTLLM allreduce fusion by default for MiniMax-M3 while preserving generation correctness.
Root cause:
LayerCommunicatorpath.Changes:
use_attn_tp_groupcorrectly fromGemmaRMSNorm.forward_with_allreduce_fusion.MiniMaxM3SparseForCausalLMandMiniMaxM3SparseForConditionalGenerationto the FlashInfer allreduce-fusion auto-enable allowlist.Correctness
H200 TP8, MiniMax-M3, FlashInfer AR fusion ON.
GSM8K stop-rate validation, no CUDA graph:
/scratch/ar-dense-only-val/smoke100.jsonl.summary.jsonn_total=100,n_ok=100,n_err=0stop_rate_pct=100.0runaway_rate_pct=0.0ct_p50=223,ct_p99=599,ct_max=650gsm8k_acc_pct=96.0GSM8K stop-rate validation, CUDA graph enabled:
/scratch/ar-dense-only-graph-val/smoke100.jsonl.summary.jsonn_total=100,n_ok=100,n_err=0stop_rate_pct=100.0runaway_rate_pct=0.0ct_p50=226,ct_p99=656,ct_max=756gsm8k_acc_pct=95.0The validation criterion here is
finish_reason=stop/ stop-rate, not GSM8K accuracy alone.Performance
H200 TP8, CUDA graph enabled, SGLang
bench_serving, random workload:--random-input-len 1024--random-output-len 512--num-prompts 128--max-concurrency 32Fusion ON artifact:
/scratch/ar-fusion-perf/fusion_on/bench.jsonlAuto-enabling FlashInfer AllReduce Fusion on SM90/SM10X for MiniMaxM3SparseForConditionalGenerationNative baseline artifact:
/scratch/ar-fusion-perf/native_baseline/bench.jsonl--enforce-disable-flashinfer-allreduce-fusionDelta, fusion ON vs native:
-12.00 tok/s(-1.17%)+0.30 ms(+1.02%)+0.23 ms(+0.79%)This is neutral/slightly negative on H200, where MiniMax-M3 is still on the Triton MoE fallback. The larger AR-fusion gain is expected on B200/MSA and is intentionally left as follow-up.
Checks
python3 -m py_compile python/sglang/srt/layers/layernorm.py python/sglang/srt/models/minimax_m3.py python/sglang/srt/server_args.pypre-commit run --files python/sglang/srt/layers/layernorm.py python/sglang/srt/models/minimax_m3.py python/sglang/srt/server_args.pyFollow-up