fix(model): pass pp_rank to callable transformer layer specs - #5752
Open
pruprakash wants to merge 1 commit into
Open
fix(model): pass pp_rank to callable transformer layer specs#5752pruprakash wants to merge 1 commit into
pruprakash wants to merge 1 commit into
Conversation
GPTModelProvider.provide() forwarded only vp_stage to a callable transformer_layer_spec, so Megatron-Core block-spec builders fell back to parallel_state.get_pipeline_model_parallel_rank(). Under use_decentralized_pg=True the MPU globals are never initialized, so building any block-spec model asserted with "pipeline_model parallel group is not initialized" before the first forward. mtp_block_spec() had the same omission. Adds unit tests covering the change (red-green verified). Detected by: megatron-bridge QA (test_eval_cp_gdn_metadata_e2e) Signed-off-by: Pruthviraj Prakash <pruprakash@nvidia.com>
Contributor
|
LGTM - clean consolidation of the duplicated inspect.signature spec-invocation logic into _callable_spec_kwargs, with pp_rank resolved from the provider's own _pg_collection.pp instead of MPU globals (correct for decentralized runs). Verified:
Minor (non-blocking): a spec that collects args via **kwargs (rather than a named pp_rank/vp_stage parameter) will not receive these kwargs, since the helper keys off signature parameter names. This matches the pre-existing vp_stage behavior, so it is consistent. Suggested test cases
|
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.
What does this PR do ?
Fixes Qwen3-Next/GDN, Qwen3.5, GLM-5 and DeepSeek-V4 models failing to build with
AssertionError: pipeline_model parallel group is not initializedunderuse_decentralized_pg=True, by passingpp_rankto callable transformer layer specs.Changelog
src/megatron/bridge/models/gpt_provider.py: new_callable_spec_kwargs()resolvespp_rankfrom_pg_collection.pp; used byprovide()andmtp_block_spec().tests/unit_tests/models/test_gpt_provider.py: 4 tests covering both added branches.GitHub Actions CI
See the CI section in the Contributing doc for how to trigger the CI. A Nvidia developer will need to approve and trigger the CI for external contributors.
Before your PR is "Ready for review"
Pre checks:
Additional Information
gpt_provider.py:257-263introspected the spec callable forvp_stageonly, so MCore block-spec builders fell back toparallel_state.get_pipeline_model_parallel_rank(), which decentralized runs never initialize. PP-degree independent: PP=1 fails identically.transformer_layer_spec; blocks eval-CP ([training, perf] feat: Add eval-time context parallelism via decentralized PG rebinding #3755, [training] fix: refresh GDN metadata for eval CP #5624), which requiresuse_decentralized_pg=True.vp_stage-only call predates the repo rename (958fb9b7, 2025-07-16); reachable since M4: Model providers update to use pg_collection #1326.nvcr.io/nvidian/nemo:nightly— RED 2 failed with the fix reverted; GREEN 32 passed / 1 skipped for the whole file. 2-GPU e2e: the GDN model now builds on both ranks and reaches the training forward, where it hits an unrelatedgdn.py:206activation assert (separate issue, not addressed here).get_gpt_mtp_block_specis not givenpp_rank— MCore'sget_mtp_num_layers_to_buildignores it and uses the global anyway.