fix: resolve TP+PP for nemotron super 49B#1607
Merged
Conversation
When pipeline parallelism splits a model, nn.ModuleList layers are converted to nn.ModuleDict. Three issues surfaced with custom models (e.g. DeciLM/Nemotron-49B) that use explicit self.num_heads in attention views and return tuples from decoder layers: 1. _update_attention_head_counts_for_tp iterates `for layer in layers`, which yields string keys (not modules) for ModuleDict — head counts were never updated, causing shape mismatches in the Q/K/V view. 2. The walrus operator fallback for causal_mask_mapping could leave a raw 2D attention_mask in place of the expected 4D causal mask when the import or computation failed silently. 3. The batch device-move code filtered out None values from nested dicts, dropping causal_mask_mapping entries for sdpa-configured models where create_causal_mask returns None. Additionally, decoder layers in older-style HF models (pre-v5) return tuples rather than bare tensors, and raw 2D padding masks that leak through the pipeline schedule need to be dropped before reaching custom attention code. Verified on nvidia/Llama-3_3-Nemotron-Super-49B-v1_5 with tp4pp2 (100 training steps, hellaswag dataset, 8xH100). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Contributor
|
/ok to test 15f9cbe |
Contributor
Author
|
/claude review |
Contributor
There was a problem hiding this comment.
LGTM. Both fixes are correct and well-targeted:
- ModuleDict iteration (
parallelizer.py): Properly handles the PP-converted ModuleDict by iterating.values()instead of yielding keys. - Tuple unpacking + kwargs removal (
hf_utils.py): Correctly extractshidden_statesfrom the decoder layer's tuple output, matching the standard HF contract.
Contributor
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
4abe87d to
578e85c
Compare
akoumpa
approved these changes
Mar 25, 2026
Contributor
akoumpa
left a comment
There was a problem hiding this comment.
LGTM. thank you @HuiyingLi
Contributor
|
/claude review |
linnanwang
pushed a commit
that referenced
this pull request
Apr 24, 2026
* fix: resolve TP+PP pipeline parallelism bugs for custom HF models When pipeline parallelism splits a model, nn.ModuleList layers are converted to nn.ModuleDict. Three issues surfaced with custom models (e.g. DeciLM/Nemotron-49B) that use explicit self.num_heads in attention views and return tuples from decoder layers: 1. _update_attention_head_counts_for_tp iterates `for layer in layers`, which yields string keys (not modules) for ModuleDict — head counts were never updated, causing shape mismatches in the Q/K/V view. 2. The walrus operator fallback for causal_mask_mapping could leave a raw 2D attention_mask in place of the expected 4D causal mask when the import or computation failed silently. 3. The batch device-move code filtered out None values from nested dicts, dropping causal_mask_mapping entries for sdpa-configured models where create_causal_mask returns None. Additionally, decoder layers in older-style HF models (pre-v5) return tuples rather than bare tensors, and raw 2D padding masks that leak through the pipeline schedule need to be dropped before reaching custom attention code. Verified on nvidia/Llama-3_3-Nemotron-Super-49B-v1_5 with tp4pp2 (100 training steps, hellaswag dataset, 8xH100). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: HuiyingLi <willwin.lee@gmail.com> * update recipe Signed-off-by: HuiyingLi <willwin.lee@gmail.com> * fix Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com> --------- Signed-off-by: HuiyingLi <willwin.lee@gmail.com> Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Alexandros Koumparoulis <akoumparouli@nvidia.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.
single node hellaswag


2nodes squad