Skip to content

[Perf][MoE] Optimize deepep_v2 receiver CPU Overhead - #51114

Merged
robertgshaw2-redhat merged 4 commits into
vllm-project:mainfrom
neuralmagic:lwilkinson/deepep-v2-receiver-repeat-interleave
Aug 17, 2026
Merged

[Perf][MoE] Optimize deepep_v2 receiver CPU Overhead#51114
robertgshaw2-redhat merged 4 commits into
vllm-project:mainfrom
neuralmagic:lwilkinson/deepep-v2-receiver-repeat-interleave

Conversation

@LucasWilkinson

Copy link
Copy Markdown
Collaborator

Optimize away excessive fills in deepep_v2's receiver

BEFORE

Screenshot 2026-08-05 at 12 12 25 AM

AFTER

Screenshot 2026-08-05 at 12 11 42 AM

@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.

…epeat_interleave

In DeepEPV2PrepareAndFinalize._receiver, the do_expand=True (prefill) branch
built recv_topk_idx with a Python loop issuing one slice+fill_ per local
expert. Rows already arrive grouped by expert, so this is a repeat_interleave.

The loop cost one kernel launch per local expert, per MoE layer, per step. On
Kimi-K3-pruned75 (224 experts) at DP=2/TP=4/EP=8 that measured 22 aten::fill_
and 146us of self CPU per layer-step, i.e. ~13ms per engine step across 92 MoE
layers, against 234ms of dispatch+combine GPU time.

Two details keep the replacement off the critical path:

  * The repeats tensor is borrowed from expert_tokens_meta, whose counts are
    already staged with .to(non_blocking=True); its construction moves above
    recv_topk_idx so it can be reused. Building a separate one with
    torch.tensor(list, device=cuda) is a pageable copy -- synchronous with
    respect to the host -- and blocks until the enqueued GPU work drains:
    52us on an idle GPU but 5249us behind a deep queue, worse than the loop.
  * output_size is passed, so repeat_interleave does not sum the counts on
    device and sync to learn the output length. It is known on the host
    because do_expand=True implies do_cpu_sync=True.

arange(num_local_experts) + rank_expert_offset is rank-constant and cached.

Signed-off-by: Lucas Wilkinson <wilkinson.lucas@gmail.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@LucasWilkinson
LucasWilkinson force-pushed the lwilkinson/deepep-v2-receiver-repeat-interleave branch from 909949f to 770f8af Compare August 5, 2026 04:20
@LucasWilkinson

Copy link
Copy Markdown
Collaborator Author

/run ci

@mgoin mgoin added performance Performance-related issues ready ONLY add when PR is ready to merge/full CI is needed nvidia labels Aug 6, 2026
@github-project-automation github-project-automation Bot moved this to Ready in NVIDIA Aug 6, 2026
@mgoin

mgoin commented Aug 6, 2026

Copy link
Copy Markdown
Member

/ci run

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

✅ Triggered Buildkite CI #82695 for commit 770f8af8c81d.

@robertgshaw2-redhat
robertgshaw2-redhat enabled auto-merge (squash) August 7, 2026 18:48
@robertgshaw2-redhat

Copy link
Copy Markdown
Collaborator

/ci run

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

✅ Triggered Buildkite CI #82900 for commit 3aadfeee5064.

@robertgshaw2-redhat

Copy link
Copy Markdown
Collaborator

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #84222 for commit d15d46c994ed.

@mergify

mergify Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Hi @LucasWilkinson, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

@robertgshaw2-redhat
robertgshaw2-redhat merged commit 75dde08 into vllm-project:main Aug 17, 2026
107 of 110 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to Done in NVIDIA Aug 17, 2026
zyp2014 pushed a commit to zyp2014/vllm that referenced this pull request Aug 21, 2026
)

Signed-off-by: Lucas Wilkinson <wilkinson.lucas@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Robert Shaw <114415538+robertgshaw2-redhat@users.noreply.github.com>
wyettzeng pushed a commit to wyettzeng/vllm that referenced this pull request Aug 21, 2026
)

Signed-off-by: Lucas Wilkinson <wilkinson.lucas@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Robert Shaw <114415538+robertgshaw2-redhat@users.noreply.github.com>
Signed-off-by: Wyett <wyettzeng@gmail.com>
zufangzhu pushed a commit to zufangzhu/vllm that referenced this pull request Aug 24, 2026
)

Signed-off-by: Lucas Wilkinson <wilkinson.lucas@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Robert Shaw <114415538+robertgshaw2-redhat@users.noreply.github.com>
Signed-off-by: Zhu, Zufang <zufang.zhu@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nvidia performance Performance-related issues ready ONLY add when PR is ready to merge/full CI is needed

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants