Skip to content

Adding NVRx as a dependency and keeping the current code base optionally#3899

Open
dimapihtar wants to merge 51 commits intoNVIDIA:mainfrom
sbak5:sbak/ckpt_migrate
Open

Adding NVRx as a dependency and keeping the current code base optionally#3899
dimapihtar wants to merge 51 commits intoNVIDIA:mainfrom
sbak5:sbak/ckpt_migrate

Conversation

@dimapihtar
Copy link
Contributor

@dimapihtar dimapihtar commented Mar 17, 2026

What does this PR do ?

  1. Adds NVRx async save routines and deprecates mcore's.
  2. Introduces async_strategy param to make it configurable from the user perspective.
  3. NVRx strategy is set as default async strategy. MCore's async strategy will be used if NVRx is not installed.
  4. Still possible to use MCore's async strategy by setting --async-strategy mcore.
  5. Keeps mcore's async strategy for backward compatibility but will be fully removed and subsituted with related nvrx solution in 1-2 releases.

⚠️ For major changes (either in lines of code or in its impact), please make sure to first share a design doc with the team. If you're unsure what's the best way to do so, contact the @mcore-oncall.

Contribution process

Pre-checks

  • 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

Feel free to message or comment the @mcore-oncall to help accelerate your merge into main. The less complex your PR is, the faster it will be approved and merged!

All PRs start as draft. If you open a non-draft PR, it will be automatically converted to draft.

Step 1: Mark PR as "Ready for Review"

  1. When your PR is ready, click Ready for Review.
  2. An oncall reviewer is auto-assigned and expert reviewers are notified based on your changes.
    • Some PRs may jump straight to step 2. This is determined by .github/CODEOWNERS.

⚠️ Only mark as ready once merge-conflicts are resolved and the CI is passing.
Final Review might get declined if these requirements are not fulfilled.

Step 2: Final Review

For PRs that change megatron/core, once all expert reviewers have approved, the Final Review label is applied automatically and final reviewers are assigned.

For PRs outside megatron/core, this step is skipped.

Step 3: Approved

Once all required reviewers have approved, the Approved label is applied automatically.

Merge

Any member of mcore-engineers will be able to merge your PR.

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.

sbak5 and others added 4 commits March 12, 2026 17:15
Fix dequantize check to use `"dequantize" in type(ten).__dict__` instead
of `hasattr(ten, "dequantize")`. The latter returns True for all
torch.Tensor objects since dequantize is defined on the base class,
causing RuntimeError on non-quantized tensors. The new check only matches
TE subclasses (e.g. Float8Tensor, MXFP8Tensor) that define their own
dequantize override.
@copy-pr-bot
Copy link

copy-pr-bot bot commented Mar 17, 2026

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.

Signed-off-by: dimapihtar <dpihtar@gmail.com>
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Signed-off-by: dimapihtar <dpihtar@gmail.com>
@sbak5
Copy link
Contributor

sbak5 commented Mar 17, 2026

/claude review

@sbak5 sbak5 changed the title Sbak/ckpt migrate Adding NVRx as a dependency and keeping the current code base optionally Mar 17, 2026
dimapihtar and others added 7 commits March 18, 2026 06:16
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Signed-off-by: dimapihtar <dpihtar@gmail.com>
@dimapihtar dimapihtar marked this pull request as ready for review March 18, 2026 14:31
@dimapihtar dimapihtar requested review from a team as code owners March 18, 2026 14:31
@svcnvidia-nemo-ci svcnvidia-nemo-ci requested a review from a team March 18, 2026 14:31
@dimapihtar
Copy link
Contributor Author

/ok to test cc6fd79

@svcnvidia-nemo-ci svcnvidia-nemo-ci added this to the Core 0.16 milestone Mar 18, 2026
@dimapihtar dimapihtar added the Expert Review [deprecated] Apply this label to indicate that your PR is ready for expert review. label Mar 18, 2026
@dimapihtar
Copy link
Contributor Author

/ok to test d2cfee3

@sbak5
Copy link
Contributor

sbak5 commented Mar 18, 2026

https://github.com/NVIDIA/Megatron-LM/actions/runs/23266155298/job/67649083947?pr=3899
It's supposed to raise error during writing but this injection may not work with some issue. @dimapihtar

Signed-off-by: dimapihtar <dpihtar@gmail.com>
@dimapihtar
Copy link
Contributor Author

/ok to test c5c86f5


@debug_time("FullyParallelLoadStrategyWrapper.load", logger)
def load(self, sharded_state_dict: ShardedStateDict, checkpoint_dir: Path) -> StateDict:
def load(
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove any load related changes. We don't have anything yet for loading.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sbak5 load calss _get_filesystem_reader: https://github.com/NVIDIA/Megatron-LM/blob/main/megatron/core/dist_checkpointing/strategies/torch.py#L807

which uses CachedMetadataFileSystemReader: https://github.com/NVIDIA/Megatron-LM/blob/main/megatron/core/dist_checkpointing/strategies/torch.py#L766 so we need to import it properly in respect to async_strategy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm but I guess we can take it from common state dict
let me see

dimapihtar and others added 13 commits March 19, 2026 03:59
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Signed-off-by: dimapihtar <dpihtar@gmail.com>
This reverts commit 48c0d95.
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Signed-off-by: dimapihtar <dpihtar@gmail.com>
@dimapihtar
Copy link
Contributor Author

/ok to test ddc37b5

Signed-off-by: dimapihtar <dpihtar@gmail.com>
@dimapihtar
Copy link
Contributor Author

/ok to test 2c85bea

Signed-off-by: dimapihtar <dpihtar@gmail.com>
@dimapihtar
Copy link
Contributor Author

/ok to test ffe53e1

dimapihtar and others added 3 commits March 20, 2026 05:03
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

complexity: medium Expert Review [deprecated] Apply this label to indicate that your PR is ready for expert review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants