← Back to Pull requests

MUSA: serve DP+EP MoE on MCCL and add the MATE Mega MoE backend #325

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 06, 2026 16:44 UTC
Author

Why

Two gaps keep block-FP8 MoE models from serving with data-parallel attention and expert parallelism on MUSA.

DP+EP does not start. --data-parallel-size 8 --enable-expert-parallel with the default allgather_reducescatter all2all fails in three places, each hidden behind the previous one:

1. pynccl is disabled. find_nccl_library() raises on MUSA because torch.version.cuda and torch.version.hip are both None. Every PyNcclCommunicator therefore disables itself, and the profile run asserts in CudaCommunicator.all_gatherv.
2. The collectives escape the decode graph. MUSA captures on torch_musa's own capture stream. vLLM's current_stream() never sees that switch, because torch_musa calls torch_musa.set_stream rather than the patched torch.cuda.set_stream. pynccl therefore issues the all2all outside the graph, and startup hangs.
3. MCCL 2.30.4 hangs on a group of small collectives. There are two such groups:
- The dispatch all-gathers four tensors in one group.
- Uneven all_gatherv/reduce_scatterv group one broadcast or reduce per rank.

Mega MoE cannot be selected. MATE 0.2.8 ships Mega MoE (mate.mega_moe). It runs the dispatch, both FP8 expert GEMMs with SwiGLU, and the weighted combine in persistent kernels over an intranode symmetric buffer, but vllm-musa has no backend that uses it.

