Skip to content

fix: mtp gating for the nccl-reshard-refit and fix the error when doing ray RPC. - #3532

Closed
youngeunkwon0405 wants to merge 7 commits into
mainfrom
youngeunk/new-refit-mtp-gate
Closed

youngeunkwon0405 wants to merge 7 commits into
mainfrom
youngeunk/new-refit-mtp-gate

Conversation

@youngeunkwon0405

@youngeunkwon0405 youngeunkwon0405 commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do ?

This PR is doing two independent things. I split this PR into two.

  1. Gate the MTP layers from the nccl-reshard path. It will force the use of the conventional refit path for the MTP layer.

Goes to #3619

  1. Make the nccl_reshard_refit_info object wire-safe before sending it to the generation worker during initialization.
    nccl_reshard_refit_info contains torch tensors, created by Megatron. The problem is that Megatron replaces the
    torch.storage._load_from_bytes function that is required for unpickling to a Megatron-specific function.
    So, during unpickling from the generation worker, it will call import megatron which will cause an import error.
    This PR fixes that issue.

Goes to #3618

Issues

List issues that this PR closes (syntax):

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you run the unit tests and functional tests locally? Visit our Testing Guide for how to run tests
  • Did you add or update any necessary documentation? Visit our Document Development Guide for how to write, build and test the docs.

Additional Information

  • ...

@youngeunkwon0405
youngeunkwon0405 requested a review from a team as a code owner August 7, 2026 09:11
@copy-pr-bot

copy-pr-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@youngeunkwon0405 youngeunkwon0405 added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Aug 7, 2026
@youngeunkwon0405

Copy link
Copy Markdown
Contributor Author

/okay to test 9736d2f

@youngeunkwon0405
youngeunkwon0405 force-pushed the youngeunk/new-refit-mtp-gate branch from 9736d2f to f7ee3a7 Compare August 7, 2026 09:24
@youngeunkwon0405

Copy link
Copy Markdown
Contributor Author

/okay to test f7ee3a7

@youngeunkwon0405 youngeunkwon0405 self-assigned this Aug 7, 2026
@youngeunkwon0405
youngeunkwon0405 force-pushed the youngeunk/new-refit-mtp-gate branch from f7ee3a7 to 2d9a63c Compare August 7, 2026 11:01
@youngeunkwon0405
youngeunkwon0405 requested a review from a team as a code owner August 7, 2026 11:01
@youngeunkwon0405

Copy link
Copy Markdown
Contributor Author

/ok to test 2d9a63c

@youngeunkwon0405 youngeunkwon0405 changed the title fix: mtp gating for the nccl-reshard-refit fix: mtp gating for the nccl-reshard-refit and sc fix Aug 7, 2026
@youngeunkwon0405
youngeunkwon0405 force-pushed the youngeunk/new-refit-mtp-gate branch from 58638d6 to d47d737 Compare August 7, 2026 17:57
@youngeunkwon0405

Copy link
Copy Markdown
Contributor Author

/okay to test d47d737

@youngeunkwon0405 youngeunkwon0405 changed the title fix: mtp gating for the nccl-reshard-refit and sc fix fix: mtp gating for the nccl-reshard-refit and fix the error when doing ray RPC. Aug 10, 2026
@youngeunkwon0405

Copy link
Copy Markdown
Contributor Author

/okay to test dd51417

Signed-off-by: Youngeun Kwon <[email protected]>
Signed-off-by: Youngeun Kwon <[email protected]>
@youngeunkwon0405
youngeunkwon0405 force-pushed the youngeunk/new-refit-mtp-gate branch from dd51417 to 1fdd2a0 Compare August 12, 2026 21:11

@youngeunkwon0405 youngeunkwon0405 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Team review: 4 agents (RL expert, test reviewer, bug finder, devil's advocate) + lead. All findings below were independently re-verified by the devil's advocate against the pinned submodule SHAs before posting.

Overall: both halves of the PR address real, reproducible failures on the pinned dependencies, and the wire-safe conversion was verified to round-trip exactly (Shard/Replicate/MeshInfo) without mutating the trainer-side original. The pickle mechanism described in the docstring is accurate for the pinned megatron-core: torch.storage._load_from_bytes = safe_load_from_bytes.

8 inline comments: 1 bug on the vLLM side (MTP drafter post-load processing), 1 exception-masking issue in teardown, 1 documented limitation (DeepSeek-V3 MTP naming), 2 test asks, and 3 small doc/style items. Linter (ruff check + format): clean.

Generated by Claude Code

Comment thread nemo_rl/algorithms/single_controller.py Resolved
youngeunkwon0405 and others added 3 commits August 12, 2026 14:54
Co-authored-by: Youngeun Kwon <[email protected]>
Signed-off-by: Youngeun Kwon <[email protected]>
- vllm_backend: run nccl_reshard_refit finalization through
  _weight_update_lifecycle so the co-trained MTP drafter gets
  _maybe_process_mtp_drafter_after_loading() like the ipc/collective
  transports (freshly refit MTP MoE weights need their runtime layout
  conversion); widen WeightUpdateTransport with "nccl_reshard"
- nccl_reshard_utils: only rewrite wire keys that are present so the
  wire copy's key set stays faithful to the builder output; list
  make_nccl_reshard_refit_info_wire_safe in the module docstring
- nccl_reshard_weight_synchronizer: hoist the wire-safe import to
  module top; document the GC intent of dropping _generation
- tests: add pure-CPU round-trip tests for the wire-safe conversion
  (no tensors on the wire, input not mutated, restore reproduces
  placements/meshes)
- docs: document the misc-path exclusions (shared_expert, mtp.) and
  the DeepSeek-style MTP limitation; describe the wire-safe hop in
  the setup flow

Co-Authored-By: Claude Fable 5 <[email protected]>
Signed-off-by: Youngeun Kwon <[email protected]>
DeepSeek bridges export MTP weights as trailing main-model layer
indices (model.layers.{N + num_layers}.*), which the mtp. prefix gate
in is_nccl_reshard_param cannot recognize from the HF name alone.
Detect MTP provenance from the Megatron-side name on the Bridge
conversion tasks (uniformly mtp.* for every family) and route those
HF layers to the misc packed-broadcast path, where vLLM's drafter
picks them up via load_weights and the weight-update lifecycle runs
the drafter post-processing.

The helper lives in megatron_policy_worker (it consumes Megatron-
Bridge task objects), keeping nccl_reshard_utils backend-agnostic;
tests are in the mcore-marked worker test file.

Co-Authored-By: Claude Fable 5 <[email protected]>
Signed-off-by: Youngeun Kwon <[email protected]>
@youngeunkwon0405
youngeunkwon0405 requested review from a team as code owners August 12, 2026 23:53
@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Aug 12, 2026
@terrykong

Copy link
Copy Markdown
Collaborator

closed since covered by the other prs referencing this one

@terrykong terrykong closed this Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants