← Back to Pull requests

perf(musa): support folded E=257 Qwen3.5 BF16 MoE prefill and skip dead warmup #378

Closed
unknown closed this pull request without merging on Dec 01, 2026 00:44 UTC
View on GitHub
unknown unknown commented on Nov 27, 2026 08:12 UTC
Author

Summary

Implements P0-C from the S5000 v0.32.0-dev optimization roadmap (MUSA-100113):

1. Match folded E=257, top_k=9 TP=4 Qwen3.5/3.6-35B-A3B BF16 prefill shapes in matches_qwen35_moe_bf16_prefill_layer (vllm_musa/optimization_contract/qwen.py):
- OptimizationFeature.QWEN35_SHARED_EXPERT_FOLD is enabled by default on Qwen3.5/3.6 MoE models, folding the shared expert into w13_weight / w2_weight (E=256 -> 257, runtime topk_ids.shape[1]=9, global_num_experts=257).
- While matches_qwen35_moe_bf16_decode_gemv_layer already accepted both folded (257, 9) and unfolded (256, 8) TP=4 shapes, matches_qwen35_moe_bf16_prefill_layer still hardcoded (256, 8). Consequently, prefer_upstream_qwen_prefill was False in production on default folded Qwen3.5-35B-A3B / Qwen3.6-35B-A3B TP=4 BF16, sending >= 1024-token prefill batches into _maybe_moe_deepgemm_bf16_prefill instead of the faster calibrated Triton MoE path.
2. Fix _warmup_bf16_grouped_moe for folded MoE layers & skip dead DeepGEMM precompilation (vllm_musa/model_executor/warmup/deep_gemm_warmup.py):
- When _fold_shared_expert_weights folds the shared expert (_musa_shared_folded=True), module.top_k (8) and module.global_num_experts (256) on FusedMoE still hold the routed-only counts until forward_oot extends them to (9, 257). Added _effective_moe_routing_counts so folded layers resolve (9, 257) (max_grouped_tokens=106368 instead of the wrong 98176 on TP=1/TP=2!).
- Added _module_prefers_upstream_qwen_bf16_prefill (handling MoEActivation.SILU enums) so TP=4 (256|257, 256, 2048) layers that route to upstream Triton skip 10.05 s of dead deep_gemm.m_grouped_bf16_gemm_nt_contiguous startup compilation.

Validation Evidence

Environment


  • Base commit: origin/v0.32.0-dev (ae29e343865b6a9f0cd8dc9e4cb45904bd1553ec)

  • Candidate commit: bd91be25d24937573eda2974e1ca3ed024545738

  • Container image: sh-harbor.mthreads.com/mcctest/vllm:v0.32.0-ph1-5.2.0-torch2.13.0.post1-20261126@sha256:57c32bbbdbd9d539b2b8e8b46f0b132252d36e4646e2d8a452dde0fa84e471af

  • Hardware: 10.20.37.14 (worker37014), 4 × MTT S5000 (80 GiB, mp_count=64, driver 5.2.0-server, shared-host lease MUSA_VISIBLE_DEVICES=0,4,5,6)

  • Stack: Python 3.12, torch=2.13.0.post1+musa5.2.0, torch_musa=2.13.0.post1+musa5.2.0, torchada=0.1.111, mate=0.2.8.post1, flash_attn_3=0.2.8.post1+musa
  • 1. Unit & Source Gates


  • Offline & on-device pytest (test_qwen_moe_bf16_prefill_policy.py, test_moe_bf16_deepgemm_source.py, test_qwen_contract_source.py, test_qwen_optimization_contract.py, test_paged_mqa_logits_metadata_warmup.py, test_rope_store_hint_prewarm.py): 105 passed.
  • 2. Cold-Cache Operator & Warmup Microbenchmark (MTT S5000, mp=64, 8.0 GB L2 Flush)


  • Dead startup warmup elimination (TP=4 E=257): 10.050 s -> 0.0042 s (-10.05 s).

  • TP=2 folded top_k=9 warmup bucket fix (E=257, N=512): First T=2048 prefill latency 18.29 ms (Baseline top_k=8 miss) -> 1.31 ms (Candidate top_k=9 hit, 14.0x faster).

  • Folded E=257, top_k=9 (N=256, K=2048) Cold-Cache MoE Prefill Latency:
  • | Prefill Tokens (T) | Baseline DeepGEMM (ms) | Candidate Upstream Triton (ms) | Speedup | Parity |
    |---:|---:|---:|---:|---|
    | 1024 | 1.029 | 0.712 | 1.45x | PASS |
    | 1536 | 1.078 | 0.706 | 1.53x | PASS |
    | 2048 | 1.201 | 0.831 | 1.45x | PASS |
    | 4096 | 1.561 | 1.141 | 1.37x | PASS |
    | 8192 | 2.232 | 1.768 | 1.26x | PASS |

    3. End-to-End Compiled FULL_AND_PIECEWISE Serving (Qwen3.5-35B-A3B-BF16, TP=4, --max-num-batched-tokens 8192)


  • Server Startup Wall Time: 344.79 s (Baseline) -> 334.68 s (Candidate, -10.11 s; Warming MUSA BF16 grouped MoE GEMM eliminated and Using the upstream fused MoE path for large BF16 Qwen3.5/3.6-35B-A3B prefill batches active).

  • Serving Latency & Throughput:

  • - 2048-in / 64-out (c=1): Mean TTFT 89.73 -> 87.93 ms (-2.0%), Median TTFT 89.55 -> 86.80 ms (-3.1%).
    - 2048-in / 64-out (c=8, n=24): Mean TTFT 274.43 -> 260.15 ms (-5.2%), Total throughput 15470.7 -> 15725.2 tok/s (+1.65%).
    - 4096-in / 64-out (c=4, n=16): Mean TTFT 865.10 -> 854.77 ms, Total throughput 4563.8 -> 4613.8 tok/s (+1.10%).

    4. Mandatory 3-Family Regression Matrix


  • PASS qwen3_8b_dense_tp2 (tp=2, contains_beijing=True)

  • PASS qwen35_35b_a3b_moe_bf16_tp4 (tp=4, contains_beijing=True)

  • PASS deepseek_coder_v2_lite_mla_tp4 (tp=4, contains_beijing=True)
  • Diff: 590 lines (+442 / -148) across 7 files Reviewer: yeahdongcn Review duration: 5312m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.55) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.55 · 590 lines diff across 7 files
    0.55
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.382
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #378"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 55.0% (MEDIUM) · Higher = larger blast radius
    55.0%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 21.7% · Safe to merge
    21.7%