Skip to content

Refit Performance for Large MoE Models #945

Description

@guyueh1
No description provided.

Activity

  1. self-assigned this
    on Aug 20, 2025
  2. added
    Performance
    on Aug 25, 2025
  3. removed their assignment
    on Aug 25, 2025
  4. guyueh1 commented on Aug 28, 2025

    @guyueh1
    ContributorAuthor

    Is your feature request related to a problem? Please describe.

    Currently when running GRPO in large number of GPUs (>= 512), the Ray overhead during refit is large. It is mainly because the single controller sits in the middle of training workers and generation workers and becomes the bottleneck of IPC passing and job submission, as shown in the following figure:

    Image

    Current refit implementation (code) is a loop over groups of model parameters, and for each group we perform:

    • policy.get_weights_ipc_handles: in this step, all policy workers collect parameters to their own GPUs, prepare IPC handles and other metadata, and return them to the main actor
    • policy_generation.update_weights_from_ipc_handles: in this step, the main actor sends the IPC handles and metadata to VllmGenerationWorkers, who consequently send them to Vllm engines;

    The Ray overhead during this process is that the following parts are carried out by main actor sequantially:

    1. job submission: submission of jobs of all policy workers and VllmGenerationWorkers are serial
    2. argument serialization and result deserialization
      Adding these overheads up, it becomes a big bottleneck in refit when number of GPUs is large. For instance, in 512 GPU GRPO job for deepseek v3, we spend ~33s out of 48s refit time on passing IPC handles and metadata.

    Describe the solution you'd like

    The target is to create a way for train worker to directly submit job to vllm engine. As shown in the graph, in co-located case all GPUs have one train worker and one vllm engine; if each train worker can submit job to the vllm engine on the same GPU, an ideal refit process will look like this pseudocode:

    # main actor code
    policy.refit()
    
    # train worker code
    class MegatronPolicyWorker:
        ...
        def refit(self):
            for keys in grouped_param_keys:
                ipc_handles = self.get_weight_ipc_handles(keys)
                self.colocated_vllm_engine.execute_method(
                    "update_weights_from_ipc_handles",
                    args=ipc_handles
                )

    This way, each train worker can call method on vllm engine and all the job submission is distributed/parallelized instead of centralized/serialized in the main actor. This is expected to significantly reduce the 33s part of refit time for DeepSeek.

    The overall goal is to remove main actor from the critical path. A possible implementation path is via zero-mq by adding the following components in our code:

    • Enable other actors to submit job to vllm engine via zeromq
    • Expose the zeromq address for each vllm engine to the corresponding train worker before training starts
    • Implement a new refit method based as described above.
      This plan is subject to change when we figure out more details.

    Describe alternatives you've considered

    To reduce Ray overhead, instead of this way we can also maybe leverage Ray compiled graph.

    Additional context

    N/A

  5. added theissue type on Aug 28, 2025
  6. added
    deepseek
    on Sep 22, 2025
  7. guyueh1 commented on Oct 11, 2025

    @guyueh1
    ContributorAuthor

    The performance of deepseek refit should be much improved with the following two PRs:

  8. guyueh1 commented on Oct 14, 2025

    @guyueh1
    ContributorAuthor

    Some results (Vllm config is fixed to async TP32)

    Vllm config Megatron config Branch Note Refit time
    sync TP64 EP16PP16 main 67s
    async TP32 EP16PP16 #1341 64s
    async TP32 EP16PP16 combining 1267 and 1341 24s
    async TP32 EP16PP16 #1341 only run megatron->hf, no vllm update. This is SOL. 9s
    async TP32 EP64PP4 #1341 only run megatron->hf, no vllm update. This is SOL. ~7s

    Some conclusions:

    1. 1267 can significantly reduce the overhead of vllm (64s to 24s)
    2. still ~15s away from SOL, need to understand the actual vllm update time to figure out if we can bridge this 15s
    3. Using a larger EP can help with all-gather performance, but if we can't reduce the vllm update overhead, this impact is very small.
  9. guyueh1 commented on Oct 23, 2025

    @guyueh1
    ContributorAuthor

    Re-open to track #1417
    This PR dependent on #1267 so I didn't raise it before 1267 is merged

  10. guyueh1 commented on Nov 6, 2025

    @guyueh1
    ContributorAuthor

    closing, #1417 is low impact and will track separately.

  11. added
    qa_rcca_done
    on May 5, 2026
  12. qiaochuz-nv commented on May 5, 2026

    @qiaochuz-nv
    Contributor

    QA RCCA Analysis

    RCCA Status: Done
    RCCA Category: covered
    Test Action: none

    Fix PR: #1341, #1417
    Root Cause: fix PR includes upstream test coverage.
    Trigger Config: Refit Performance for Large MoE Models

    Coverage Assessment:

    Area Result
    Existing Test Upstream fix PR test coverage
    Coverage Status COVERED
    Gap N/A
    Corrective Action No nmfw_tests addition required; fix PR includes upstream test coverage or equivalent regression coverage.

    Conclusion: RCCA classification completed for this closed NeMo-RL GitHub issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Performancedeepseekqa_rcca_done

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions