Repository navigation
fix ple grads under sp - #234
Merged
Merged
Conversation
PLE's SP forward gathers the full sequence, computes and scatters the output back, so every TP rank already produces the complete full-sequence gradient for the replicated key_proj/value_proj/norm_*/conv1d parameters. Marking them sequence_parallel=True made finalize_model_grads SUM those complete gradients again across TP, scaling the updates (and global grad clipping) by tp_size -- a silent gradient correctness bug (issue modelscope#233); TP=2/TP=8 regressions show 2x/8x vs the full-sequence reference before the fix. - ple.py: sync the replicas via average_gradients_across_tp_domain, matching the olmoe q/k-norm precedent. - tuners/lora.py: a base whose own weight is AVG-synced computes on the gathered sequence, so the replicated LoRA factors wrapped around it (e.g. PLE's projections) get the same AVG sync instead of the SP sum. - tests/test_ple_sp_tp_grad.py: real NCCL TP ranks and the real finalize_model_grads, compared against the TP=1 full-sequence reference, with a negative control that reproduces the tp_size amplification.
tastelikefeet
approved these changes
Oct 15, 2026
1 task done
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.
fix #233