NeMo icon indicating copy to clipboard operation
NeMo copied to clipboard

Load master weights from checkpoint

Open kunlunl opened this issue 6 months ago • 1 comments
trafficstars

[!IMPORTANT]
The Update branch button must only be pressed in very rare occassions. An outdated branch is never blocking the merge of a PR. Please reach out to the automation team before pressing that button.

What does this PR do ?

Make MCore initializes master weights from ckpt rather than model params.

Detais:

Currently, when ckpt doesn't contain master weights, mcore's dist-opt will use model weights to initialize master weights. So, there is a potential problem that if the precision of checkpoints are higher than model params, master weights will be less accurate, for example:

  • If weights in checkpoints are fp32, but model params are in bf16, the fp32 master weights are obtained by fp32 ckpt -> bf16 model weights -> fp32 master weights.
  • If weights in checkpoints are bf16, but model params are in fp8, the fp32 master weights are obtained by bf16 ckpt -> quantized to fp8 model params -> dequantized to fp32 master weights.

Although the first case is rare, the second does exists, and it will lead to different loss curves for "bf16 weights+fp8 training" vs "fp8 weights+fp8 training", because their initial values ​​of master weights are different.

This MR makes dist-opt to initialized master weights from ckpt directly, bypassing model params.

Collection: [Note which collection this PR will affect]

Changelog

  • Add specific line by line info of high level changes in this PR.

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this 

GitHub Actions CI

The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.

The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR. To re-run CI remove and add the label again. To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".

Before your PR is "Ready for review"

Pre checks:

  • [ ] Make sure you read and followed Contributor guidelines
  • [ ] Did you write any new necessary tests?
  • [ ] Did you add or update any necessary documentation?
  • [ ] Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • [ ] Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • [ ] New Feature
  • [ ] Bugfix
  • [ ] Documentation

If you haven't finished some of the above items you can still open "Draft" PR.

Who can review?

Anyone in the community is free to review the PR once the checks have passed. Contributor guidelines contains specific people who can review PRs to various areas.

Additional Information

  • Related to # (issue)

kunlunl avatar May 19 '25 07:05 kunlunl

This PR is stale because it has been open for 14 days with no activity. Remove stale label or comment or update or this will be closed in 7 days.

github-actions[bot] avatar Jun 15 '25 02:06 github-actions[bot]

This PR was closed because it has been inactive for 7 days since being marked as stale.

github-actions[bot] avatar Jun 22 '25 02:06 github-actions[bot]

The corresponding MCore MR was merged.

kunlunl avatar Jun 30 '25 18:06 kunlunl

Reopening PR

gautham-kollu avatar Jun 30 '25 18:06 gautham-kollu