Skip to content

[BugFix] Fix MTP draft model weight sync in RL training disaggregated mode - #13209

Open
CalvinXKY wants to merge 3 commits into
vllm-project:mainfrom
CalvinXKY:fix/npuworker-mtp-draft-model
Open

CalvinXKY wants to merge 3 commits into
vllm-project:mainfrom
CalvinXKY:fix/npuworker-mtp-draft-model

Conversation

@CalvinXKY

@CalvinXKY CalvinXKY commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it?

In RL disaggregated training, weight sync only updated the target model and skipped the MTP draft (model_runner.drafter). After the first update, draft stayed at HF init while target moved, so MTP acceptance dropped to 0% and rollout became garbage.

After #12876, weight load lives in transfer engines; this PR wires draft sync through that path:

  • NPUWorker: _get_draft_model() / _bind_draft_model_to_engine(); on start_weight_update bind draft via engine.set_draft_model(...)
  • HCCLWeightTransferEngine / NPUIPCWeightTransferEngine: explicit set_draft_model; start/finish/_load_weights_with_draft also update draft when present
  • is_checkpoint_format kept on worker start_weight_update for RL-client compat but ignored (engine owns format handling)

Non-MTP models unchanged (_get_draft_model() returns None).

Companion vime fix: vllm-project/vime#375

Does this PR introduce any user-facing change?

No. Fixes RL weight-sync for MTP on NPU; non-MTP / non-RL paths unchanged.

How was this patch tested?

Unit tests

  • tests/ut/worker/a2/test_worker_v1.py: draft unwrap + set_draft_model bind on start
  • tests/ut/distributed/weight_transfer/test_npu_ipc_engine.py: draft start/finish/load
  • tests/ut/distributed/weight_transfer/test_hccl_engine_draft.py: HCCL draft helpers

E2E with vime disaggregated RL on 8x Ascend 910B1, GLM-4.7-Flash (30B-A3B MoE + MTP), 4 train + 4 rollout, TP=4 (together with vime#375):

Metric Before After
MTP acceptance rate 0% ~30%
rollout_time 1289.6s (garbage) 847.4s
tokens/gpu/sec 32.0 74.13
grad_norm 6.95 0.128
update_weights_time 91.3s 9.3s

@CalvinXKY
CalvinXKY requested a review from MengqingCao as a code owner July 30, 2026 12:30
@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 addresses a critical issue in RL disaggregated training where the MTP draft model failed to synchronize weights with the target model. By ensuring both models are updated simultaneously during the weight update cycle, the MTP acceptance rate is restored, significantly improving performance and training stability on NPU hardware.

Highlights

  • MTP Draft Model Weight Sync: Implemented weight synchronization for the MTP draft model in RL disaggregated training mode, ensuring the draft model stays in sync with the target model during updates.
  • Layerwise Reload Support: Updated start and finish weight update procedures to include the draft model in layerwise reload operations.
  • Direct Mode TP-Sharding: Added a TP-sharding-aware loader for direct mode weight updates to bypass NPU-specific issues with layerwise_reload.
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:

[Ops][Feature] Support weight updates for speculative draft models on Ascend

Suggested PR Summary:

### What this PR does / why we need it?
This PR adds support for updating weights of MTP/Eagle draft models alongside the target model on Ascend NPUs. It introduces `_get_draft_model` to retrieve and unwrap the draft model, and updates `start_weight_update`, `update_weights`, and `finish_weight_update` to handle draft models in both checkpoint and direct loading formats.

Feedback:
- In `_get_draft_model`, the check `hasattr(drafter, "get_model")` is incorrect and should be performed on `draft_model` instead of `drafter` to correctly unwrap the `ACLGraphWrapper`.
- In direct weight loading mode, the `_loader` function should run under `torch.no_grad()` to avoid tracking gradients and causing unnecessary memory overhead.

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
Not specified.

Comment thread vllm_ascend/worker/worker.py Outdated
Comment on lines +315 to +317
if hasattr(drafter, "get_model"):
with suppress(Exception):
draft_model = drafter.get_model()

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.

high

The check hasattr(drafter, "get_model") and subsequent call drafter.get_model() are incorrect because drafter is the speculative proposer (e.g., AscendEagleProposer), whereas the draft model itself (draft_model) is the one that may be wrapped in ACLGraphWrapper. This typo will prevent the draft model from being unwrapped, which can cause hasattr(draft_model, "load_weights") to return False and disable weight updates for the draft model entirely.

Suggested change
if hasattr(drafter, "get_model"):
with suppress(Exception):
draft_model = drafter.get_model()
if hasattr(draft_model, "get_model"):
with suppress(Exception):
draft_model = draft_model.get_model()

Comment thread vllm_ascend/worker/worker.py Outdated
Comment on lines 416 to 417
def _loader(weights):
for name, weight in weights:

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.

high

In direct mode, copying weights and invoking weight_loader should be performed under torch.no_grad() to prevent autograd from tracking these operations and constructing unnecessary gradient graphs, which can lead to memory overhead or errors.

Suggested change
def _loader(weights):
for name, weight in weights:
def _loader(weights):
with torch.no_grad():
for name, weight in weights:

@CalvinXKY CalvinXKY changed the title [NPU] Fix MTP draft model weight sync in RL training disaggregated mode [BugFix] Fix MTP draft model weight sync in RL training disaggregated mode Jul 30, 2026
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

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

NPUWorker's weight update methods (start/update/finish) only updated
the target model, leaving the MTP draft model at HF checkpoint init
values. This caused 0% MTP acceptance rate and garbage rollout output
in RL training disaggregated mode.

Changes:
- Add _get_draft_model() to retrieve MTP draft model from AscendEagleProposer
- start_weight_update: also initialize layerwise_reload for draft model
- update_weights: load weights into both target and draft model;
  replace naive param.copy_() with TP-sharding-aware loader that handles
  packed params (qkv_proj, gate_up_proj) and TP rank sharding
- finish_weight_update: also finalize layerwise_reload for draft model

Non-MTP models are unaffected (_get_draft_model returns None).

Signed-off-by: kaiyuan <kyxiezju@163.com>
Signed-off-by: kaiyuan <kyxiezju@163.com>
@CalvinXKY
CalvinXKY force-pushed the fix/npuworker-mtp-draft-model branch from e2579b1 to 88d54d3 Compare August 3, 2026 02:16
@CalvinXKY
CalvinXKY requested a review from LCAIZJ as a code owner August 3, 2026 02:16
Replace engine getattr side-channel with explicit set_draft_model API,
tighten draft unwrap logic, and cover worker/engine draft sync paths.

Signed-off-by: kaiyuan <kyxiezju@163.com>
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

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

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