mimo26-marlin-skip-zero-fill.diff 951 B

12345678910111213141516
  1. diff --git a/python/sglang/srt/layers/moe/fused_moe_triton/fused_marlin_moe.py b/python/sglang/srt/layers/moe/fused_moe_triton/fused_marlin_moe.py
  2. index 7f76b2616e..9e8b7df1c1 100644
  3. --- a/python/sglang/srt/layers/moe/fused_moe_triton/fused_marlin_moe.py
  4. +++ b/python/sglang/srt/layers/moe/fused_moe_triton/fused_marlin_moe.py
  5. @@ -287,7 +287,10 @@ def fused_marlin_moe(
  6. dtype=hidden_states.dtype,
  7. )
  8. # Marlin skips masked expert rows, so their shared cache must start at zero.
  9. - intermediate_cache13 = torch.zeros(
  10. + # Without an expert map every (token, expert) row is local and written by
  11. + # both GEMMs, so the ~M*topk*K zero-fill (0.8 GB per MoE layer for an
  12. + # 8K-token MiMo prefill chunk) is skipped.
  13. + intermediate_cache13 = (torch.zeros if expert_map is not None else torch.empty)(
  14. (M * topk_ids.shape[1] * max(gemm1_n, K),),
  15. device=hidden_states.device,
  16. dtype=hidden_states.dtype,