[fix] Cleanup usage of pg_collection in gtp - #6234
Conversation
Signed-off-by: Shiqing Fan <shiqingf@nvidia.com>
|
This PR has been automatically converted to draft because all PRs must start as drafts. When you are ready for review, click Ready for Review to begin the review process. This will:
See the contribution guide for more details. |
|
/ok to test 4e87571 |
- Thread pg_collection from TransformerLayer through Attention/MLP into the TE and core linear layers. - Assert in finalize_model_grads when the config enables the axis but the group is missing, instead of treating it as "GTP inactive" and training on wrong gradients. - Add test_gtp_custom_pgs.py: two TransformerBlocks, identical degrees (TP=1, CP=1, GTP_remat=2 over world=4), identical weights and input, one from the MPU groups and one from a custom collection with permuted gtp_remat rank membership. Output and gradients must match; verified it fails without the plumbing. Signed-off-by: Shiqing Fan <shiqingf@nvidia.com>
|
/ok to test 2c47a2e |
a3943e3 to
07b0066
Compare
|
/ok to test 07b0066 |
Signed-off-by: ykarnati <ykarnati@nvidia.com>
07b0066 to
382835b
Compare
|
/ok to test 382835b |
|
/claude strict-review |
There was a problem hiding this comment.
Strict review passed — no significant issues found. LGTM
Reviewed as a pg_collection plumbing refactor for GTP-backed layers. Verified:
- Correctness:
resolve_gtp_remat_groupcorrectly usesvars()nothasattr(dataclass__getattr__returns None for unset fields, sohasattrwould always be True and defeat the MPU fallback) — covered by the fall-back test. The new fail-loud assertion infinalize_model_gradsturns a silent wrong-gradient skip into a hard error when*_remat_size > 1but the group is missing/mismatched. - Backward compat: all new
pg_collectionargs are optional and MPU-fallback preserves pre-pg_collection callers; the default training path stays safe because_build_default_pg_collectionnow populates the gtp_remat fields; the one internal signature change (_allreduce_replicated_grads_over_gtp_remat_group) has both callers updated. - Unused-arg check: every added
pg_collectionparameter has a real use path (resolve or downstream propagation); the newgtp_remat_rank/egtp_remat_rankseed args are wired and defaulted. - Cleanup: removed
HAVE_GTPimport andMEGATRON_GTP_FORCE_ENABLEenv sets are confirmed dead across the tree. - Process-group guidance: the direct
parallel_state.get_*_group()reads are confined to the existing MPU-fallback branch — a documented compatibility point.
Strong new test coverage: the permuted-pairing custom-group test precisely targets the silent 'module reads global groups instead of the passed collection' failure this refactor prevents.
| embd_group = parallel_state.get_embedding_group(check_initialized=False) | ||
| pos_emb_group = parallel_state.get_position_embedding_group(check_initialized=False) | ||
| dp_cp_group = parallel_state.get_data_parallel_group(with_context_parallel=True) | ||
| gtp_remat_group = parallel_state.get_gtp_weight_remat_group(check_initialized=False) |
There was a problem hiding this comment.
@yashaswikarnati when are we getting rid of all of this fallback code?
There was a problem hiding this comment.
Not only for GTP, but everywhere. It's an eyesore :P
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/31029975296 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/31034228133 |
What does this PR do?
Refine usage of
pg_collectionin gtp, which is a planned following up tiny task of #4967Contribution process
Pre-checks