Skip to content

[Perf] Fix moe reduce_scatter perf regression by removing additional comm, 5% E2E throughput gain back. - #48763

Merged
yewentao256 merged 11 commits into
vllm-project:mainfrom
yewentao256:wentao-fix-perf-regression
Jul 25, 2026
Merged

yewentao256 merged 11 commits into
vllm-project:mainfrom
yewentao256:wentao-fix-perf-regression

Conversation

@yewentao256

@yewentao256 yewentao256 commented Jul 15, 2026

Copy link
Copy Markdown
Member

Purpose

Part of #46654

Following up PR for #48036 and alternative for #48657

Originally:

# before
hidden [T/P,H] + residual [T/P,H]
        ↓ all gather
      [T/P,2H]
        ↓ all-gather
       [T,2H]
        ↓ split
hidden [T,H] + residual [T,H]
        ↓ all-reduce hidden
        ↓ final RMSNorm

# Now
hidden [T/P,H]
        ↓ * P (as TP hidden states would be duplicated)
        ↓  final RMSNorm with local residual
       [T/P,H]
        ↓ all-gather
        [T,H]

So all-gather(2H) + all-reduce(H) -> all-gather(H)

Test

vllm serve zai-org/GLM-5.2-FP8 --kv-cache-dtype fp8_e4m3 --enable-expert-parallel --tensor-parallel-size 4 --tool-call-parser glm47 --enable-auto-tool-choice --reasoning-parser glm45 --port 9256 --profiler-config.profiler=torch --profiler-config.torch_profiler_dir=/home/yewentao256/profile_vllm --speculative-config '{"method":"mtp","num_speculative_tokens":3}'

vllm bench serve --model zai-org/GLM-5.2-FP8  --dataset-name random --host 127.0.0.1 --port 9256 --random-input-len 8192 --random-output-len 1 --request-rate inf --num-prompts 128 --num-warmups 16

# Now

============ Serving Benchmark Result ============
Successful requests:                     128       
Failed requests:                         0         
Benchmark duration (s):                  3.08      
Total input tokens:                      1048576   
Total generated tokens:                  128       
Request throughput (req/s):              41.50     
Output token throughput (tok/s):         41.50     
Peak output token throughput (tok/s):    76.00     
Peak concurrent requests:                128.00    
Total token throughput (tok/s):          340041.81 
---------------Time to First Token----------------
Mean TTFT (ms):                          1669.15   
Median TTFT (ms):                        1669.02   
P99 TTFT (ms):                           2724.38   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          0.00      
Median TPOT (ms):                        0.00      
P99 TPOT (ms):                           0.00      
---------------Inter-token Latency----------------
Mean ITL (ms):                           0.00      
Median ITL (ms):                         0.00      
P99 ITL (ms):                            0.00      
==================================================
============ Serving Benchmark Result ============
Successful requests:                     128       
Failed requests:                         0         
Benchmark duration (s):                  2.75      
Total input tokens:                      1048576   
Total generated tokens:                  128       
Request throughput (req/s):              46.61     
Output token throughput (tok/s):         46.61     
Peak output token throughput (tok/s):    75.00     
Peak concurrent requests:                128.00    
Total token throughput (tok/s):          381839.84 
---------------Time to First Token----------------
Mean TTFT (ms):                          1452.11   
Median TTFT (ms):                        1315.32   
P99 TTFT (ms):                           2478.83   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          0.00      
Median TPOT (ms):                        0.00      
P99 TPOT (ms):                           0.00      
---------------Inter-token Latency----------------
Mean ITL (ms):                           0.00      
Median ITL (ms):                         0.00      
P99 ITL (ms):                            0.00      
==================================================

# main
============ Serving Benchmark Result ============
Successful requests:                     128       
Failed requests:                         0         
Benchmark duration (s):                  3.23      
Total input tokens:                      1048576   
Total generated tokens:                  128       
Request throughput (req/s):              39.63     
Output token throughput (tok/s):         39.63     
Peak output token throughput (tok/s):    50.00     
Peak concurrent requests:                128.00    
Total token throughput (tok/s):          324671.20 
---------------Time to First Token----------------
Mean TTFT (ms):                          1668.69   
Median TTFT (ms):                        1649.00   
P99 TTFT (ms):                           3126.43   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          0.00      
Median TPOT (ms):                        0.00      
P99 TPOT (ms):                           0.00      
---------------Inter-token Latency----------------
Mean ITL (ms):                           0.00      
Median ITL (ms):                         0.00      
P99 ITL (ms):                            0.00      
==================================================
============ Serving Benchmark Result ============
Successful requests:                     128       
Failed requests:                         0         
Benchmark duration (s):                  3.03      
Total input tokens:                      1048576   
Total generated tokens:                  128       
Request throughput (req/s):              42.26     
Output token throughput (tok/s):         42.26     
Peak output token throughput (tok/s):    60.00     
Peak concurrent requests:                128.00    
Total token throughput (tok/s):          346261.13 
---------------Time to First Token----------------
Mean TTFT (ms):                          1483.22   
Median TTFT (ms):                        1461.62   
P99 TTFT (ms):                           2754.37   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          0.00      
Median TPOT (ms):                        0.00      
P99 TPOT (ms):                           0.00      
---------------Inter-token Latency----------------
Mean ITL (ms):                           0.00      
Median ITL (ms):                         0.00      
P99 ITL (ms):                            0.00      
==================================================

lm_eval --model local-completions --model_args "base_url=http://127.0.0.1:9256/v1/completions,model=$MODEL,num_concurrent=1024" --tasks gsm8k

|Tasks|Version|     Filter     |n-shot|  Metric   |   |Value |   |Stderr|
|-----|------:|----------------|-----:|-----------|---|-----:|---|-----:|
|gsm8k|      3|flexible-extract|     5|exact_match||0.9439|±  |0.0063|
|     |       |strict-match    |     5|exact_match||0.9447|±  |0.0063|

Signed-off-by: yewentao256 <zhyanwentao@126.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@yewentao256 yewentao256 added the ready ONLY add when PR is ready to merge/full CI is needed label Jul 15, 2026
@mergify

mergify Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @yewentao256.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Jul 16, 2026
Comment thread vllm/models/deepseek_v32/nvidia/mtp.py Outdated
Comment on lines +97 to +100
if is_sequence_parallel:
hidden_states = hidden_states * get_tensor_model_parallel_world_size()
else:
hidden_states = tensor_model_parallel_all_reduce(hidden_states)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why we would do hidden_states = hidden_states * get_tensor_model_parallel_world_size(). Perhaps the scalar coefficient is being taken care of by a subsequent norm?

Suggested change
if is_sequence_parallel:
hidden_states = hidden_states * get_tensor_model_parallel_world_size()
else:
hidden_states = tensor_model_parallel_all_reduce(hidden_states)
if not is_sequence_parallel:
hidden_states = tensor_model_parallel_all_reduce(hidden_states)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a further look. You are right, fixed, thanks!

Signed-off-by: yewentao256 <zhyanwentao@126.com>
Signed-off-by: yewentao256 <zhyanwentao@126.com>
@mergify mergify Bot removed the needs-rebase label Jul 16, 2026
Signed-off-by: yewentao256 <zhyanwentao@126.com>
@yewentao256
yewentao256 requested a review from luccafong as a code owner July 16, 2026 21:53
@mergify mergify Bot added the deepseek Related to DeepSeek models label Jul 16, 2026
@yewentao256 yewentao256 changed the title [Perf] Fix moe reduce_scatter perf regression by removing additional comm, 1.4%~4.8% E2E throughput gain back. [Perf] Fix moe reduce_scatter perf regression by removing additional comm, 5% E2E throughput gain back. Jul 16, 2026
Comment on lines +124 to +127
if (
self.mtp_block.use_sequence_parallel_moe
or hidden_states.shape[0] != positions.shape[0]
):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Why do we need both checks? I would think these are redundant

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, fixed

@tlrmchlsmth tlrmchlsmth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one nit, but otherwise LGTM now!

Signed-off-by: yewentao256 <zhyanwentao@126.com>
@yewentao256
yewentao256 enabled auto-merge (squash) July 17, 2026 15:45
@mergify

mergify Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @yewentao256.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify

mergify Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @yewentao256.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Jul 25, 2026
@yewentao256
yewentao256 force-pushed the wentao-fix-perf-regression branch from 03b1160 to a3e02ca Compare July 25, 2026 13:44
@mergify

mergify Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Documentation preview: https://vllm--48763.org.readthedocs.build/en/48763/

@mergify mergify Bot added documentation Improvements or additions to documentation ci/build frontend rust multi-modality Related to multi-modality (#4194) new-model Requests to new models performance Performance-related issues quantization qwen Related to Qwen models gpt-oss Related to GPT-OSS models nvidia labels Jul 25, 2026
@mergify mergify Bot added the rocm Related to AMD ROCm label Jul 25, 2026
@github-project-automation github-project-automation Bot moved this from To Triage to Ready in gpt-oss Issues & Enhancements Jul 25, 2026
@mergify mergify Bot added the cpu Related to CPU backends label Jul 25, 2026
@github-project-automation github-project-automation Bot moved this to Ready in NVIDIA Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/build cpu Related to CPU backends deepseek Related to DeepSeek models documentation Improvements or additions to documentation frontend gpt-oss Related to GPT-OSS models kv-connector multi-modality Related to multi-modality (#4194) needs-rebase new-model Requests to new models nvidia performance Performance-related issues quantization qwen Related to Qwen models ready ONLY add when PR is ready to merge/full CI is needed rocm Related to AMD ROCm rust speculative-decoding structured-output tool-calling v1

Projects

Status: Done
Status: Done
Status: Done
Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants