Skip to content

[Performance][MRV2] Skip CPU length synchronization for DeepSeek V4 - #19355

Closed
linfeng-yuan wants to merge 1 commit into
vllm-project:mainfrom
linfeng-yuan:perf/mrv2-v4-cpu-seqlens
Closed

linfeng-yuan wants to merge 1 commit into
vllm-project:mainfrom
linfeng-yuan:perf/mrv2-v4-cpu-seqlens

Conversation

@linfeng-yuan

@linfeng-yuan linfeng-yuan commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it?

MRV2 exempts DeepSeek V4.1 from copying rejection-corrected token counts back to the CPU and waiting for that copy on the next step, but V4 takes the synchronous path even though its attention uses device sequence lengths. This can interrupt asynchronous decode submission.

Extend the existing exemption to the V4/V4.1 family. Recognize text configs, nested config representations, and the config-class identity when DSpark overrides an instance's model_type. Keep the device-side postprocessing and optimistic CPU upper bounds, and preserve sync_spec_pp_cpu_counts so PP consumers still receive exact counts. Other models retain their existing behavior.

This PR is independent of the UVA prefix-write optimization.

Does this PR introduce any user-facing change?

V4 speculative decoding avoids an unnecessary host/device synchronization. No new configuration, API, or MRV1 changes.

How was this patch tested?

  • python -m pytest --noconftest -q tests/ut/worker/test_spec_pp_cpu_counts.py: 132 passed. The test executes the production methods on CPU and covers V4/V4.1 config detection, rejected-token device updates, CPU upper bounds, PP overrides, and existing deferred PP behavior.
  • Expanded tests/ut/worker/test_model_runner_v2.py to cover the V4 family.
  • Ruff 0.14.0 formatting/lint and git diff --check passed for all changed files.
  • The regular two-file pytest command was attempted but blocked during conftest import: the installed vLLM lacks prepare_dcp_local_seq_lens required by current main. Full bash format.sh ci was also attempted, but hook dependency initialization stalled in this environment; only the scoped Ruff checks are claimed as passing. Main-branch integration and full hook checks remain for CI.

Before porting to main, the V4 exemption was exercised on Ascend hardware with MRV2, DSpark (5 draft tokens), MooncakeHybridConnector, DP4/TP1, 224 client concurrency, and 64K/128K inputs. Four 1,000-request comparison runs and one 3,000-request long run completed without request failures; requested input/output lengths were checked. These runs validate operation, not model accuracy, and do not isolate the throughput gain from this exemption alone.

Implementation and tests were prepared with Codex.

Assisted-by: Codex
Signed-off-by: linfeng-yuan <194351811+linfeng-yuan@users.noreply.github.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request optimizes speculative decoding performance for the DeepSeek V4 model family by removing redundant CPU-side synchronization of token counts. By generalizing the existing V4.1 exemption logic, the changes ensure that models using device-side sequence lengths can proceed without stalling the asynchronous decode pipeline, while maintaining compatibility with existing PP (Pipeline Parallelism) consumers.

Highlights

  • Performance Optimization: Extended the CPU length synchronization exemption from DeepSeek V4.1 to the entire DeepSeek V4 family, preventing unnecessary host/device synchronization during speculative decoding.
  • Configuration Detection: Introduced is_deepseek_v4_family to robustly identify V4/V4.1 models, supporting various configuration representations including nested objects, dictionaries, and DSpark overrides.
  • Testing: Expanded test coverage in test_model_runner_v2.py and test_spec_pp_cpu_counts.py to validate the new detection logic and ensure synchronization behavior is correctly applied across the V4 family.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

Suggested PR Title:\n\nmarkdown\n[Ops][Feature] Extend device sequence length exemption to DeepSeek V4 family\n\n\nSuggested PR Summary:\n\nmarkdown\n### What this PR does / why we need it?\nThis PR extends the exemption for CPU length synchronization to the entire DeepSeek V4 family (including `deepseek_v4`, `deepseek_v4_text`, `deepseek_v41`, and `deepseek_v41_text`), as these models use device sequence lengths for attention. Previously, this exemption was only applied to `deepseek_v41`. A new helper function `is_deepseek_v4_family` is introduced in `utils.py` to identify these configurations, and the model runner has been updated to use this helper.\n\n### Does this PR introduce _any_ user-facing change?\nNo.\n\n### How was this patch tested?\nThe changes were tested by updating existing unit tests in `tests/ut/worker/test_model_runner_v2.py` and adding new unit tests in `tests/ut/worker/test_spec_pp_cpu_counts.py` to verify the configuration detection and the host synchronization bypass logic.\n

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@GDzhu01
GDzhu01 self-requested a review November 4, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant