DDP refactoring: Extract parameter layout computation into optimizer classmethod - #3812
Merged
deepakn94 merged 2 commits intoApr 22, 2026
Merged
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
deepakn94
commented
Mar 11, 2026
deepakn94
commented
Mar 11, 2026
deepakn94
force-pushed
the
dnarayanan/refactor_param_mapping
branch
from
March 18, 2026 19:51
c0918d7 to
9dcf047
Compare
5 tasks
Contributor
Author
|
/claude review |
deepakn94
marked this pull request as ready for review
March 18, 2026 22:56
Contributor
Author
|
/claude review |
deepakn94
marked this pull request as draft
March 18, 2026 23:07
Contributor
Author
|
/claude review |
Contributor
Author
|
/claude review |
deepakn94
force-pushed
the
dnarayanan/refactor_param_mapping
branch
2 times, most recently
from
April 2, 2026 20:33
de016f8 to
807c80a
Compare
Contributor
Author
|
/claude review |
deepakn94
marked this pull request as ready for review
April 2, 2026 21:33
deepakn94
force-pushed
the
dnarayanan/refactor_param_mapping
branch
from
April 19, 2026 21:19
5b64fa2 to
056189f
Compare
Contributor
Author
|
/claude review |
deepakn94
force-pushed
the
dnarayanan/refactor_param_mapping
branch
from
April 19, 2026 21:58
056189f to
556aa44
Compare
deepakn94
force-pushed
the
dnarayanan/refactor_param_mapping
branch
from
April 19, 2026 22:52
556aa44 to
2aaf8f7
Compare
deepakn94
commented
Apr 19, 2026
deepakn94
commented
Apr 19, 2026
deepakn94
force-pushed
the
dnarayanan/refactor_param_mapping
branch
from
April 19, 2026 23:35
2aaf8f7 to
3df5114
Compare
yaoyu-33
approved these changes
Apr 20, 2026
…classmethod Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add deprecation warning for DDP auto-compute fallback, pass param_indices directly to _compute_per_buffer_param_layout instead of mutating after construction, remove nonlocal from _finalize_bucket, add type annotation for param_layout parameter, and add new tests for shared_embedding + bucket_size interaction and layout regression. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
deepakn94
force-pushed
the
dnarayanan/refactor_param_mapping
branch
from
April 21, 2026 00:47
3df5114 to
b94d35e
Compare
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/24801777359 |
maanug-nv
added a commit
to maanug-nv/Megatron-LM
that referenced
this pull request
Apr 30, 2026
Signed-off-by: Maanu Grover <maanug@nvidia.com>
yangbofun
pushed a commit
to xlm-research/Megatron-LM
that referenced
this pull request
May 22, 2026
…classmethod (NVIDIA#3812) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
yhgalaxy
pushed a commit
to yhgalaxy/Megatron-LM
that referenced
this pull request
Jun 17, 2026
…classmethod (NVIDIA#3812) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: yhgalaxy <yhgalaxy@outlook.com>
jon-barker
pushed a commit
to jon-barker/Megatron-LM
that referenced
this pull request
Jul 10, 2026
…classmethod (NVIDIA#3812) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Jon Barker <jbarker@aws-cmh-slurm-1-vscode-02.cm.cluster>
terminator123
pushed a commit
to 021ai/Megatron-LM
that referenced
this pull request
Aug 3, 2026
…classmethod (NVIDIA#3812) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
At a high level, this PR refactors
DistributedDataParallel(DDP). DDP's constructor now accepts afull_param_layoutargument that describes how parameters and gradients should be mapped in the underlying_ParamAndGradBuffer. Distributed optimizers compute this mapping via a staticcompute_full_param_layoutmethod. This allows different optimizers to control gradient buffer layout — e.g., the existingDistributedOptimizeruses a sequential layout with padding to ensure buckets are multiples of the data-parallel size, and in the future,LayerwiseOptimizerfor Muon could specify a mapping such that each gradient bucket shard contains a full layer's gradients. This ensures that: a) gradient reduction can use reduce-scatter instead of all-reduce (gradient and parameter sharding follows optimizer sharding exactly), and b) no extra parameter copies are needed after the parameter all-gather (results go directly into the right place for the next forward pass).Key changes:
param_layout.pymodule withBufferKey,PerBufferParamLayout, andFullParamLayoutdataclasses, plus shared padding utilities (pad_param_start,pad_bucket_end).DistributedOptimizer.compute_full_param_layout()and_compute_per_buffer_param_layout()static methods that pre-compute padded layouts.DistributedDataParallelaccepts an optionalfull_param_layoutand passes per-buffer layouts to_ParamAndGradBuffer._ParamAndGradBufferconsumes pre-computed layouts when provided, falling back to_compute_default_per_buffer_param_layout()(no-padding layout for non-distributed-optimizer cases).training.pypre-computes layouts viaDistributedOptimizer.compute_full_param_layout()when using the distributed optimizer with DDP.test_param_layout.pyfor layout computation functions.In the future,
training.pycan assemble layouts from multiple distributed optimizers (this should be straightforward since each optimizer will have disjoint buffers).