What

  • 0213 adds --moe-backend mate_mega_moe for block-FP8 MoE layers:

  • - It is bound to the passthrough all2all, the same self-dispatching contract as the FlashInfer MoE-EP backends.
    - It maps to Fp8MoeBackend.MATE_MEGA_MOE and keeps the loaded weight layout.
    - The experts repack the weights once the modular kernel is built.
  • vllm_musa/model_executor/layers/fused_moe/mate_mega_moe.py (MateMegaMoEExperts):

  • - Quantizes the activations straight into the symmetric buffer and repacks the weights with transform_weights_for_mega_moe.
    - Shares one buffer per shape across all MoE layers.
    - Takes MATE's decode or prefill kernels from the largest token count across data-parallel ranks, since both are collectives.
    - is_supported_config names what the kernels do not cover, so an unsupported shape is rejected at backend selection rather than aborting inside the symmetric-buffer setup. The limits are: more than 8 ranks, a hidden or intermediate size that is not a multiple of 256, intermediate above 8192, top-k above 32, a non-SwiGLU activation, bias, LoRA, EPLB, DBO, and redundant experts.
  • 0214 returns libmccl.so.2 from find_nccl_library() on MUSA. torchada resolves the ncclXxx lookups to MCCL's mcclXxx exports, which cover all 20 symbols pynccl loads.

  • 0215 wraps torch_musa.set_stream on the first current_stream() call on MUSA, so current_stream() follows every stream switch.

  • 0216 keeps the all2all collectives out of MCCL groups on MUSA:

  • - A batched all_gatherv packs the rows of its tensors (hidden states, top-k weights, top-k ids, block scales) into one byte matrix and gathers it with one all-gather. The dispatch costs one collective per MoE layer instead of four.
    - Uneven all_gatherv/reduce_scatterv run as one all_gather/reduce_scatter over rows padded to the largest size.
  • Tests:

  • - Mega MoE: limits (including 1408), DP-consistent path choice, an idle rank, guards and supported schemes.
    - pynccl: MCCL library choice and symbol coverage, stream tracking, padded row offsets, and the packed gather round trip (fp8, fp32 and int32 tensors, uneven and empty ranks).
    - A source contract for each series entry.
  • Series bookkeeping: the series length goes to 216. 0213 joins moe, 0214 and 0216 join distributed, and 0215 joins compilation.
  • Evidence

    Setup:

  • Isolated 8× MTT S5000 node (driver 5.2.0-server, mpx28); every run below shares one lease unless noted.

  • Image v0.32.0-ph1-5.2.0-torch2.11.0.post2-20261106 (sha256:65d5e96b5027c796494a7ad6597c6267953d60b96e2436c344760b243c346bc1), MCCL 2.30.4, MATE 0.2.8.post1.

  • Model: Qwen3-30B-A3B-FP8 unless noted.
  • All servers use --max-model-len 4096 --max-num-batched-tokens 4096 --gpu-memory-utilization 0.85 --no-enable-prefix-caching --compilation-config '{"mode":"NONE","cudagraph_mode":"FULL_DECODE_ONLY"}'. On top of that:

  • TP8+EP8: --tensor-parallel-size 8 --enable-expert-parallel --max-num-seqs 128.

  • DP8+EP8: --data-parallel-size 8 --enable-expert-parallel --max-num-seqs 64.

  • Mega MoE: the DP8+EP8 flags plus --moe-backend mate_mega_moe.
  • The load is vllm bench serve on random 1024 in / 512 out with --ignore-eos and 4×c prompts, measured after a warm-up pass that sends the same requests, so first-use Triton compiles stay out of the measured pass. Output tok/s, mean TPOT in ms:

    | c | TP8+EP8 | DP8+EP8 | Mega MoE |
    |---|---|---|---|
    | 1 | 71.8 (13.70) | 57.0 (17.15) | 83.9 (11.67) |
    | 8 | 523.2 (14.66) | 376.9 (20.55) | 554.0 (14.00) |
    | 64 | 2606.1 (23.25) | 2314.3 (25.59) | 3387.2 (17.74) |
    | 128 | 4076.9 (29.41) | 4198.8 (27.13) | 5891.0 (19.86) |

  • Without the series, DP8+EP8 does not start: it asserts in all_gatherv during the profile run.

  • The packed dispatch gather against one all-gather per tensor, same warm-up, raises DP8+EP8 from 46.0 to 56.9 tok/s at c=1 and from 314.5 to 359.9 at c=8. In a decode profile at c=1, the slowest rank's collective time drops from 11.63 to 4.52 ms per step.

  • Mega MoE against DP8+EP8, the same attention layout: +47%, +47%, +46% and +40% at c=1, 8, 64 and 128. Against TP8+EP8: +17%, +6%, +30% and +44%.

  • TP8+EP8 issues no all_gatherv or reduce_scatterv; in an earlier lease on the same image it stayed within 1% of the unmodified tree.

  • GSM8K, full 1319 questions, greedy, thinking off: DP8+EP8 0.9325 (1230). From the earlier lease, before the packed gather (neither routes through it): TP8+EP8 0.9325 (1230), Mega MoE 0.9287 (1225), unmodified TP8+EP8 0.9303 (1227).
  • Other models, with the series (warm-up pass of c requests):

    | Model | Config | Output tok/s at c=1 / 8 / 64 | GSM8K |
    |---|---|---|---|
    | DeepSeek-V2-Lite-Chat (BF16, MLA) | TP8+EP8 | 75.0 / 457.8 / 2317.3 | 0.6694 |
    | DeepSeek-V2-Lite-Chat (BF16, MLA) | DP8+EP8 | 61.7 / 391.5 / 2279.7 | 0.6573 |
    | Qwen3-Next-80B-A3B-Instruct (BF16) | TP8+EP8 | 41.9 / 282.6 / 1499.6 | 0.9507 |
    | Qwen3-Next-80B-A3B-Instruct (BF16) | DP8+EP8 | 32.8 / 124.9 / 925.9 | 0.9447 |

    Qwen3-Next DP8+EP8 at c=8 and c=64 still includes first-use compiles (TTFT p99 47.5 s at c=64).

    Qwen3.8-Flash-Next-FP8 with --moe-backend mate_mega_moe stops at startup with MATE_MEGA_MOE does not support the deployment configuration since kernel does not support intermediate size 640 not divisible by 256. The model does not start on MUSA in any configuration (Qwen4Exp QSA requires FlashAttention).

    Isolated checks, on 8 ranks:

  • pynccl: On the unmodified tree it is disabled on every rank. With the series, 16 of 16 checks pass, including a captured all_reduce + all_gatherv + reduce_scatterv graph replayed with fresh inputs.

  • Graph capture: I captured pynccl all_gatherv, a Triton kernel and reduce_scatterv the way vLLM does on MUSA. Without 0215 the replay returns wrong results; with it the results are correct.

  • MCCL groups: A standalone C program against libmccl.so.2 (no vLLM or PyTorch) hangs on 2, 4 and 8 ranks when one mcclGroupStart/mcclGroupEnd holds an all-gather of at least 2 KB per rank and one of at most 1 KB per rank. It completes when every op is on the same side of that boundary or when the ops are issued without a group. No MCCL_PROTO, MCCL_ALGO, channel-count, MCCL_SYM_KERNEL or MCCL_RUNTIME_CONNECT setting avoids the hang.

  • Uneven sizes: One rank with 20 tokens and seven with 1 token. Without 0216 it hangs; with it, it passes.

  • Mega MoE kernel: MATE's own bench puts one decode MoE layer at 91.5 µs for 1 token per rank.
  • Validation:

  • check-series --replay against a pristine checkout at 5df63a72: 216 clean.

  • verify: 219 clean, 0 need attention.

  • pre-commit run --files on the change set.

  • pytest in the image: 197 passed. The one failure is test_cli_never_tracebacks_on_a_broken_entry_file[chmod-000-unreadable], which fails the same way on the unmodified image when run as root.
  • Not covered:

  • Pipeline parallelism. Single-node TP4×PP2 does not start on the unmodified image either, eager or with graphs and with custom all-reduce on or off, so it is out of scope here. send/recv through pynccl are checked only in the collectives test.

  • Runs across two nodes.

  • DeepEP. deepep_low_latency stops at startup with Buffer.__init__() got an unexpected keyword argument 'enable_shrink' (deep_ep 1.1.0+musa). deepep_high_throughput serves only without decode graphs. There it matches the default all2all, at a TPOT of 149 ms at c=8 for both, against 20.6 ms for DP8+EP8 with graphs.
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: yeahdongcn Review duration: 4012m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.57) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.57 · 650 lines diff across 8 files
    0.57
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #325"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 57% (MEDIUM) · Higher = larger blast radius
    57%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 30.4% · Safe to merge
    30.4%