Repository navigation
fix: make nccl_reshard_refit_info wire-safe for the generation-worker. - #3618
Conversation
|
/ok to test e0c8961 |
youngeunkwon0405
left a comment
There was a problem hiding this comment.
Team review: 4 agents (RL expert, test reviewer, bug finder, devil's advocate) + lead; findings independently re-verified before posting.
The fix is correct and necessary — verified empirically. The devil's advocate reproduced the failure end-to-end on CPU: with torch.storage._load_from_bytes patched the way the pinned megatron-core does (megatron/core/init.py @ d12f6c8c, torch.storage._load_from_bytes = safe_load_from_bytes), the raw refit-info pickle references megatron.core.safe_globals.safe_load_from_bytes and cannot unpickle without megatron, while the wire-safe form unpickles and restores exactly. The converter was further verified for MoE+EP+PP round-trip fidelity, idempotency in both directions, and non-mutation of the caller's dict. All 50 unit tests in the touched file pass on a CPU-only environment.
4 inline comments, none above low severity: a fail-loud suggestion in the wire helpers, a narrow teardown race + a hang risk around the new shutdown() wiring (which otherwise closes a real gap), and two test-strengthening suggestions. Linter (ruff check + format): clean.
Generated by Claude Code
|
/ok to test 234e68b |
… RPC nccl_reshard_refit_info holds MeshInfo rank tensors created under Megatron. megatron.core replaces torch.storage._load_from_bytes with its own loader at import time, so pickled tensors require `import megatron` at unpickle time — which fails inside vLLM subprocesses. Convert meshes and Shard/Replicate placements to plain dicts/lists (make_nccl_reshard_refit_info_wire_safe) before the Ray hop; the vLLM worker rebuilds them via restore_refit_info_placements. Also shut the weight synchronizer down at the end of the single-controller run loop (guarded so teardown errors cannot mask a training failure) and drop the synchronizer's generation handle on shutdown to break the reference cycle. Adds pure-CPU round-trip tests: no tensors on the wire, input not mutated, restore reproduces placements/meshes exactly. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Youngeun Kwon <[email protected]>
Mimic megatron-core's torch.storage._load_from_bytes patch with a dummy module and assert the raw refit info pickle references it while the wire-safe form does not — the exact invariant the conversion exists to guarantee, which a plain pickle round-trip in an unpatched test process cannot detect. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Youngeun Kwon <[email protected]>
234e68b to
a103e75
Compare
|
/ok to test a103e75 |
terrykong
left a comment
There was a problem hiding this comment.
Team review: 5 agents + 3 independent adversarial passes.
The fix is correct and complete. Re-verified independently: megatron-core does patch the storage unpickler at import (megatron/core/__init__.py:58), so the premise is real; the only tensor-bearing values are MeshInfo.mesh under per_layer_params (misc_meta is shape/dtype scalars), so the shallow copy misses nothing; the encodings match restore_refit_info_placements exactly and int64 round-trips through tolist(). Reusing the encoding vLLM's msgspec already emits, so the decoder needed zero changes, is a good call.
2 inline comments, both low severity — test-coverage gaps only. Nothing blocking.
Eight other candidates were dropped after adversarial challenge, including two that looked strong at first: a claimed double-shutdown() (refuted — VllmGeneration.weight_synchronizer is None on this path, so the two call sites are mutually exclusive) and a claimed stale-msgspec-docstring contradiction (refuted — the sync and async engines take different transports, so the existing msgspec docstrings and this PR's pickle premise are both true).
One low-severity follow-up, not worth reopening a resolved thread: CheckpointEngineWeightSynchronizer.shutdown() does an untimed ray.get, and this PR is what first puts it on the single-controller failure path where workers may be wedged; a hang there is not caught by except Exception. A bounded ray.get(..., timeout=...) would be worth a separate issue.
Caveat: no tests or linters were run for this review — the environment is macOS and uv.lock supports linux only. Both test suggestions are unverified.
Generated by Claude Code
Signed-off-by: Youngeun Kwon <[email protected]>
|
/ok to test ddab4e8 |
I am separating PR #3532 into two. Wire-safe part and the MTP gating part.
What does this PR do ?
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.
Add a one line overview of what this PR aims to accomplish.
Issues
List issues that this PR closes (syntax):
Usage
# Add a code snippet demonstrating how to use thisBefore your PR is "Ready for review"
Pre checks:
Additional Information