refactor(update-weight): move the transfer protocols into training_utils/weight_update - #2754
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
…kages
protocols/{broadcast,delta,p2p,p2p_transfer_utils,rdt,cuda_ipc}.py (colocate
renamed cuda_ipc after its transport); hf_weight_iterator/{__init__,bucketing,
atomic_groups}.py. The iterator package keeps its import path via __init__.
The TP/ETP gather machinery (all_gather_params_async and helpers) moves into its only consumer, the direct iterator; named_params_and_buffers becomes megatron_utils/named_weights.py — model introspection shared by the actor, hf_export, and the iterator, never update-specific.
# Conflicts: # miles/backends/megatron_utils/update_weight/common.py
# Conflicts: # miles/backends/megatron_utils/update_weight/common.py
|
codex cmt [P3] Update documentation paths moved by this PR
|
| def _check_and_fix_partition(args: Namespace, name: str, partition_stride: int, partition_dim: int) -> tuple[int, int]: | ||
| """Validate partition_stride values for known parameter patterns. | ||
|
|
||
| After Megatron-LM PR #2708, linear_fc1 correctly reports partition_stride=2 |
There was a problem hiding this comment.
This comment maybe deprecated after our mgt upgrade. non blocking. I will help fix this later.
# Conflicts: # miles/backends/training_utils/weight_update/protocols/cuda_ipc.py
Resolution: main's #3089 added translate_gpu_to_cpu to named_params_and_buffers in update_weight/common.py, which this layer dissolved; the addition moves with the function to named_weights.py.
Part of #1360. Stacked on #2753 (review only the last four commits). The final PR of the step-5 stack: the whole weight-update engine now lives in
training_utils/weight_update/.What
lora_base_cpu_backup_enabled(pure args inspection) moves frommegatron_utils/lora_utils.pytomiles/utils/lora.pynext tois_lora_enabled; both callers follow. Thefrom ..sglang import ...compat shim is inlined as direct sglang imports (megatron_utils/sglang.pystays behind as the megatron actor's dep manager).git mv, imports/path-constants updated, zero logic diff):megatron_utils/update_weight/training_utils/weight_update/update_weight_from_distributed/broadcast.pybroadcast.pyupdate_weight_from_distributed/delta.pydelta.pyupdate_weight_from_distributed/p2p.pyp2p.pyupdate_weight_from_distributed/p2p_transfer_utils.pyp2p_transfer_utils.pyupdate_weight_from_rdt.pyrdt.pyupdate_weight_from_tensor.pycolocate.pyThree test files whose subjects all moved follow into
tests/fast/backends/training_utils/weight_update/(the lock test is renamedtest_broadcast_lock.pyto matchbroadcast.py).What stays in
megatron_utils/update_weight/: the megatron iterator implementations (hf_weight_iterator*.py) andcommon.py— backend code behind the iterator interface.Mechanical Move
The transform script reproduces this PR's entire tree from its base commit (
verify_mechanical_refactorscaffold: applies the transform to a fresh worktree at base, runs pre-commit, diffs against the PR head — verified PASS locally). Script inline below; run from the repo root.transform_move_weight_update_protocols.py