Skip to content

Comments

hybrid-cp part 2 for main branch#2304

Closed
xiaoyao0115 wants to merge 1 commit intoNVIDIA:mainfrom
xiaoyao0115:hybrid-cp-main
Closed

hybrid-cp part 2 for main branch#2304
xiaoyao0115 wants to merge 1 commit intoNVIDIA:mainfrom
xiaoyao0115:hybrid-cp-main

Conversation

@xiaoyao0115
Copy link
Contributor

@xiaoyao0115 xiaoyao0115 commented Nov 19, 2025

This PR is the second part of hybrid-cp. The first part is: #2282

Compared to part 1, this PR adds the following:​

  • Added support for SFT datasets and sequence packing, along with a script. With these additions, hybrid-cp can run end-to-end.​
  • Added a mock SFT dataset that lets users control sequence lengths by specifying a sequence-length distribution or by providing a file containing sequence lengths.​
  • Migrated the hybrid-cp and sequence packing changes into a dataiterator_wrapper to minimize code changes. Adding a new scheduling algorithm now only requires adding a new scheduler class, which keeps the logic clear and easier to maintain.​
  • Added support for FSDP with hybrid-cp; the loss curve is shown below.(model : Qwen3-30B-A3B, hybrid-cp size : 4)
  • Added support for PP, but does not support for FSDP+PP.

There's many improvements that we want to make in the future releases.

  1. The feature is limited to creating dynamic groups of CP of power 2. We hope to add complete dynamic support using changes in TransformerEngine DPA.
  2. The feature does not support CUDA graphs.
  3. The feature works best with FlashAttention instead of cuDNN FusedAttention. This is because the changing lengths and CP size make cuDNN recompile the graph and all performance gains are lost. We'll advocate for dynamic support to cuDNN FusedAttention.

Contribution process

flowchart LR
    A[Pre-checks] --> B[PR Tests]
    subgraph Code Review/Approval
        C1[Expert Review] --> C2[Final Review]
    end
    B --> C1
    C2 --> D[Merge]
Loading

Pre-checks

  • I want this PR in a versioned release and have added the appropriate Milestone (e.g., Core 0.8)
  • I have added relevant unit tests
  • I have added relevant functional tests
  • I have added proper typing to my code Typing guidelines
  • I have added relevant documentation
  • I have run the autoformatter.sh on my PR

Code review

The following process is enforced via the CODEOWNERS file for changes into megatron/core. For changes outside of megatron/core, it is up to the PR author whether or not to tag the Final Reviewer team.

For MRs into `main` branch

(Step 1): Add PR label Expert Review

(Step 2): Collect the expert reviewers reviews

  1. Attach the Expert Review label when your PR is ready for review.
  2. GitHub auto-assigns expert reviewers based on your changes. They will get notified and pick up your PR soon.

⚠️ Only proceed to the next step once all reviewers have approved, merge-conflict are resolved and the CI is passing.
Final Review might get declined if these requirements are not fulfilled.

(Step 3): Final Review

  1. Add Final Review label
  2. GitHub auto-assigns final reviewers based on your changes. They will get notified and pick up your PR soon.

(Optional Step 4): Cherry-pick into release branch

If this PR also needs to be merged into core_r* release branches, after this PR has been merged, select Cherry-pick to open a new PR into the release branch.

For MRs into `dev` branch The proposed review process for `dev` branch is under active discussion.

MRs are mergable after one approval by either eharper@nvidia.com or zijiey@nvidia.com.

Merging your PR

Any member of core-adlr and core-nemo will be able to merge your PR.

Signed-off-by: tailaim <tailaim@nvidia.com>
@xiaoyao0115 xiaoyao0115 requested review from a team as code owners November 19, 2025 16:04
@copy-pr-bot
Copy link

copy-pr-bot bot commented Nov 19, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Comment on lines -244 to -245
num_moe_layers * moe_layer_flops(batch_size, seq_len, hidden_size, moe_ffn_hidden_size,
shared_expert_ffn_hidden_size, num_experts_routed_to, swiglu) +

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I am confused, why moe_layer_flops is ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this! I will fix it!

@parthmannan parthmannan mentioned this pull request Jan 15, 2026
6 tasks
@xiaoyao0115 xiaoyao0115 closed this Feb 4, 2026
@xiaoyao0115 xiaoyao0115 deleted the hybrid-cp-main branch February 4, 2026 16:30
@xiaoyao0115 xiaoyao0115 restored the hybrid-cp-main branch February 4, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants