Skip to content

[Refactor][DSv4.1] Remove duplicated code - #64974

Merged
gau-nernst merged 5 commits into
vllm-project:mainfrom
gcanlin:refactor/dsv41-share-v4-leaves
Nov 3, 2026
Merged

gau-nernst merged 5 commits into
vllm-project:mainfrom
gcanlin:refactor/dsv41-share-v4-leaves

Conversation

@gcanlin

@gcanlin gcanlin commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Remove code that deepseek_v41 duplicates from deepseek_v4. No behavior change.

Claims

  • Ops that deepseek_v41 carried as byte-identical copies of deepseek_v4 are removed and imported from deepseek_v4 instead: the Triton kernels quantize_and_insert_k_kernel, remap_flashinfer_index and fill_short_context_topk_indices, and the FlashInfer sparse helpers get_flashinfer_dsv4_workspace, packed_block_span, pad_to_supported_q_heads and required_sm120_sparse_topk. They lose their leading underscore now that another package imports them.
  • Removed the hf_config_int / scheduler_config_int helpers. Warmup always receives the engine's VllmConfig, so the warmup code now reads sliding_window / index_topk directly, and the max_num_batched_tokens <= 0 early return is dropped (the field is validated >= 1).
  • deepseek_v41/nvidia imports DeepseekV4MixtureOfExperts from deepseek_v4/nvidia instead of keeping its own copy, since its MoE subclasses the V4 one. The ROCm model keeps its copy because its MoE has a different base.

gcanlin and others added 4 commits November 1, 2026 17:51
…of copying them

deepseek_v41 carried byte-identical copies of several deepseek_v4 module-level
helpers (three Triton kernels, the FlashInfer sparse helpers, two config
readers) and three copies of DeepseekV4MixtureOfExperts. Import the helpers
from deepseek_v4 and move DeepseekV4MixtureOfExperts into
deepseek_v4/common/eplb_util.py so the NVIDIA and ROCm models share one copy.
Only definitions whose source and referenced globals are identical in both
packages are shared; no behavior change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Canlin <canlinguosdu@gmail.com>
The helpers deepseek_v41 now imports from deepseek_v4 are part of the
package's cross-module surface, so drop their leading underscores.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Canlin <canlinguosdu@gmail.com>
hf_config_int/scheduler_config_int guarded against a missing model or
scheduler config, but warmup always receives the engine's VllmConfig:
max_num_batched_tokens is validated >= 1 and DeepseekV4/V41 configs
expose sliding_window and index_topk at the top level, as the attention
layers already assume. Read the fields directly; the generated warmup keys
are unchanged for the V4 and V4.1 configs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Canlin <canlinguosdu@gmail.com>
The NVIDIA and ROCm DeepseekV4MoE classes have no common base, so a
mixin shared across both can only type its MoE layers as Any. Keep it in
deepseek_v4/nvidia/model.py, typed with the V4 MoE that the V4.1 NVIDIA
MoE subclasses, and import it from there; the ROCm model keeps its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Canlin <canlinguosdu@gmail.com>
@gcanlin
gcanlin requested a review from zyongye as a code owner November 1, 2026 10:30

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

@mergify mergify Bot added deepseek Related to DeepSeek models DSv4 DSv4.1 Related to DeepSeek-V4.1 models nvidia labels Nov 1, 2026
@gcanlin

gcanlin commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

@Juntian777 @WoosukKwon Some clean up for DSv4.1. Could you please take a look? :)

@WoosukKwon WoosukKwon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@github-project-automation github-project-automation Bot moved this to Ready in NVIDIA Nov 2, 2026
@mergify

mergify Bot commented Nov 2, 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, @gcanlin.

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 Nov 2, 2026
…e-v4-leaves

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Canlin <canlinguosdu@gmail.com>
@mergify mergify Bot removed the needs-rebase label Nov 3, 2026
@gcanlin

gcanlin commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/ci run

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

✅ Triggered Buildkite CI #99427 for commit 040c6a0fee77.

@gau-nernst
gau-nernst merged commit 45d0ac9 into vllm-project:main Nov 3, 2026
139 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to Done in NVIDIA Nov 3, 2026
yaoyaoding added a commit to yaoyaoding/vllm that referenced this pull request Nov 3, 2026
Resolve two conflicts under vllm/models/deepseek_v41/nvidia/:

- dspark.py: keep main's dspark_fused_markov opt-in (vllm-project#64442) beside the
  draft executor's registration, and main's compute_draft_logits_local.
- moe/routed_expert_gemm.py: take current_cu_stream from main's shared
  moe_tail_fusion primitives (vllm-project#64974) and keep the finalize kernel.

Signed-off-by: Yaoyao Ding <yaoyaod@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepseek Related to DeepSeek models DSv4 DSv4.1 Related to DeepSeek-V4.1 models nvidia

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants