fix(megatron): shard Megatron rollouts across DP coordinator leaders - #3571
Draft
YigongQin wants to merge 1 commit into
Draft
fix(megatron): shard Megatron rollouts across DP coordinator leaders#3571YigongQin wants to merge 1 commit into
YigongQin wants to merge 1 commit into
Conversation
Signed-off-by: YigongQin <qqqyyy1233@outlook.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.
What does this PR do ?
Shard Megatron inference rollouts across data-parallel coordinator leaders so multi-replica generation scales like vLLM, instead of sending every prompt batch to Ray worker 0 / global rank 0 only.
Issues
None
Usage
No config changes required. Existing Megatron generation recipes automatically use all DP replicas when
world_size / (TP × PP × CP × EP) > 1.Sync rollouts shard the batch across DP leaders:
Async rollouts round-robin single-sample requests across DP leaders (same pattern as vLLM async):
NeMo Gym with multiple DP replicas gets one OpenAI URL per DP leader when
expose_http_server: true.Before your PR is "Ready for review"
Pre checks:
Additional Information
Problem: mcore starts a
DynamicInferenceEngine+ DP coordinator on every replica, but NeMo RL previously routed all rollouts through worker 0 only. Extra DP GPUs did not increase rollout throughput.Changes:
MegatronGeneration.generate: shard prompts withshard_by_batch_size(dp_size)and dispatch viarun_all_workers_sharded_data(vLLM parity).MegatronGeneration.generate_async: round-robin across DP leader workers.MegatronGenerationMixin: useparallel_state.get_data_parallel_rank() == 0forInferenceClient, sleep/wake, HTTP server, and request submission (per-replica, not global rank 0 only).Tests added/updated:
tests/unit/models/generation/test_megatron_generation_dp_shard.py— CPU mock test for driver-side sharding.tests/unit/models/generation/test_megatron_generation.py— async test accepts any DP leader.Suggested local verification: