Skip to content

Optimize MUSA custom allreduce RMSNorm fusion - #140

Merged
Joey-gvwal merged 5 commits into
MooreThreads:v0.24.0-devfrom
Elon-yf:perf/musa-custom-allreduce-rmsnorm-fusion
Jul 30, 2026
Merged

Joey-gvwal merged 5 commits into
MooreThreads:v0.24.0-devfrom
Elon-yf:perf/musa-custom-allreduce-rmsnorm-fusion

Conversation

@Elon-yf

@Elon-yf Elon-yf commented Jul 28, 2026 •

Copy link
Copy Markdown

Optimize MUSA custom allreduce RMSNorm fusion

Summary

This PR adds and wires the MUSA JIT custom allreduce + RMSNorm fused path for
the supported tensor-parallel world sizes (TP2/TP4/TP8). It includes
graph-safe registered-input handling and keeps the existing behavior as the
fallback when the feature is disabled or a shape is not eligible. The
included serving matrix covers TP2 and TP4.

Key changes:

  • Add the MUSA JIT fused custom allreduce + RMSNorm kernels and Python launch
    bindings, including residual-output variants.
  • Integrate fused dispatch with the lifecycle-managed communicator registry.
  • Keep eager/prefill on fixed staging with the D2D fallback, while eligible
    captured graphs use registered input pointers without a per-replay copy.
  • Add graph-capture registration and recapture handling so registered pointers
    cannot become stale or remain placeholder data.
  • Add Inductor graph rewrites and environment-controlled opt-in/fallback paths.
  • Limit the TP4 rows=64 two-shot kernel to 32 blocks to reduce
    synchronization overhead.
  • Add source-level coverage for graph registration, fusion, and safety guards.

test:

Serving performance used Qwen3.5-35B-A3B BF16/FP8 with TP4 and
Qwen3.5-27B BF16/FP8 with TP2 on S5000. This PR reports only 4096→1024;
batch sizes are 1/4/16/64. Baseline is the paired mean of two disabled control
runs; Fused is the enabled run. Throughput + is better; TTFT/TPOT/E2E -
is better.

Source contract test:

pytest -q tests/test_fused_ar_registered_graph_source.py

Serving command used for each control/fused run:

vllm bench serve --backend openai-chat --base-url http://127.0.0.1:<PORT> \
  --endpoint /v1/chat/completions --model <SERVED_MODEL> --tokenizer <MODEL> \
  --dataset-name random --random-input-len 4096 --random-output-len 1024 \
  --num-prompts <BS> --max-concurrency <BS> --request-rate inf \
  --temperature 0 --seed 0 --ignore-eos --trust-remote-code \
  --percentile-metrics ttft,tpot,itl,e2el --metric-percentiles 50,90,95,99

The three runs use the disabled/fused/disabled feature settings. The server
uses TP4 for 35B or TP2 for 27B, max_model_len=5184, max_num_seqs=64,
FLASH_ATTN, normal graph capture, and no eager or compile-disabling flags.

Model Precision Input→Output BS TP Baseline output (tok/s) Fused output (tok/s) Throughput Δ TTFT Δ TPOT Δ E2E Δ Reps/leg
Qwen3.5-35B-A3B BF16 4096→1024 1 4 55.47 55.82 +0.634% -2.309% -0.617% -0.630% 5
Qwen3.5-35B-A3B BF16 4096→1024 4 4 229.75 231.77 +0.880% -2.031% -0.851% -0.874% 5
Qwen3.5-35B-A3B BF16 4096→1024 16 4 690.80 692.86 +0.298% -1.757% -0.250% -0.319% 5
Qwen3.5-35B-A3B BF16 4096→1024 64 4 1729.47 1730.60 +0.065% -1.904% +0.116% -0.110% 5
Qwen3.5-35B-A3B-FP8 FP8 4096→1024 1 4 58.00 58.64 +1.097% -1.922% -1.078% -1.085% 5
Qwen3.5-35B-A3B-FP8 FP8 4096→1024 4 4 211.93 213.48 +0.731% -2.286% -0.697% -0.726% 5
Qwen3.5-35B-A3B-FP8 FP8 4096→1024 16 4 642.71 645.41 +0.419% -0.860% -0.398% -0.419% 5
Qwen3.5-35B-A3B-FP8 FP8 4096→1024 64 4 1442.36 1447.94 +0.387% -2.177% -0.157% -0.362% 5
Qwen3.5-27B BF16 4096→1024 1 2 29.51 30.46 +3.215% -3.008% -3.116% -3.115% 5
Qwen3.5-27B BF16 4096→1024 4 2 103.11 105.24 +2.071% -2.910% -1.997% -2.028% 5
Qwen3.5-27B BF16 4096→1024 16 2 296.47 300.78 +1.454% -2.662% -1.320% -1.432% 5
Qwen3.5-27B BF16 4096→1024 64 2 582.10 588.20 +1.047% -2.489% -0.762% -1.041% 5
Qwen3.5-27B-FP8 FP8 4096→1024 1 2 38.98 40.31 +3.425% -3.869% -3.302% -3.312% 5
Qwen3.5-27B-FP8 FP8 4096→1024 4 2 131.22 134.45 +2.461% -3.908% -2.344% -2.403% 5
Qwen3.5-27B-FP8 FP8 4096→1024 16 2 360.95 367.30 +1.760% -3.470% -1.562% -1.728% 5
Qwen3.5-27B-FP8 FP8 4096→1024 64 2 669.85 678.56 +1.300% -3.339% -0.895% -1.285% 5

Focused repeated validation:

  • Qwen3.5-35B-A3B BF16, TP4, 4096→1024, BS64 used 10 formal repetitions per leg: 30/30 samples, 1,920 completed requests, 0 failures.
  • Output throughput: 1729.47 → 1730.60 tok/s (+0.065%).
  • TTFT: 4168.08 → 4088.73 ms (-1.904%).
  • TPOT: 32.313 → 32.351 ms (+0.116%).
  • E2E: 37224.35 → 37183.33 ms (-0.110%).
  • The earlier apparent regression did not reproduce in this repeated run.

Functional and source validation:

  • PASS: all three semantic smoke requests returned the expected response.
  • PASS: all 8 changed feature-file hashes match the candidate commit.
  • PASS: candidate commit b4a2e8b94f10c92ff1e04bd19dda664e7f8b035d has tree 2b1b12a1eef9f2c0166d563bb8ba32987ff593bc, identical to the tested tree.
  • PASS: no textual merge conflict against v0.24.0-dev@6c7ef2f8d4939de2f76f17990419258663456e2c.

Evidence boundary:

  • The focused 35B BF16 4096→1024 BS64 row is the clean-source repeated run.
  • The remaining 15 rows are historical comparison context whose source commit was not recorded; they are not relabeled as clean-SHA results.
  • The table contains mean deltas and does not claim that every delta is statistically significant.

@Elon-yf
Elon-yf force-pushed the perf/musa-custom-allreduce-rmsnorm-fusion branch from 1343c91 to c40d22f Compare July 30, 2026 08:13
Xiaodong Ye and others added 4 commits July 30, 2026 16:22
Add the MUSA JIT kernels and Inductor rewrite for fused custom all-reduce and RMSNorm.
Reuse the lifecycle-managed communicator registry and limit the TP4 rows=64
two-shot launch to 32 blocks by default.
@Elon-yf
Elon-yf force-pushed the perf/musa-custom-allreduce-rmsnorm-fusion branch from c40d22f to 18a7fee Compare July 30, 2026 08:25
@Joey-gvwal
Joey-gvwal merged commit 782fe45 into MooreThreads:v0.24.0-dev Jul 30, 2026
@Elon-yf

Elon-yf commented Jul 31, 2026 •

Copy link
Copy Markdown
Author

-cc.mode=VLLM_COMPILE

@Joey-gvwal

Copy link
Copy Markdown
Collaborator

Please clarify whether the current default path uses the fused optimization.

Joey-gvwal pushed a commit that referenced this pull request Aug 3, 2026
* Optimize MUSA custom allreduce RMSNorm fusion

Add the MUSA JIT kernels and Inductor rewrite for fused custom all-reduce and RMSNorm.
Reuse the lifecycle-managed communicator registry and limit the TP4 rows=64
two-shot launch to 32 blocks by default.

* Refine fused allreduce runtime defaults

* Clean up fused allreduce diagnostics

* Fail closed unsupported allreduce RMSNorm rewrites

* Harden MUSA allreduce RMSNorm fusion guards

---------

Co-authored-by: Xiaodong Ye <yexiaodong60@mthreads.com>
Co-authored-by: Elon Gao <elon.gao@mthread.com>

(cherry picked from commit 782fe45)
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.

2 participants